org.eclipse.swt.custom.BidiSegmentEvent Java Examples

The following examples show how to use org.eclipse.swt.custom.BidiSegmentEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BidiLayout.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void addBidiSegmentListener() {
	styledText.addBidiSegmentListener(new BidiSegmentListener() {
		@Override
		public void lineGetSegments(BidiSegmentEvent event) {
			int length = event.lineText.length();
			if ((isPushMode && !isWidgetReversed) ||
					(!isPushMode && isWidgetReversed)){
				event.segments = new int[] { 0};
				event.segmentsChars = new char[] { RLO};
			} else {
				event.segments = new int[] { 0, length };
				event.segmentsChars = new char[] { LRO, PDF };
			}
			if (isPushMode && (indxPushSegmentStart != -1) && (prevLength< length)) {
				lengthPushSegment++;
			}
			prevLength  = length;
		}
	});

}
 
Example #2
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public PythonSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    super(parent, ruler, null, false, styles, new PyAbstractIndentGuidePreferencesProvider() {

        @Override
        public int getTabWidth() {
            return DefaultIndentPrefs.get(null).getTabWidth();
        }
    });
    StyledText text = this.getTextWidget();
    text.addBidiSegmentListener(new BidiSegmentListener() {
        @Override
        public void lineGetSegments(BidiSegmentEvent event) {
            try {
                event.segments = getBidiLineSegments(event.lineOffset);
            } catch (BadLocationException x) {
                // ignore
            }
        }
    });
    updateViewerFont();
    updateViewerColors();
    getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
}
 
Example #3
Source File: JavaSourceViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void createControl(Composite parent, int styles) {

	// Use LEFT_TO_RIGHT unless otherwise specified.
	if ((styles & SWT.RIGHT_TO_LEFT) == 0 && (styles & SWT.LEFT_TO_RIGHT) == 0)
		styles |= SWT.LEFT_TO_RIGHT;

	final int baseLevel= (styles & SWT.RIGHT_TO_LEFT) != 0 ? Bidi.DIRECTION_RIGHT_TO_LEFT : Bidi.DIRECTION_LEFT_TO_RIGHT;

	super.createControl(parent, styles);

	fBackspaceManager= new SmartBackspaceManager();
	fBackspaceManager.install(this);

	StyledText text= getTextWidget();
	text.addBidiSegmentListener(new BidiSegmentListener() {
		public void lineGetSegments(BidiSegmentEvent event) {
			if (redraws()) {
				try {
					event.segments= getBidiLineSegments(getDocument(), baseLevel, widgetOffset2ModelOffset(event.lineOffset), event.lineText);
				} catch (BadLocationException e) {
					// don't touch the segments
				}
			}
		}
	});
}