int textWidth = bidi.getTextWidth();
int textWidth = bidi.getTextWidth() + leftMargin;
void doColumnRight() {	int line = content.getLineAtOffset(caretOffset);	int lineOffset = content.getOffsetAtLine(line);		int offsetInLine = caretOffset - lineOffset;	String lineText = content.getLine(line);	int lineLength = lineText.length();		if (isBidi()) {		GC gc = new GC(this);		StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);		if (bidi.getTextWidth() > horizontalScrollOffset + getClientArea().width || 			offsetInLine < lineLength) {			if (bidi.isRightToLeft(offsetInLine) == false && 				offsetInLine < lineLength) {				// advance caret logically if in L2R segment (move visually right)				caretOffset++;				doSelection(SWT.RIGHT);				// end of L2R segment reached (visual right side)?				if (bidi.isRightToLeft(caretOffset - lineOffset)) {					// go to end of R2L segment (visually left of next R2L segment)/ 					// end of line					caretOffset++;					while (caretOffset < lineOffset + lineLength &&						   bidi.isRightToLeft(caretOffset - lineOffset)) {						caretOffset++;					}				}			}			else			if (offsetInLine > 0 && 				(bidi.isRightToLeft(offsetInLine) || 				bidi.getTextWidth() > horizontalScrollOffset + getClientArea().width ||				offsetInLine < lineLength)) {				// advance caret visually if in R2L segment or logically at line end 				// but right end of line is not fully visible yet				caretOffset--;				doSelection(SWT.LEFT);				offsetInLine = caretOffset - lineOffset;				// end of R2L segment reached (visual right side)?				if (offsetInLine > 0 && bidi.isRightToLeft(offsetInLine) == false) {					// go to end of R2L segment (visually left of next L2R segment)/ 					// end of line					caretOffset++;					while (caretOffset < lineOffset + lineLength &&						   bidi.isRightToLeft(caretOffset - lineOffset)) {						caretOffset++;					}				}			}			else			if (offsetInLine == 0 && bidi.getCaretPosition(0) != bidi.getTextWidth()) {				// at logical line start in R2L segment but there's more text (a L2R				// segment) go to end of R2L segment (visually left of next L2R				// segment)/end of line				caretOffset++;				while (caretOffset < lineOffset + lineLength &&					   bidi.isRightToLeft(caretOffset - lineOffset - 1)) {					caretOffset++;				}			}			offsetInLine = caretOffset - lineOffset;			// if new caret position is to the right of the client area			if (bidi.getCaretPosition(offsetInLine) >= horizontalScrollOffset) {				// scroll to the caret position				showCaret();			}			else {				// otherwise just update caret position without scrolling it into view				setCaretLocation();				setBidiKeyboardLanguage();			}			if (offsetInLine > 0 && offsetInLine < lineLength - 1) {				int clientAreaEnd = horizontalScrollOffset + getClientArea().width;				boolean directionChange = bidi.isRightToLeft(offsetInLine - 1) == false && bidi.isRightToLeft(offsetInLine);				int textWidth = bidi.getTextWidth();				// between L2R and R2L segment and second character of R2L segment is				// left of right border and logical line end is left of right border				// but visual line end is not left of right border				if (directionChange && 					bidi.isRightToLeft(offsetInLine + 1) &&					bidi.getCaretPosition(offsetInLine + 1) < clientAreaEnd && 					bidi.getCaretPosition(lineLength) < clientAreaEnd && textWidth > clientAreaEnd) {					// make visual line end visible					scrollHorizontalBar(textWidth - clientAreaEnd);				}			}		}		gc.dispose();	}	else	if (offsetInLine < lineLength) {		caretOffset++;		showCaret();	}}