Search in sources :

Example 6 with SourcePosition

use of org.rstudio.studio.client.workbench.views.source.model.SourcePosition in project rstudio by rstudio.

the class AceEditor method navigate.

private void navigate(SourcePosition srcPosition, boolean addToHistory, boolean highlightLine) {
    // get existing cursor position
    Position previousCursorPos = getCursorPosition();
    // 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(), 0);
    else if (position.getRow() != previousCursorPos.getRow())
        moveCursorNearTop();
    else
        ensureCursorVisible();
    // set focus
    focus();
    if (highlightLine)
        applyLineHighlight(position.getRow());
    // supports history navigation
    if (addToHistory)
        fireRecordNavigationPosition(position);
}
Also used : InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) SourcePosition(org.rstudio.studio.client.workbench.views.source.model.SourcePosition) JsArrayString(com.google.gwt.core.client.JsArrayString) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Aggregations

SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)6 JsArrayString (com.google.gwt.core.client.JsArrayString)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2 ServerError (org.rstudio.studio.client.server.ServerError)2 SendToConsoleEvent (org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 JSONString (com.google.gwt.json.client.JSONString)1 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)1 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 FileFunctionDefinition (org.rstudio.studio.client.workbench.codesearch.model.FileFunctionDefinition)1 ObjectDefinition (org.rstudio.studio.client.workbench.codesearch.model.ObjectDefinition)1 SearchPathFunctionDefinition (org.rstudio.studio.client.workbench.codesearch.model.SearchPathFunctionDefinition)1 InputEditorLineWithCursorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorLineWithCursorPosition)1 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)1 NavigationResult (org.rstudio.studio.client.workbench.views.source.SourceWindowManager.NavigationResult)1 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)1 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)1 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)1 AceEditor (org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor)1 ScopeFunction (org.rstudio.studio.client.workbench.views.source.editors.text.ScopeFunction)1