/** * Set the selection * * @param offset * the offset * @param length * the length */ public void setSelectionRange(int offset, int length) { setSelection(new TextSelection(offset, length)); }
/** * Set the selection * * @param offset * the offset * @param length * the length */ public void setSelectionRange(int offset, int length) { setSelection(new TextSelection(offset, length)); }
@Override public void setSelection(IRegion selection) { viewer.getTextWidget().setSelection(convert(selection)); }
public void selectWithCaretAtStart() { moveCaretAbsolute(this.start); getControl().setSelection(new TextSelection(this.start, this.length)); }
public void selectWithCaretAtEnd() { moveCaretAbsolute(this.end); getControl().setSelection(new TextSelection(this.start, this.length)); }
void updateSelection(int startOffset, int replacedLength, int newLength) { if (getSelection().offset + getSelection().length > startOffset && getSelection().offset < startOffset + replacedLength) { // selection intersects replaced text. set caret behind text change setSelection(new TextSelection(startOffset + newLength, 0)/*, true, false*/); } else { // move selection to keep same text selected setSelection(new TextSelection(getSelection().offset + newLength - replacedLength, getSelection().length)/*, true, false*/); if( getSelection().length > 0 ) { int delta = this.lastTextChangeNewCharCount - this.lastTextChangeReplaceCharCount; this.caretOffsetProperty.set(Math.max(0,Math.min(getCharCount()-1,getCaretOffset() + delta))); } } }
void updateSelection(int startOffset, int replacedLength, int newLength) { if (getSelection().offset + getSelection().length > startOffset && getSelection().offset < startOffset + replacedLength) { // selection intersects replaced text. set caret behind text change setSelection(new TextSelection(startOffset + newLength, 0)/* , true, false */); } else { // move selection to keep same text selected int computedOffset = getSelection().offset + newLength - replacedLength; if (computedOffset >= 0 && computedOffset < getCharCount()) { // we only set this if the offset is valid!! setSelection(new TextSelection(computedOffset, getSelection().length)/* , true, false */); } if (getSelection().length > 0) { int delta = this.lastTextChangeNewCharCount - this.lastTextChangeReplaceCharCount; this.caretOffsetProperty.set(Math.max(0, Math.min(getCharCount() - 1, getCaretOffset() + delta))); } } }
private void handleVerify(VerifyEvent event) { if( !(event.isControlDown() && event.getCode() == KeyCode.SPACE) ) { return; } event.consume(); List<ICompletionProposal> proposals = proposalComputer.apply(new ContentAssistContextData(this.viewer.getTextWidget().getCaretOffset(),this.viewer.getDocument()/*,""*/)); if( proposals.size() == 1) { proposals.get(0).apply(this.viewer.getDocument()); this.viewer.getTextWidget().setSelection(proposals.get(0).getSelection(this.viewer.getDocument())); } else if( ! proposals.isEmpty() ) { // System.err.println(this.viewer.getTextWidget().getCaretLocation()); System.err.println(); Point2D p = this.viewer.getTextWidget().getLocationAtOffset(this.viewer.getTextWidget().getCaretOffset()); System.err.println(p); this.popuop.displayProposals(proposals, this.viewer.getTextWidget().getCaretOffset(), this.viewer.getTextWidget().localToScreen(p)); } } }
private void applySelection() { ICompletionProposal selectedItem = this.proposalList.getSelectionModel().getSelectedItem(); if( selectedItem != null ) { IDocument document = this.viewer.getDocument(); selectedItem.apply(document); this.viewer.getTextWidget().setSelection(selectedItem.getSelection(document)); this.stage.hide(); } }
private void doLink(QuickLink link) { if (link instanceof SimpleQuickLink) { SimpleQuickLink simple = (SimpleQuickLink) link; getControl().setCaretOffset(simple.getRegion().upperEndpoint()); getControl().setSelection(new TextSelection(simple.getRegion().lowerEndpoint(), simple.getRegion().upperEndpoint() - simple.getRegion().lowerEndpoint())); } else if (link instanceof CustomQuickLink) { CustomQuickLink custom = (CustomQuickLink) link; custom.getAction().run(); } }
private void onSourceSelect(SourceSelection data) { if (((URIProvider)input).getURI().equals(data.uri)) { getSourceViewer().getTextWidget().setCaretOffset(data.selection.getOffset() + data.selection.getLength()); getSourceViewer().getTextWidget().setSelection(new TextSelection(data.selection.getOffset(), data.selection.getLength())); getSourceViewer().getTextWidget().revealCaret(); } }
getSkinnable().getContent().replaceTextRange(lineIndex.get(), 0, insert); getSkinnable().setCaretOffset(lineIndex.get() + insert.length()); getSkinnable().setSelection(new TextSelection(lineIndex.get(), insert.length())); updateInsertionMarkerIndex(-1); e.setDropCompleted(true);
getControl().setSelection(new TextSelection(targetOffset, text.length()));