/** * Determines which one of default line delimiters appears first in the list. If none of them the * hint is returned. * * @param text the text to be checked * @param hint the line delimiter hint * @return the line delimiter */ public static String determineLineDelimiter(String text, String hint) { try { int[] info= indexOf(DELIMITERS, text, 0); return DELIMITERS[info[1]]; } catch (ArrayIndexOutOfBoundsException x) { } return hint; }
/** * Determines which one of default line delimiters appears first in the list. If none of them the * hint is returned. * * @param text the text to be checked * @param hint the line delimiter hint * @return the line delimiter */ public static String determineLineDelimiter(String text, String hint) { try { int[] info= indexOf(DELIMITERS, text, 0); return DELIMITERS[info[1]]; } catch (ArrayIndexOutOfBoundsException x) { } return hint; }
/** * Returns the first line of the given selection. * * @param selection the selection * @return the first line of the selection */ private String getFirstLine(String selection) { if (selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return ""; //$NON-NLS-1$ }
/** * Returns the first line of the given selection. * * @param selection the selection * @return the first line of the selection */ private String getFirstLine(String selection) { if (selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return ""; //$NON-NLS-1$ }
/** * Returns the first line of the given selection. * * @param selection the selection * @return the first line of the selection */ private String getFirstLine(String selection) { if (selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return selection; } }
/** * Returns the first line of the given selection. * * @param selection the selection * @return the first line of the selection */ private String getFirstLine(String selection) { if (selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return selection; } }
@Override protected DelimiterInfo nextDelimiterInfo(String text, int offset) { if (fDelimiters.length > 1) { int[] info= TextUtilities.indexOf(fDelimiters, text, offset); if (info[0] == -1) return null; fDelimiterInfo.delimiterIndex= info[0]; fDelimiterInfo.delimiter= fDelimiters[info[1]]; } else { int index= text.indexOf(fDelimiters[0], offset); if (index == -1) return null; fDelimiterInfo.delimiterIndex= index; fDelimiterInfo.delimiter= fDelimiters[0]; } fDelimiterInfo.delimiterLength= fDelimiterInfo.delimiter.length(); return fDelimiterInfo; } }
@Override protected DelimiterInfo nextDelimiterInfo(String text, int offset) { if (fDelimiters.length > 1) { int[] info= TextUtilities.indexOf(fDelimiters, text, offset); if (info[0] == -1) return null; fDelimiterInfo.delimiterIndex= info[0]; fDelimiterInfo.delimiter= fDelimiters[info[1]]; } else { int index= text.indexOf(fDelimiters[0], offset); if (index == -1) return null; fDelimiterInfo.delimiterIndex= index; fDelimiterInfo.delimiter= fDelimiters[0]; } fDelimiterInfo.delimiterLength= fDelimiterInfo.delimiter.length(); return fDelimiterInfo; } }
/** * Returns the actual selection of the find replace target. * @return the selection of the target */ private String getSelectionString() { String selection= fTarget.getSelectionText(); if (selection != null && selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return null; }
/** * Returns the actual selection of the find replace target. * * @return the actual selection of the find replace target */ private String getSelectionString() { /* * 1GF86V3: ITPUI:WINNT - Internal errors using Find/Replace Dialog * Now uses TextUtilities rather than focusing on '\n' */ String selection= fTarget.getSelectionText(); if (selection != null && selection.length() > 0) { int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0); if (info[0] > 0) return selection.substring(0, info[0]); else if (info[0] == -1) return selection; } return null; } }
/** * Set up a line tracker for text within command if text is multi-line */ private ILineTracker getLineTracker(IDocument document, String originalText) { ConfigurableLineTracker lineTracker = null; int[] delims = TextUtilities.indexOf(document.getLegalLineDelimiters(), originalText, 0); if ((delims[0] != -1) || (delims[1] != -1)) { lineTracker = new ConfigurableLineTracker(document.getLegalLineDelimiters()); lineTracker.set(originalText); } return lineTracker; }
String contents= (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD); String toInsert; if (TextUtilities.indexOf(fDocument.getLegalLineDelimiters(), contents, 0)[0] != -1) {
String text= document.get(line.getOffset(), line.getLength()); int[] found= TextUtilities.indexOf(prefixes, text, 0);
@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); }
String text = document.get(line.getOffset(), line.getLength()); int[] found = TextUtilities.indexOf(prefixes, text, 0);
@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); }
String text= document.get(line.getOffset(), line.getLength()); int[] found= TextUtilities.indexOf(prefixes, text, 0);
String text= document.get(line.getOffset(), line.getLength()); int[] found= TextUtilities.indexOf(prefixes, text, 0);
String text= document.get(line.getOffset(), line.getLength()); int[] found= TextUtilities.indexOf(prefixes, text, 0);
/** * */ protected void appendSpaceBefore(ICSSNode node, String toAppend, StringBuffer source) { if (node == null || source == null) return; if (isCleanup() && !getCleanupStrategy(node).isFormatSource()) return; // for not formatting case on cleanup action Preferences preferences = CSSCorePlugin.getDefault().getPluginPreferences(); if (toAppend != null && toAppend.startsWith("{") && preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_NEWLINE_ON_OPEN_BRACE)) {//$NON-NLS-1$ source.append(getLineDelimiter(node)); source.append(getIndent(node)); return; } else if (/* ! mgr.isOnePropertyPerLine() && */preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH) > 0 && (!preferences.getBoolean(CSSCorePreferenceNames.WRAPPING_PROHIBIT_WRAP_ON_ATTR) || node.getOwnerDocument().getNodeType() != ICSSNode.STYLEDECLARATION_NODE)) { int n = getLastLineLength(node, source); int append = (toAppend != null) ? TextUtilities.indexOf(DefaultLineTracker.DELIMITERS, toAppend, 0)[0] : 0; if (toAppend != null) append = (append < 0) ? toAppend.length() : append; if (n + append + 1 > preferences.getInt(CSSCorePreferenceNames.LINE_WIDTH)) { source.append(getLineDelimiter(node)); source.append(getIndent(node)); source.append(getIndentString()); return; } } source.append(" ");//$NON-NLS-1$ }