/** * Checks whether the given text starts with a line delimiter and * subsequently contains a white space only. * * @param text the text to check * @return <code>true</code> if the text is a line delimiter followed by * whitespace, <code>false</code> otherwise */ private boolean isWhitespaceText(String text) { if (text == null || text.length() == 0) return false; String[] delimiters= fDocument.getLegalLineDelimiters(); int index= TextUtilities.startsWith(delimiters, text); if (index > -1) { char c; int length= text.length(); for (int i= delimiters[index].length(); i < length; i++) { c= text.charAt(i); if (c != ' ' && c != '\t') return false; } return true; } return false; }
/** * Checks whether the given text starts with a line delimiter and * subsequently contains a white space only. * * @param text the text to check * @return <code>true</code> if the text is a line delimiter followed by * whitespace, <code>false</code> otherwise */ private boolean isWhitespaceText(String text) { if (text == null || text.length() == 0) return false; String[] delimiters= fDocument.getLegalLineDelimiters(); int index= TextUtilities.startsWith(delimiters, text); if (index > -1) { char c; int length= text.length(); for (int i= delimiters[index].length(); i < length; i++) { c= text.charAt(i); if (c != ' ' && c != '\t') return false; } return true; } return false; }
/** * Checks whether the given text starts with a line delimiter and * subsequently contains a white space only. * * @param text the text to check * @return <code>true</code> if the text is a line delimiter followed by whitespace, <code>false</code> otherwise */ private boolean isWhitespaceText(String text) { if (text == null || text.length() == 0) return false; String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters(); int index= TextUtilities.startsWith(delimiters, text); if (index > -1) { char c; int length= text.length(); for (int i= delimiters[index].length(); i < length; i++) { c= text.charAt(i); if (c != ' ' && c != '\t') return false; } return true; } return false; }
/** * Checks whether the given text starts with a line delimiter and * subsequently contains a white space only. * * @param text the text to check * @return <code>true</code> if the text is a line delimiter followed by whitespace, <code>false</code> otherwise */ private boolean isWhitespaceText(String text) { if (text == null || text.length() == 0) return false; String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters(); int index= TextUtilities.startsWith(delimiters, text); if (index > -1) { char c; int length= text.length(); for (int i= delimiters[index].length(); i < length; i++) { c= text.charAt(i); if (c != ' ' && c != '\t') return false; } return true; } return false; }
@Override protected void internalCustomizeDocumentCommand(IDocument document, DocumentCommand command) throws BadLocationException { if (command.length != 0) return; String[] lineDelimiters = document.getLegalLineDelimiters(); int delimiterIndex = TextUtilities.startsWith(lineDelimiters, command.text); if (delimiterIndex != -1) { MultiLineTerminalsEditStrategy bestStrategy = null; IRegion bestStart = null; for(MultiLineTerminalsEditStrategy strategy: strategies) { IRegion candidate = strategy.findStartTerminal(document, command.offset); if (candidate != null) { if (bestStart == null || bestStart.getOffset() < candidate.getOffset()) { bestStrategy = strategy; bestStart = candidate; } } } if (bestStrategy != null) { bestStrategy.internalCustomizeDocumentCommand(document, command); } } }
String originalText = command.text; String[] lineDelimiters = document.getLegalLineDelimiters(); int delimiterIndex = TextUtilities.startsWith(lineDelimiters, originalText); if (delimiterIndex != -1) { IRegion startTerminal = findStartTerminal(document, command.offset);