@Override TextEdit delete(ISelection selection) throws BadLocationException { if (isEmpty(selection)) { IBlockTextSelection cts= (IBlockTextSelection)selection; selection= new BlockTextSelection(fDocument, cts.getStartLine(), cts.getStartColumn(), cts.getEndLine(), cts.getEndColumn() + 1, fTabWidth); } return replace(selection, "", true); //$NON-NLS-1$ }
@Override ISelection makeReplaceSelection(ISelection selection, String replacement) throws BadLocationException { IBlockTextSelection bts= (IBlockTextSelection)selection; String[] delimiters= fDocument.getLegalLineDelimiters(); int[] index= TextUtilities.indexOf(delimiters, replacement, 0); int length; if (index[0] == -1) length= replacement.length(); else length= index[0]; int startLine= bts.getStartLine(); int column= bts.getStartColumn() + length; int endLine= bts.getEndLine(); int endColumn= computeCharacterColumn(endLine, computeVisualColumn(startLine, column)); return new BlockTextSelection(fDocument, startLine, column, endLine, endColumn, fTabWidth); }
@Override ISelection makeReplaceSelection(ISelection selection, String replacement) throws BadLocationException { IBlockTextSelection bts= (IBlockTextSelection)selection; String[] delimiters= fDocument.getLegalLineDelimiters(); int[] index= TextUtilities.indexOf(delimiters, replacement, 0); int length; if (index[0] == -1) length= replacement.length(); else length= index[0]; int startLine= bts.getStartLine(); int column= bts.getStartColumn() + length; int endLine= bts.getEndLine(); int endColumn= computeCharacterColumn(endLine, computeVisualColumn(startLine, column)); return new BlockTextSelection(fDocument, startLine, column, endLine, endColumn, fTabWidth); }
@Override TextEdit delete(ISelection selection) throws BadLocationException { if (isEmpty(selection)) { IBlockTextSelection cts= (IBlockTextSelection)selection; selection= new BlockTextSelection(fDocument, cts.getStartLine(), cts.getStartColumn(), cts.getEndLine(), cts.getEndColumn() + 1, fTabWidth); } return replace(selection, "", true); //$NON-NLS-1$ }
@Override TextEdit backspace(ISelection selection) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; if (isEmpty(selection) && cts.getStartColumn() > 0) { selection= new BlockTextSelection(fDocument, cts.getStartLine(), cts.getStartColumn() - 1, cts.getEndLine(), cts.getEndColumn(), fTabWidth); } return replace(selection, ""); //$NON-NLS-1$ }
@Override TextEdit backspace(ISelection selection) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; if (isEmpty(selection) && cts.getStartColumn() > 0) { selection= new BlockTextSelection(fDocument, cts.getStartLine(), cts.getStartColumn() - 1, cts.getEndLine(), cts.getEndColumn(), fTabWidth); } return replace(selection, ""); //$NON-NLS-1$ }
@Override ISelection makeEmpty(ISelection selection, boolean beginning) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; int startLine, startColumn, endLine, endColumn; if (beginning) { startLine= cts.getStartLine(); startColumn= cts.getStartColumn(); endLine= cts.getEndLine(); endColumn= computeCharacterColumn(endLine, computeVisualColumn(startLine, startColumn)); } else { endLine= cts.getEndLine(); endColumn= cts.getEndColumn(); startLine= cts.getStartLine(); startColumn= computeCharacterColumn(startLine, computeVisualColumn(endLine, endColumn)); } return new BlockTextSelection(fDocument, startLine, startColumn, endLine, endColumn, fTabWidth); }
@Override ISelection makeEmpty(ISelection selection, boolean beginning) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; int startLine, startColumn, endLine, endColumn; if (beginning) { startLine= cts.getStartLine(); startColumn= cts.getStartColumn(); endLine= cts.getEndLine(); endColumn= computeCharacterColumn(endLine, computeVisualColumn(startLine, startColumn)); } else { endLine= cts.getEndLine(); endColumn= cts.getEndColumn(); startLine= cts.getStartLine(); startColumn= computeCharacterColumn(startLine, computeVisualColumn(endLine, endColumn)); } return new BlockTextSelection(fDocument, startLine, startColumn, endLine, endColumn, fTabWidth); }
/** * Restores a previously saved selection in the document. * <p> * If no selection was previously saved, nothing happens. * * @since 3.0 */ protected void restoreSelection() { if (!fSelections.isEmpty()) { final IDocument document= getDocument(); final Position position= fSelections.pop(); try { document.removePosition(fSelectionCategory, position); Point currentSelection= getSelectedRange(); if (currentSelection == null || currentSelection.x != position.getOffset() || currentSelection.y != position.getLength()) { if (position instanceof ColumnPosition && getTextWidget().getBlockSelection()) { setSelection(new BlockTextSelection(document, document.getLineOfOffset(position.getOffset()), ((ColumnPosition) position).fStartColumn, document.getLineOfOffset(position.getOffset() + position.getLength()), ((ColumnPosition) position).fEndColumn, getTextWidget().getTabs())); } else { setSelectedRange(position.getOffset(), position.getLength()); } } if (fSelections.isEmpty()) clearRememberedSelection(); } catch (BadPositionCategoryException exception) { // Should not happen } catch (BadLocationException x) { // Should not happen } } }
/** * Restores a previously saved selection in the document. * <p> * If no selection was previously saved, nothing happens. * * @since 3.0 */ protected void restoreSelection() { if (!fSelections.isEmpty()) { final IDocument document= getDocument(); final Position position= fSelections.pop(); try { document.removePosition(fSelectionCategory, position); Point currentSelection= getSelectedRange(); if (currentSelection == null || currentSelection.x != position.getOffset() || currentSelection.y != position.getLength()) { if (position instanceof ColumnPosition && getTextWidget().getBlockSelection()) { setSelection(new BlockTextSelection(document, document.getLineOfOffset(position.getOffset()), ((ColumnPosition) position).fStartColumn, document.getLineOfOffset(position.getOffset() + position.getLength()), ((ColumnPosition) position).fEndColumn, getTextWidget().getTabs())); } else { setSelectedRange(position.getOffset(), position.getLength()); } } if (fSelections.isEmpty()) clearRememberedSelection(); } catch (BadPositionCategoryException exception) { // Should not happen } catch (BadLocationException x) { // Should not happen } } }
if (startLine == -1 || endLine == -1) return TextSelection.emptySelection(); return new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, fTextWidget.getTabs()); } catch (BadLocationException e) { return TextSelection.emptySelection();
if (startLine == -1 || endLine == -1) return TextSelection.emptySelection(); return new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, fTextWidget.getTabs()); } catch (BadLocationException e) { return TextSelection.emptySelection();
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());