Beispiel #1
0
  private void navigate(SourcePosition srcPosition, boolean addToHistory, boolean highlightLine) {
    // set cursor to function line
    Position position = Position.create(srcPosition.getRow(), srcPosition.getColumn());
    setCursorPosition(position);

    // skip whitespace if necessary
    if (srcPosition.getColumn() == 0) {
      int curRow = getSession().getSelection().getCursor().getRow();
      String line = getSession().getLine(curRow);
      int funStart = line.indexOf(line.trim());
      position = Position.create(curRow, funStart);
      setCursorPosition(position);
    }

    // scroll as necessary
    if (srcPosition.getScrollPosition() != -1) scrollToY(srcPosition.getScrollPosition());
    else moveCursorNearTop();

    // set focus
    focus();

    if (highlightLine) applyLineHighlight(position.getRow());

    // add to navigation history if requested and our current mode
    // supports history navigation
    if (addToHistory) fireRecordNavigationPosition(position);
  }
Beispiel #2
0
 @Override
 public SourcePosition findFunctionPositionFromCursor(String functionName) {
   Scope func =
       getSession()
           .getMode()
           .getCodeModel()
           .findFunctionDefinitionFromUsage(getCursorPosition(), functionName);
   if (func != null) {
     Position position = func.getPreamble();
     return SourcePosition.create(position.getRow(), position.getColumn());
   } else {
     return null;
   }
 }
Beispiel #3
0
  @Override
  public void highlightDebugLocation(
      SourcePosition startPosition, SourcePosition endPosition, boolean executing) {
    int firstRow = widget_.getEditor().getFirstVisibleRow();
    int lastRow = widget_.getEditor().getLastVisibleRow();

    // if the expression is large, let's just try to land in the middle
    int debugRow =
        (int)
            Math.floor(
                startPosition.getRow() + (endPosition.getRow() - startPosition.getRow()) / 2);

    // if the row at which the debugging occurs is inside a fold, unfold it
    getSession().unfold(debugRow, true);

    // if the line to be debugged is past or near the edges of the screen,
    // scroll it into view. allow some lines of context.
    if (debugRow <= (firstRow + DEBUG_CONTEXT_LINES)
        || debugRow >= (lastRow - DEBUG_CONTEXT_LINES)) {
      widget_.getEditor().scrollToLine(debugRow, true);
    }

    applyDebugLineHighlight(startPosition.asPosition(), endPosition.asPosition(), executing);
  }
Beispiel #4
0
 private void fireRecordNavigationPosition(Position pos) {
   SourcePosition srcPos = SourcePosition.create(pos.getRow(), pos.getColumn());
   fireEvent(new RecordNavigationPositionEvent(srcPos));
 }
Beispiel #5
0
 @Override
 public boolean isAtSourceRow(SourcePosition position) {
   Position currPos = getCursorPosition();
   return currPos.getRow() == position.getRow();
 }
Beispiel #6
0
 public void scrollToBottom() {
   SourcePosition pos = SourcePosition.create(getCurrentLineCount() - 1, 0);
   navigate(pos, false);
 }