Package com.google.collide.shared.document

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


            new LineInfo(selectionModel.getCursorLine(), selectionModel.getCursorLineNumber());
        String text = selectionModel.getCursorLine().getText();
        final char cursorChar = text.charAt(selectionModel.getCursorColumn());
        final char searchChar;
        final boolean searchingForward = OPENING_GROUPS.indexOf(cursorChar) >= 0;
        final Position searchingTo;
        if (searchingForward) {
          searchChar = CLOSING_GROUPS.charAt(OPENING_GROUPS.indexOf(cursorChar));
          searchingTo =
              new Position(new LineInfo(document.getLastLine(), document.getLastLineNumber()),
                  document.getLastLine().length());
        } else if (CLOSING_GROUPS.indexOf(cursorChar) >= 0) {
          searchChar = OPENING_GROUPS.charAt(CLOSING_GROUPS.indexOf(cursorChar));
          searchingTo = new Position(new LineInfo(document.getFirstLine(), 0), 0);
        } else {
          return true; // not on a valid starting character
        }


        Position startingPosition = new Position(cursorLineInfo, selectionModel.getCursorColumn()
            + (searchingForward ? 0 : 1));
        PositionUtils.visit(new LineUtils.LineVisitor() {
          // keep a stack to match the correct corresponding bracket
          ScopeMatcher scopeMatcher = new ScopeMatcher(searchingForward, cursorChar, searchChar);
          @Override
View Full Code Here


     */
    Line beginLine = lineInfo.line();
    int column = startColumn;
    do {
      if (selectNextMatchOnLine(lineInfo, column, lineInfo.line().length())) {
        return new Position(lineInfo, selection.getCursorColumn());
      }
      if (!lineInfo.moveToNext()) {
        lineInfo = document.getFirstLineInfo();
      }
      // after first attempt, we always look at start of line
      column = 0;
    } while (lineInfo.line() != beginLine);

    // We check to ensure there wasn't another match to wrap to on our own line
    if (selectNextMatchOnLine(lineInfo, 0, startColumn)) {
      return new Position(lineInfo, selection.getCursorColumn());
    }
    return null;
  }
View Full Code Here

     */
    Line beginLine = lineInfo.line();
    int column = startColumn;
    do {
      if (selectPreviousMatchOnLine(lineInfo, 0, column)) {
        return new Position(lineInfo, selection.getCursorColumn());
      }

      if (!lineInfo.moveToPrevious()) {
        lineInfo = document.getLastLineInfo();
      }
      // after first attempt we want the last match in a line always
      column = lineInfo.line().getText().length();
    } while (lineInfo.line() != beginLine);

    // We check to ensure there wasn't another match to wrap to on our own line
    if (selectPreviousMatchOnLine(lineInfo, startColumn, beginLine.length())) {
      return new Position(lineInfo, selection.getCursorColumn());
    }
    return null;
  }
View Full Code Here

    if (compare(b[0], a[1]) > 0) {
      // No intersection
      return null;
    }

    Position earlierEnd = compare(a[1], b[1]) < 0 ? a[1] : b[1];
    return new Position[] {b[0], earlierEnd};
  }
View Full Code Here

      difference.add(new Position[] {a[0], getPosition(b[0], -1)});
    }

    int abEndComparison = compare(a[1], b[1]);
    if (abEndComparison != 0) {
      Position earlierEnd = abEndComparison < 0 ? a[1] : b[1];
      Position laterEnd = abEndComparison < 0 ? b[1] : a[1];
      difference.add(new Position[] {getPosition(earlierEnd, 1), laterEnd});
    }

    return difference;
  }
View Full Code Here

        column -= numCharsToTraverse;
        numCharsToTraverse = 0;
      }
    }

    return new Position(new LineInfo(line, lineNumber), column);
  }
View Full Code Here

        column += numCharsToTraverse;
        numCharsToTraverse = 0;
      }
    }

    return new Position(new LineInfo(line, lineNumber), column);
  }
View Full Code Here

    Position[] selection = new Position[2];

    Anchor beginAnchor = getEarlierSelectionAnchor();
    Anchor endAnchor = getLaterSelectionAnchor();

    selection[0] = new Position(beginAnchor.getLineInfo(), beginAnchor.getColumn());

    if (inclusiveEnd) {
      Preconditions.checkState(hasSelection(),
          "Can't get selection range inclusive end when nothing is selected");
      selection[1] =
          PositionUtils.getPosition(endAnchor.getLine(), endAnchor.getLineNumber(),
              endAnchor.getColumn(), -1);
    } else {
      selection[1] = new Position(endAnchor.getLineInfo(), endAnchor.getColumn());
    }

    return selection;
  }
View Full Code Here

  public ReadOnlyAnchor getCursorAnchor() {
    return cursorAnchor;
  }

  public Position getCursorPosition() {
    return new Position(cursorAnchor.getLineInfo(), cursorAnchor.getColumn());
  }
View Full Code Here

    int deleteCount =
        LineUtils.getTextCount(topLine, 0, bottomLine, bottomLine.getText().length() -
          (deleteEndingNewline ? 0 : 1));

    documentMutator.insertText(topLine, topLineInfo.number(), 0, text, false);
    Position endOfInsertion =
        PositionUtils.getPosition(topLine, topLineInfo.number(), 0, text.length() - 1);
    documentMutator.deleteText(endOfInsertion.getLine(), endOfInsertion.getColumn(), deleteCount);
  }
View Full Code Here

TOP

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

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.