Package com.google.collide.shared.document

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


    manager.selectNextMatch();
    assertSelection(lineSix, 41, 45);
  }

  public void testFindMatchAfterAndBeforePosition() {
    LineInfo lineSix = SearchTestsUtil.gotoLineInfo(document, 6);
    LineInfo lineEight = SearchTestsUtil.gotoLineInfo(document, 8);

    SearchMatchManager manager = createMatchManager(document, model);
    manager.setSearchPattern(RegExp.compile("doug", "gi"));

    manager.addMatches(lineSix, 1);
View Full Code Here


    manager.selectPreviousMatchFromPosition(lineEight, 10);
    assertSelection(lineEight, 5, 9);
  }
 
  public void testWrapFindNextWhenMatchesOnSameLine() {
    LineInfo lineEleven = SearchTestsUtil.gotoLineInfo(document, 11);

    SearchMatchManager manager = createMatchManager(document, model);
    manager.setSearchPattern(RegExp.compile("Awesome", "gi"));
   
    manager.addMatches(lineEleven, 1);
View Full Code Here

    manager.selectNextMatch();
    assertSelection(lineEleven, 0, 7);
  }

  public void testWrapFindPreviousWhenMatchesOnSameLine() {
    LineInfo lineEleven = SearchTestsUtil.gotoLineInfo(document, 11);

    SearchMatchManager manager = createMatchManager(document, model);
    manager.setSearchPattern(RegExp.compile("Awesome", "gi"));

    manager.addMatches(lineEleven, 1);
View Full Code Here

    manager.selectPreviousMatch();
    assertSelection(lineEleven, 8, 15);
  }

  public void testReplaceMatch() {
    LineInfo lineThree = SearchTestsUtil.gotoLineInfo(document, 3);
    LineInfo lineSix = SearchTestsUtil.gotoLineInfo(document, 6);
    LineInfo lineEight = SearchTestsUtil.gotoLineInfo(document, 8);

    SearchMatchManager manager = createMatchManager(document, model);
    manager.setSearchPattern(RegExp.compile("doug", "gi"));

    // NOTE! Since this a not an editor mutator, selection won't be replaced
    // so you will get newtextoldtext when calling replace.
    manager.addMatches(lineSix, 1);
    assertTrue(manager.replaceMatch("boug"));
    assertEquals("boug", document.getText(lineSix.line(), 41, 4));
    document.deleteText(lineSix.line(), 45, 4);
    assertTrue(manager.replaceMatch("soug"));
    assertEquals("soug", document.getText(lineEight.line(), 0, 4));

    model.setSelection(lineThree, 0, lineThree, 0);
    manager.setSearchPattern(RegExp.compile("catwoman"));
    manager.addMatches(lineThree, 1);
    assertTrue(manager.replaceMatch("dogwoman"));
View Full Code Here

        document, createMockViewport(document, 3), new StubIncrementalScheduler(50, 50));

    SearchMatchManager manager = new SearchMatchManager(document, model, document, task);
    manager.setSearchPattern(RegExp.compile("doug", "gi"));
   
    LineInfo lineSix = SearchTestsUtil.gotoLineInfo(document, 6);
    manager.addMatches(lineSix, 1);
    manager.replaceAllMatches("boug");
   
    assertNull(manager.selectNextMatch());
  }
View Full Code Here

            50, 50));

    SearchMatchManager manager = new SearchMatchManager(document, model, document, task);
    manager.setSearchPattern(RegExp.compile("foo", "gi"));

    LineInfo lineOne = document.getFirstLineInfo();
    manager.addMatches(lineOne, 1);
    manager.replaceAllMatches("notit");

    assertNull(manager.selectNextMatch());
  }
View Full Code Here

            50, 50));

    SearchMatchManager manager = new SearchMatchManager(document, model, document, task);
    manager.setSearchPattern(RegExp.compile("foo", "gi"));

    LineInfo lineOne = document.getFirstLineInfo();
    manager.addMatches(lineOne, 1);
    manager.replaceAllMatches("foofoo");

    assertNotNull(manager.selectNextMatch());
  }
View Full Code Here

  public static LineInfo gotoLineInfo(Document document, int line) {
    Line curLine = document.getFirstLine();
    for (int i = 0; curLine != null && i < line; i++) {
      curLine = curLine.getNextLine();
    }
    return new LineInfo(curLine, line);
  }
View Full Code Here

   */
  public static IAnswer<LineInfo> lineInfoFactory(final Line line, final int number) {
    return new IAnswer<LineInfo>() {
      @Override
      public LineInfo answer() throws Throwable {
        return new LineInfo(line, number);
      }
    };
  }
View Full Code Here

      return;
    }
   
    // If a user is typing, a selection will likely be null (since it isn't an explicit move)
    if (selection != null) {
      LineInfo lineInfo =
          document.getLineFinder().findLine(selection.getCursorPosition().getLineNumber());
      int cursorColumn = selection.getCursorPosition().getColumn();
 
      if (!collaboratorStates.containsKey(selection.getUserId())) {
        createCursor(selection.getUserId(), lineInfo.line(), lineInfo.number(), cursorColumn);
      } else {
        document.getAnchorManager().moveAnchor(collaboratorStates.get(selection.getUserId()).anchor,
            lineInfo.line(), lineInfo.number(), cursorColumn);
      }
    }
   
    if (collaboratorStates.containsKey(userId)) {
      collaboratorStates.get(userId).markAsActive();
View Full Code Here

TOP

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

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.