Caret caret = getCaret(); String lineText = content.getLine(caretLine); int lineStartOffset = content.getOffsetAtLine(caretLine); int offsetInLine = caretOffset - lineStartOffset; GC gc = null;
int caretLine = getCaretLine();
void setBidiCaretLocation(StyledTextBidi bidi) {	Caret caret = getCaret();	String lineText = content.getLine(caretLine);	int lineStartOffset = content.getOffsetAtLine(caretLine);	int offsetInLine = caretOffset - lineStartOffset;	GC gc = null;		if (bidi == null) {		gc = new GC(this);		bidi = getStyledTextBidi(lineText, lineStartOffset, gc);	}			if (lastCaretDirection == SWT.NULL) {		caretX = bidi.getTextPosition(offsetInLine) + leftMargin - horizontalScrollOffset;	} else {		caretX = bidi.getTextPosition(offsetInLine, lastCaretDirection) + leftMargin - horizontalScrollOffset;	}	if (StyledTextBidi.getKeyboardLanguageDirection() == SWT.RIGHT) {		caretX -= (getCaretWidth() - 1);	}	if (caret != null) {		setBidiCaretDirection();				caret.setLocation(			caretX, 			caretLine * lineHeight - verticalScrollOffset + topMargin);	}	if (gc != null) {		gc.dispose();	}}