/** * @param line a line in the text. * @return the offset of the last non-whitespace character. */ public static int getLastNonWhiteSpaceOffset( final TextContent content, final LineInformation line) { if (line.getLength() == 0) { return line.getBeginOffset(); } int index = line.getEndOffset() - 1; final int begin = line.getBeginOffset(); while (index > begin) { final String s = content.getText(index, 1); if (!isWhiteSpace(s)) { break; } index--; } return index; }
/** @return true, if the last character in the text buffer is newline */ public static boolean endsWithEOL(final EditorAdaptor editor) { final TextContent content = editor.getModelContent(); final LineInformation line = content.getLineInformation(content.getNumberOfLines() - 1); return line.getNumber() > 0 && line.getLength() == 0; }
/** @return true, if line contains only whitespace characters */ public static boolean isLineBlank(final TextContent content, final int lineNo) { final LineInformation line = content.getLineInformation(lineNo); return VimUtils.isBlank(content.getText(line.getBeginOffset(), line.getLength())); }