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); }
@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); }
@Override public boolean isAtSourceRow(SourcePosition position) { Position currPos = getCursorPosition(); return currPos.getRow() == position.getRow(); }