Java Code Examples for org.eclipse.swt.custom.StyledText#getSelectionRange()
The following examples show how to use
org.eclipse.swt.custom.StyledText#getSelectionRange() .
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: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void hideSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.hideSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 2
Source File: CompositeTab.java From ldparteditor with MIT License | 6 votes |
public void showSelection() { if (!state.getFileNameObj().getVertexManager().isUpdated()){ return; } final DatFile df = state.getFileNameObj(); final VertexManager vm = df.getVertexManager(); vm.addSnapshot(); final StyledText st = getTextComposite(); int s1 = st.getSelectionRange().x; int s2 = s1 + st.getSelectionRange().y; int fromLine = s1 > -1 ? st.getLineAtOffset(s1) : s1 * -1; int toLine = s2 > -1 ? st.getLineAtOffset(s2) : s2 * -1; fromLine++; toLine++; Text2SelectionConverter.convert(fromLine, toLine, df); vm.showSelection(); df.addHistory(); st.redraw(0, 0, st.getBounds().width, st.getBounds().height, true); st.forceFocus(); }
Example 3
Source File: JavaScriptLightWeightEditor.java From typescript.java with MIT License | 5 votes |
/** * Returns the signed current selection. The length will be negative if the * resulting selection is right-to-left (RtoL). * <p> * The selection offset is model based. * </p> * * @param sourceViewer * the source viewer * @return a region denoting the current signed selection, for a resulting * RtoL selections length is < 0 */ protected IRegion getSignedSelection(ISourceViewer sourceViewer) { StyledText text = sourceViewer.getTextWidget(); Point selection = text.getSelectionRange(); if (text.getCaretOffset() == selection.x) { selection.x = selection.x + selection.y; selection.y = -selection.y; } selection.x = widgetOffset2ModelOffset(sourceViewer, selection.x); return new Region(selection.x, selection.y); }
Example 4
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static final IRegion getSignedSelection(ISourceViewer sourceViewer) { Point viewerSelection= sourceViewer.getSelectedRange(); StyledText text= sourceViewer.getTextWidget(); Point selection= text.getSelectionRange(); if (text.getCaretOffset() == selection.x) { viewerSelection.x= viewerSelection.x + viewerSelection.y; viewerSelection.y= -viewerSelection.y; } return new Region(viewerSelection.x, viewerSelection.y); }
Example 5
Source File: FindReplaceDialog.java From Rel with Apache License 2.0 | 5 votes |
/** * Create the dialog. * * @param parent * @param style */ public FindReplaceDialog(Shell parent, StyledText text) { super(parent, SWT.DIALOG_TRIM | SWT.RESIZE); this.text = text; setText("Find/Replace"); text.addExtendedModifyListener(textModifyListener); text.addSelectionListener(textSelectionListener); text.addFocusListener(textFocusListener); text.addLineBackgroundListener(textLineBackgroundListener); originalTextSelection = text.getSelectionRange(); }
Example 6
Source File: EditorUtils.java From goclipse with Eclipse Public License 1.0 | 5 votes |
/** * Copy of {@link org.eclipse.jface.text.source.MatchingCharacterPainter#getSignedSelection()} */ public static final IRegion getSignedSelection(ITextViewer sourceViewer) { Point viewerSelection= sourceViewer.getSelectedRange(); StyledText text= sourceViewer.getTextWidget(); Point selection= text.getSelectionRange(); if (text.getCaretOffset() == selection.x) { viewerSelection.x= viewerSelection.x + viewerSelection.y; viewerSelection.y= -viewerSelection.y; } return new Region(viewerSelection.x, viewerSelection.y); }