@Override public Point getSelection() { return fStyledText.getSelection(); }
@Override public void keyPressed(KeyEvent e) { if ( e.keyCode == SWT.SHIFT ) { Point pt = edit.getSelection(); if ( pt.y == edit.getCaretOffset() ) selAnchor = pt.x; else selAnchor = pt.y; } } });
@Override public void getSelectionCount(AccessibleTextEvent e) { StyledText st = StyledText.this; if (st.blockSelection && st.blockXLocation != -1) { Rectangle rect = st.getBlockSelectionPosition(); e.count = rect.height - rect.y + 1; } else { Point point = st.getSelection(); e.count = point.x == point.y ? 0 : 1; } } @Override
/** * Find the previous range before the current selection. */ private StyleRange findPreviousRange() { StyleRange[] ranges = styledText.getStyleRanges(); int currentSelectionStart = styledText.getSelection().x; for (int i = ranges.length - 1; i > -1; i--) { if ((ranges[i].start + ranges[i].length - 1) < currentSelectionStart) { return ranges[i]; } } return null; }
@Override public void insertControlContents(Control control, String text, int cursorPosition) { Point selection = ((StyledText) control).getSelection(); ((StyledText) control).insert(text); if (cursorPosition < text.length()) { ((StyledText) control).setSelection(selection.x + cursorPosition, selection.x + cursorPosition); } }
@Override public void run() { Point selection= fTextWidget.getSelection(); fTextWidget.invokeAction(fAction); fireSelectionChanged(selection); }
private void refresh () { Point pt = cacheContent(edit.getSelection()); if ( pt == null ) return; updateText(pt); }
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
/** * Returns the selection. * * @return - the selection */ public Point getSelection() { return getSourceViewer().getTextWidget().getSelection(); }
public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } public void getSelection(AccessibleTextEvent e) {
public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } public void getCharacterCount(AccessibleTextEvent e) {
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
@Override public void addSelection(AccessibleTextEvent e) { StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) { int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } } @Override
@Override public void setSelection(AccessibleTextEvent e) { if (e.index != 0) return; StyledText st = StyledText.this; Point point = st.getSelection(); if (point.x == point.y) return; int end = e.end; if (end == -1) end = st.getCharCount(); st.setSelection(e.start, end); e.result = ACC.OK; } @Override
protected void pasteText(XtextEditor editor, String text) throws Exception { StyledText textWidget = editor.getInternalSourceViewer().getTextWidget(); Point selection = textWidget.getSelection(); Event event = new Event(); event.start = selection.x; event.end = selection.y; event.text = text; event.keyCode = KeyLookupFactory.getDefault().getCtrl(); textWidget.notifyListeners(SWT.KeyDown, event); Method sendKeyEvent = textWidget.getClass().getDeclaredMethod("sendKeyEvent", Event.class); sendKeyEvent.setAccessible(true); sendKeyEvent.invoke(textWidget, event); }
@Override public void focusGained(FocusEvent e) { currentText = (StyledText) e.widget; // Remove highlighted selection if text widget has changed if ((currentText != lastNavigatedText) && (lastNavigatedText != null)) { lastNavigatedText.setSelection(lastNavigatedText .getSelection().x); } // enable/disable copy action copyAction.setEnabled(currentText.isTextSelected()); } });
void setBullet(int type) { Point selection = styledText.getSelection(); int lineStart = styledText.getLineAtOffset(selection.x); int lineEnd = styledText.getLineAtOffset(selection.y); StyleRange styleRange = new StyleRange(); styleRange.metrics = new GlyphMetrics(0, 0, BULLET_WIDTH); Bullet bullet = new Bullet(type, styleRange); bullet.text = "."; for (int lineIndex = lineStart; lineIndex <= lineEnd; lineIndex++) { Bullet oldBullet = styledText.getLineBullet(lineIndex); styledText.setLineBullet(lineIndex, 1, oldBullet != null ? null : bullet); } }