Example #1
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);
  }