Package com.google.collide.shared.document

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


    /*
     * Basic Strategy: loop through lines until we find another match, if we hit
     * the end start at the top. Until we hit our own line then just select the
     * first match from index 0 (shouldn't be us).
     */
    Line beginLine = lineInfo.line();
    int column = startColumn;
    do {
      if (selectNextMatchOnLine(lineInfo, column, lineInfo.line().length())) {
        return new Position(lineInfo, selection.getCursorColumn());
      }
View Full Code Here


    /*
     * Basic Strategy: loop through lines going up, we have to go right to left
     * though so we use the line keys to determine how many matches should be in
     * a line and back out from that.
     */
    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

     */
    int lineTextLength = lineInfo.line().getText().length();
    if (column >= lineTextLength) {
      moveCursor(lineInfo, lineTextLength, true, false, getSelectionRangeForCallback());
    } else if (selectionGranularity == SelectionGranularity.WORD) {
      Line line = lineInfo.line();
      String text = line.getText();
      if (UnicodeUtils.isWhitespace(text.charAt(column))) {
        moveCursor(lineInfo, column, true, false, getSelectionRangeForCallback());
      } else {
        // Start seeking from the next column so the character under cursor
        // will belong to the "previous word".
View Full Code Here

   *        granularity is line.)
   */
  private void moveCursorUsingSelectionGranularity(LineInfo targetLineInfo, int x,
      boolean updatePreferredColumn) {

    Line targetLine = targetLineInfo.line();
    int roundedTargetColumn = buffer.convertXToRoundedVisibleColumn(x, targetLine);
    // Forward if the cursor anchor will be ahead of the base anchor
    boolean growForward =
        AnchorUtils.compare(baseAnchor, targetLineInfo.number(), roundedTargetColumn) <= 0;

    LineInfo newLineInfo = targetLineInfo;
    int newColumn = roundedTargetColumn;

    switch (selectionGranularity) {
      case WORD:
        if (growForward) {
          /*
           * Floor the column so the last pixel of the last character of the
           * current word does not trigger a finding of the next word
           */
          newColumn =
              TextUtils.findNextWord(
                  targetLine.getText(),
                  buffer.convertXToColumn(x, targetLine, RoundingStrategy.FLOOR), false);
        } else {
          // See note above about flooring, but we ceil here instead
          newColumn =
              TextUtils.findPreviousWord(
                  targetLine.getText(),
                  buffer.convertXToColumn(x, targetLine, RoundingStrategy.CEIL), false);
        }
        break;

      case LINE:
View Full Code Here

  }

  private void adjustSelectionIndentationAssumingEarlierSelectionAnchorWontShift(
      final DocumentMutator documentMutator, final String tabString, final boolean indent) {
    Position[] selectionRange = getSelectionRange(false);
    Line terminator = selectionRange[1].getLine();
    if (selectionRange[1].getColumn() != 0 || !hasSelection()) {
      terminator = terminator.getNextLine();
    }

    int lineNumber = selectionRange[0].getLineNumber();
    Line line = selectionRange[0].getLine();

    while (line != terminator) {
      if (indent) {
        documentMutator.insertText(line, lineNumber, 0, tabString, false);
      } else {
        int toDelete = StringUtils.findCommonPrefixLength(tabString, line.getText());
        if (toDelete > 0) {
          documentMutator.deleteText(line, 0, toDelete);
        }
      }
      lineNumber++;
      line = line.getNextLine();
    }
  }
View Full Code Here

  void renderDirtyLines(JsonArray<Line> dirtyLines) {
    int maxLineLength = buffer.getMaxLineLength();
    int newMaxLineLength = maxLineLength;

    for (int i = 0, n = dirtyLines.size(); i < n; i++) {
      Line line = dirtyLines.get(i);
      Element lineElement = getLineElement(line);
      if (lineElement == null) {
        /*
         * The line may have been in the viewport when marked as dirty, but it
         * is not anymore
         */
        continue;
      }

      if (buffer.hasLineElement(lineElement)) {
        lineRendererController.renderLine(line, LineUtils.getCachedLineNumber(line), lineElement,
            false);
      }

      int lineLength = line.getText().length();
      if (lineLength > newMaxLineLength) {
        newMaxLineLength = lineLength;
      }
    }

View Full Code Here

   */
  void renderViewportContentChange(int beginLineNumber, JsonArray<Line> removedLines) {

    // Garbage collect the elements of removed lines
    for (int i = 0, n = removedLines.size(); i < n; i++) {
      Line line = removedLines.get(i);
      garbageCollectLine(line);
    }
    /*
     * New lines being rendered were at +createOffset below the viewport before
     * this render pass.
View Full Code Here

   * @param createOffset the offset in pixels that this line would be at before
   *        this rendering pass, used to animate in from offscreen
   */
  public void fillOrUpdateLines(Line beginLine, int beginLineNumber, Line endLine,
      int endLineNumber, int createOffset) {
    Line curLine = beginLine;
    int curLineNumber = beginLineNumber;
    if (curLineNumber <= endLineNumber) {
      for (; curLineNumber <= endLineNumber && curLine != null; curLineNumber++) {
        createOrUpdateLineElement(curLine, curLineNumber, createOffset);
        curLine = curLine.getNextLine();
      }
    } else {
      for (; curLineNumber >= endLineNumber && curLine != null; curLineNumber--) {
        createOrUpdateLineElement(curLine, curLineNumber, createOffset);
        curLine = curLine.getPreviousLine();
      }
    }
  }
View Full Code Here

   */
  public void garbageCollectLines(Line beginLine, int beginNumber, Line endLine, int endNumber) {

    if (beginNumber > endNumber) {
      // Swap so beginNumber < endNumber
      Line tmpLine = beginLine;
      int tmpNumber = beginNumber;
      beginLine = endLine;
      beginNumber = endNumber;
      endLine = tmpLine;
      endNumber = tmpNumber;
    }

    Line curLine = beginLine;
    for (int curNumber = beginNumber; curNumber <= endNumber && curLine != null; curNumber++) {
      garbageCollectLine(curLine);
      curLine = curLine.getNextLine();
    }
  }
View Full Code Here

    if (beginLine == endLine) {
      return endColumn - beginColumn + 1;
    }

    int count = beginLine.getText().length() - beginColumn;
    Line line = beginLine.getNextLine();
    while (line != null && line != endLine) {
      count += line.getText().length();
      line = line.getNextLine();
    }
    if (line == null) {
      throw new IndexOutOfBoundsException("can't find endLine");
    }
    count += endColumn + 1;
View Full Code Here

TOP

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

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.