boolean isRightOriented = (getStyle() & SWT.MIRRORED) != 0;
boolean isRightOriented = isMirrored();
void doVisualPrevious() {	int line = content.getLineAtOffset(caretOffset);	int lineOffset = content.getOffsetAtLine(line);		int offsetInLine = caretOffset - lineOffset;		if (isBidi()) {		// check if caret location is at the visual beginning of the line		if (columnX <= XINSET && horizontalScrollOffset == 0) { 			return;		}		String lineText = content.getLine(line);		int lineLength = lineText.length();		GC gc = getGC();		StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);		int visualOffset = -1;				if (offsetInLine == lineLength) {			//logical end of line may not be visual end, setup visualOffset to process as usual			visualOffset = bidi.getVisualOffset(offsetInLine - 1);		}		else		if (offsetInLine < lineLength) {			visualOffset = bidi.getVisualOffset(offsetInLine);		}		if (visualOffset != -1) {			if (visualOffset > 0) {				visualOffset--;				offsetInLine = bidi.getLogicalOffset(visualOffset);			}			else			if (visualOffset == 0) {				boolean isRightOriented = (getStyle() & SWT.MIRRORED) != 0;				//move to visual line end (i.e., behind L2R character/in front of R2L character at visual 0)				if ((isRightOriented && bidi.isRightToLeft(offsetInLine) == false) ||					(isRightOriented == false && bidi.isRightToLeft(offsetInLine))) {					offsetInLine++;				}								if (offsetInLine > 0 && offsetInLine < lineLength) {					if (isRightOriented) {						boolean rightToLeftStart = bidi.isRightToLeft(offsetInLine) && bidi.isRightToLeft(offsetInLine - 1) == false;						if (rightToLeftStart) {							//moving from LtoR segment to RtoL segment							lastCaretDirection = ST.COLUMN_NEXT;						}											}					else {						boolean leftToRightStart = bidi.isRightToLeft(offsetInLine) == false && bidi.isRightToLeft(offsetInLine - 1);						if (bidi.isLatinNumber(offsetInLine) && bidi.isRightToLeftInput(offsetInLine - 1)) {							//moving from LtoR segment to latin number 							lastCaretDirection = ST.COLUMN_PREVIOUS;						}						else						if (leftToRightStart) {							//moving from RtoL segment to LtoR segment							lastCaretDirection = ST.COLUMN_NEXT;						}											}				}			}			caretOffset = lineOffset + offsetInLine;			showCaret();		}		if (bidi.getTextPosition(offsetInLine, ST.COLUMN_NEXT) == XINSET) {			//scroll to origin if caret is at origin			scrollHorizontalBar(-horizontalScrollOffset);		}		gc.dispose();	}	else	if (offsetInLine > 0) {		caretOffset--;		showCaret();	}}