private IRegion getMarkedRegion() { if (getTextWidget() == null) return null; if (fMarkPosition == null || fMarkPosition.isDeleted()) return null; int start= fMarkPosition.getOffset(); int end= getSelectedRange().x; return start > end ? new Region (end, start - end) : new Region(start, end - start); }
private IRegion getMarkedRegion() { if (getTextWidget() == null) return null; if (fMarkPosition == null || fMarkPosition.isDeleted()) return null; int start= fMarkPosition.getOffset(); int end= getSelectedRange().x; return start > end ? new Region (end, start - end) : new Region(start, end - start); }
private void executeReplaceVisibleDocument(IDocument visibleDocument) { StyledText textWidget= getTextWidget(); try { if (textWidget != null && !textWidget.isDisposed()) textWidget.setRedraw(false); int topIndex= getTopIndex(); Point selection= getSelectedRange(); setVisibleDocument(visibleDocument); Point currentSelection= getSelectedRange(); if (currentSelection.x != selection.x || currentSelection.y != selection.y) setSelectedRange(selection.x, selection.y); setTopIndex(topIndex); } finally { if (textWidget != null && !textWidget.isDisposed()) textWidget.setRedraw(true); } }
private void executeReplaceVisibleDocument(IDocument visibleDocument) { StyledText textWidget= getTextWidget(); try { if (textWidget != null && !textWidget.isDisposed()) textWidget.setRedraw(false); int topIndex= getTopIndex(); Point selection= getSelectedRange(); setVisibleDocument(visibleDocument); Point currentSelection= getSelectedRange(); if (currentSelection.x != selection.x || currentSelection.y != selection.y) setSelectedRange(selection.x, selection.y); setTopIndex(topIndex); } finally { if (textWidget != null && !textWidget.isDisposed()) textWidget.setRedraw(true); } }
private void expand() { if (isProjectionMode()) { Position found= null; Annotation bestMatch= null; Point selection= getSelectedRange(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); // take the first most fine grained match if (position != null && touches(selection, position)) if (found == null || position.includes(found.offset) && position.includes(found.offset + found.length)) { found= position; bestMatch= annotation; } } } if (bestMatch != null) { fProjectionAnnotationModel.expand(bestMatch); revealRange(selection.x, selection.y); } } }
private void expand() { if (isProjectionMode()) { Position found= null; Annotation bestMatch= null; Point selection= getSelectedRange(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); // take the first most fine grained match if (position != null && touches(selection, position)) if (found == null || position.includes(found.offset) && position.includes(found.offset + found.length)) { found= position; bestMatch= annotation; } } } if (bestMatch != null) { fProjectionAnnotationModel.expand(bestMatch); revealRange(selection.x, selection.y); } } }
private void collapse() { if (isProjectionMode()) { Position found= null; Annotation bestMatch= null; Point selection= getSelectedRange(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (!annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); // take the first most fine grained match if (position != null && touches(selection, position)) if (found == null || found.includes(position.offset) && found.includes(position.offset + position.length)) { found= position; bestMatch= annotation; } } } if (bestMatch != null) { fProjectionAnnotationModel.collapse(bestMatch); revealRange(selection.x, selection.y); } } }
private void collapse() { if (isProjectionMode()) { Position found= null; Annotation bestMatch= null; Point selection= getSelectedRange(); for (Iterator<Annotation> e= fProjectionAnnotationModel.getAnnotationIterator(); e.hasNext();) { ProjectionAnnotation annotation= (ProjectionAnnotation) e.next(); if (!annotation.isCollapsed()) { Position position= fProjectionAnnotationModel.getPosition(annotation); // take the first most fine grained match if (position != null && touches(selection, position)) if (found == null || found.includes(position.offset) && found.includes(position.offset + position.length)) { found= position; bestMatch= annotation; } } } if (bestMatch != null) { fProjectionAnnotationModel.collapse(bestMatch); revealRange(selection.x, selection.y); } } }
return; Point selectedRange = viewer.getSelectedRange(); Position selectedPosition = selectedRange == null ? null : new Position(selectedRange.x, selectedRange.y); boolean updateSelectedRange = false;
@Override protected void handleVerifyEvent(VerifyEvent e) { if (getTextWidget().getBlockSelection()) { ITextSelection selection= (ITextSelection) getSelection(); if (exposeModelRange(new Region(selection.getOffset(), selection.getLength()))) setSelection(selection); super.handleVerifyEvent(e); return; } Point selection= getSelectedRange(); IRegion modelRange= event2ModelRange(e); if (exposeModelRange(modelRange)) { e.doit= false; try { if (selection.y == 0 && e.text.length() <= 1 && modelRange.getLength() == 1) { selection.y= 1; if (selection.x - 1 == modelRange.getOffset()) selection.x--; } getDocument().replace(selection.x, selection.y, e.text); setSelectedRange(selection.x + e.text.length(), 0); } catch (BadLocationException e1) { // ignore as nothing bad happens (no log at this level) } } else super.handleVerifyEvent(e); }
@Override protected void handleVerifyEvent(VerifyEvent e) { if (getTextWidget().getBlockSelection()) { ITextSelection selection= (ITextSelection) getSelection(); if (exposeModelRange(new Region(selection.getOffset(), selection.getLength()))) setSelection(selection); super.handleVerifyEvent(e); return; } Point selection= getSelectedRange(); IRegion modelRange= event2ModelRange(e); if (exposeModelRange(modelRange)) { e.doit= false; try { if (selection.y == 0 && e.text.length() <= 1 && modelRange.getLength() == 1) { selection.y= 1; if (selection.x - 1 == modelRange.getOffset()) selection.x--; } getDocument().replace(selection.x, selection.y, e.text); setSelectedRange(selection.x + e.text.length(), 0); } catch (BadLocationException e1) { // ignore as nothing bad happens (no log at this level) } } else super.handleVerifyEvent(e); }