@Override IRegion[] getRanges(ISelection selection) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; final int startLine= cts.getStartLine(); final int endLine= cts.getEndLine(); int visualStartColumn= computeVisualColumn(startLine, cts.getStartColumn()); int visualEndColumn= computeVisualColumn(endLine, cts.getEndColumn()); IRegion[] ranges= new IRegion[endLine - startLine + 1]; for (int line= startLine; line <= endLine; line++) { int startColumn= computeCharacterColumn(line, visualStartColumn); int endColumn= computeCharacterColumn(line, visualEndColumn); IRegion lineInfo= fDocument.getLineInformation(line); int lineEnd= lineInfo.getLength(); startColumn= Math.min(startColumn, lineEnd); endColumn= Math.min(endColumn, lineEnd); ranges[line - startLine]= new Region(lineInfo.getOffset() + startColumn, endColumn - startColumn); } return ranges; }
@Override IRegion[] getRanges(ISelection selection) throws BadLocationException { IBlockTextSelection cts= (IBlockTextSelection)selection; final int startLine= cts.getStartLine(); final int endLine= cts.getEndLine(); int visualStartColumn= computeVisualColumn(startLine, cts.getStartColumn()); int visualEndColumn= computeVisualColumn(endLine, cts.getEndColumn()); IRegion[] ranges= new IRegion[endLine - startLine + 1]; for (int line= startLine; line <= endLine; line++) { int startColumn= computeCharacterColumn(line, visualStartColumn); int endColumn= computeCharacterColumn(line, visualEndColumn); IRegion lineInfo= fDocument.getLineInformation(line); int lineEnd= lineInfo.getLength(); startColumn= Math.min(startColumn, lineEnd); endColumn= Math.min(endColumn, lineEnd); ranges[line - startLine]= new Region(lineInfo.getOffset() + startColumn, endColumn - startColumn); } return ranges; }
@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 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); }
@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); }