public void setSelection(ISelection sel) { txtViewer.setSelection(sel); }
public void setSelection(ISelection selection, boolean reveal) { if (fViewerInFocus != null) { if (reveal && !isSelectionInsideVisibleRegion(fViewerInFocus, selection)) resetVisibleRegion(); fViewerInFocus.setSelection(selection, reveal); } }
@Override public void run() { SelectionProcessor processor= new SelectionProcessor(TextViewer.this); try { /* Use the selection instead of the event's coordinates. Is this dangerous? */ ISelection selection= getSelection(); int length= e.text.length(); if (length == 0 && e.character == '\0') { // backspace in StyledText block selection mode... TextEdit edit= processor.backspace(selection); edit.apply(fDocument, TextEdit.UPDATE_REGIONS); ISelection empty= processor.makeEmpty(selection, true); setSelection(empty); } else { int lines= processor.getCoveredLines(selection); String delim= fDocument.getLegalLineDelimiters()[0]; StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length()); text.append(e.text); for (int i= 0; i < lines - 1; i++) { text.append(delim); text.append(e.text); } processor.doReplace(selection, text.toString()); } } catch (BadLocationException x) { if (TRACE_ERRORS) System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$ } } });
edit.apply(fDocument, TextEdit.UPDATE_REGIONS); ISelection empty= processor.makeEmpty(selection, true); setSelection(empty); } else { int lines= processor.getCoveredLines(selection);
int startColumn= fSelection.getOffset() - startLineOffset + cp.fStartColumn; int endColumn= selectionEnd - endLineOffset + cp.fEndColumn; setSelection(new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, tabs)); } catch (BadLocationException e) {
int startColumn= fSelection.getOffset() - startLineOffset + cp.fStartColumn; int endColumn= selectionEnd - endLineOffset + cp.fEndColumn; setSelection(new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, tabs)); } catch (BadLocationException e) {
if (fTextWidget.getBlockSelection()) setSelection(new BlockTextSelection(doc, 0, 0, doc.getNumberOfLines() - 1, 1000, fTextWidget.getTabs())); else setSelectedRange(0, doc.getLength());
if (fTextWidget.getBlockSelection()) setSelection(new BlockTextSelection(doc, 0, 0, doc.getNumberOfLines() - 1, 1000, fTextWidget.getTabs())); else setSelectedRange(0, doc.getLength());