Package com.google.collide.shared.document

Examples of com.google.collide.shared.document.TextChange


  private TextChange deleteText(Line line, int lineNumber, int column, String deletedText) {
    if (editor.isReadOnly()) {
      return null;
    }

    TextChange textChange = TextChange.createDeletion(line, lineNumber, column, deletedText);
    dispatchBeforeTextChange(textChange);
    isMutatingDocument = true;
    editor.getDocument().deleteText(line, lineNumber, column, deletedText.length());
    isMutatingDocument = false;
    dispatchTextChange(textChange);
View Full Code Here


      boolean canReplaceSelection) {
    if (editor.isReadOnly()) {
      return null;
    }

    TextChange textChange = null;

    SelectionModel selection = editor.getSelection();
    if (canReplaceSelection && selection.hasSelection()) {
      Position[] selectionRange = selection.getSelectionRange(true);
      /*
 
View Full Code Here

   */
  public static DocOp createFromTextChanges(DocOpFactory factory,
      JsonArray<TextChange> textChanges) throws Composer.ComposeException {
    DocOp result = null;
    for (int i = 0, n = textChanges.size(); i < n; i++) {
      TextChange textChange = textChanges.get(i);
      DocOp curOp = DocOpUtils.createFromTextChange(factory, textChange);
      result = result != null ? Composer.compose(factory, result, curOp) : curOp;
    }
    return result;
  }
View Full Code Here

    /*
     * There can theoretically be multiple text changes, but we just set
     * selection to the first
     */
    TextChange textChange = textChanges.get(0);
    Position endPosition =
        new Position(new LineInfo(textChange.getEndLine(), textChange.getEndLineNumber()),
            textChange.getEndColumn());
    if (textChange.getType() == TextChange.Type.INSERT) {
      endPosition = PositionUtils.getPosition(endPosition, 1);
    }

    selection.setSelection(new LineInfo(textChange.getLine(), textChange.getLineNumber()),
        textChange.getColumn(), endPosition.getLineInfo(),
        endPosition.getColumn());
  }
View Full Code Here

    for (int i = 0, n = textChanges.size(); i < n; i++) {
      /*
       * For insertion, the second line through the second-to-last line can't
       * have existed in the document, so no point in marking them dirty.
       */
      TextChange textChange = textChanges.get(i);

      Line line = textChange.getLine();
      Line lastLine = textChange.getLastLine();

      if (dirtyLines.indexOf(line) == -1) {
        dirtyLines.add(line);
      }

View Full Code Here

   */
  private class TextListenerImpl implements Document.TextListener, AnchorManager.AnchorVisitor {
    @Override
    public void onTextChange(Document document, JsonArray<TextChange> textChanges) {
      for (int i = 0, n = textChanges.size(); i < n; ++i) {
        TextChange textChange = textChanges.get(i);
        Line line = textChange.getLine();
        Line stopAtLine = textChange.getEndLine().getNextLine();
        while (line != stopAtLine) {
          AnchorUtils.visitAnchorsOnLine(line, this);
          line = line.getNextLine();
        }
      }
View Full Code Here

    c.retain(4, false);
    assertSize(1, c.getDocOp());
  }

  public void testMultilineTextChangeConversions() {
    TextChange textChange;
    DocOp op;

    textChange =
        TextChange.createInsertion(doc.getFirstLine(), 0, 0, doc.getFirstLine()
            .getNextLine(), 1, "Hello world\n");
View Full Code Here

  public void testRetainTrailingNewLineBehavior() {
    // Add the to-be-inserted "A" and the "r" that is to be retained
    doc.insertText(doc.getLastLine(), 0, "Ar");

    TextChange textChange;
    DocOp op;

    textChange =
        TextChange.createInsertion(doc.getLastLine(), doc.getLastLineNumber(), 0,
            doc.getLastLine(), doc.getLastLineNumber(), "A");
View Full Code Here

    assertRetainLine(1, op, 3);
  }

  public void testSimpleTextChangeConversions() {
    Document doc = Document.createFromString("\nThis is\na test\n");
    TextChange textChange =
        TextChange.createInsertion(doc.getFirstLine(), 0, 0, doc.getFirstLine(), 0, "\n");
    DocOp op = DocOpUtils.createFromTextChange(factory, textChange);
    assertSize(3, op);
    assertInsert("\n", op, 0);
    assertRetain(8, true, op, 1);
View Full Code Here

    // There's an empty line at the end
    assertRetainLine(2, op, 2);
  }

  public void testSingleLineTextChangeConversions() {
    TextChange textChange;
    DocOp op;

    textChange =
        TextChange.createInsertion(doc.getFirstLine(), 0, 1, doc.getFirstLine(), 0, "ello");
    op = DocOpUtils.createFromTextChange(factory, textChange);
View Full Code Here

TOP

Related Classes of com.google.collide.shared.document.TextChange

Copyright © 2018 www.massapicom. 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.