Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IDocument.replace()


    }

    if (selection instanceof ITextSelection) {
      textSelection = (ITextSelection) selection;
      try {
        doc.replace(textSelection.getOffset(), textSelection.getLength(), text);
      }
      catch (BadLocationException e) {
        return false;
      }
    }
View Full Code Here


            // replacement length is supposed to be
            // in each case, otherwise we'll get negative
            // replacment length sometimes
            postCaretReplacementLength = 0;
          }
          document.replace(caretOffset, postCaretReplacementLength, getReplacementString().substring(preCaretReplacementLength));
        }
        // Insert the portion of the new text that comes before the
        // current caret position
        // Done second since offsets would change for the post text
        // otherwise
View Full Code Here

        // Done second since offsets would change for the post text
        // otherwise
        // Outright insertions are handled here
        if (caretOffset > getReplacementOffset()) {
          int preCaretTextLength = caretOffset - getReplacementOffset();
          document.replace(getReplacementOffset(), preCaretTextLength, getReplacementString().substring(0, preCaretTextLength));
        }
      }
      catch (BadLocationException x) {
        apply(document);
      }
View Full Code Here

            // replacement length is supposed to be
            // in each case, otherwise we'll get negative
            // replacment length sometimes
            postCaretReplacementLength = 0;
          }
          document.replace(caretOffset, postCaretReplacementLength, getReplacementString().substring(preCaretReplacementLength));
        }
        // Insert the portion of the new text that comes before the
        // current caret position
        // Done second since offsets would change for the post text
        // otherwise
View Full Code Here

        // Done second since offsets would change for the post text
        // otherwise
        // Outright insertions are handled here
        if (caretOffset > getReplacementOffset()) {
          int preCaretTextLength = caretOffset - getReplacementOffset();
          document.replace(getReplacementOffset(), preCaretTextLength, getReplacementString().substring(0, preCaretTextLength));
        }
      }
      catch (BadLocationException x) {
        apply(document);
      }
View Full Code Here

        // Replace tabs with spaces
        for (int i = 0; i >= 0;) {
            i = buffer.indexOf("\t", i);
            if (i >= 0) {
                try {
                    document.replace(i, 1, "    ");
                    buffer.replace(i, i + 1, "    ");
                    if (i < caretPosition) {
                        caretPosition += 3;
                    }
                    i += 3;
View Full Code Here

                    break;
                }
            }
            if (spaceStart + eolSize < eolPos) {
                try {
                    document.replace(spaceStart + 1, eolPos
                            - (spaceStart + eolSize), "");
                    buffer.replace(spaceStart + 1, eolPos - eolSize + 1, "");
                    if (eolPos < caretPosition) {
                        caretPosition -= eolPos - (spaceStart + eolSize);
                    } else if (spaceStart < caretPosition
View Full Code Here

        int docLength = document.getLength();
        try {
            if (docLength == 0
                    || (!document.get(docLength - 1, 1).equals("\n") && !document
                            .get(docLength - 1, 1).equals("\r"))) {
                document.replace(docLength, 0, "\n");
            }
        } catch (BadLocationException e) {
            OutputConsole.outputError(e.getMessage());
        }
View Full Code Here

        OutputConsole console = EclipsePlugin.getDefault().getConsole();
        IDocument document = console.getDocument();

        // Clear the document.
        try {
            document.replace(0, document.getLength(), "");
        } catch (Exception e) {
            EclipsePlugin.getStandardDisplay().asyncExec(
                    new ErrorDialogRunnable(e));
        }
View Full Code Here

                        }
                    }

                    try
                    {
                        document.replace( line.getOffset(), line.getLength(), newLine.toFormattedString() );
                    }
                    catch ( BadLocationException e )
                    {
                        e.printStackTrace();
                    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.