Search in sources :

Example 1 with ConsoleHistoryAddedEvent

use of org.rstudio.studio.client.workbench.views.console.events.ConsoleHistoryAddedEvent in project rstudio by rstudio.

the class NotebookQueueState method onNotebookRangeExecuted.

// Event handlers ----------------------------------------------------------
@Override
public void onNotebookRangeExecuted(NotebookRangeExecutedEvent event) {
    if (queue_ == null || event.getDocId() != queue_.getDocId())
        return;
    Scope scope = notebook_.getChunkScope(event.getChunkId());
    if (scope == null)
        return;
    if (isChunkExecuting(event.getChunkId())) {
        if (event.getExprMode() == NotebookRangeExecutedEvent.EXPR_NEW)
            executingUnit_.setExecutingRange(event.getExecRange());
        else
            executingUnit_.extendExecutingRange(event.getExecRange());
        executingUnit_.addCompletedRange(event.getExecRange());
    }
    // add to console history
    events_.fireEvent(new ConsoleHistoryAddedEvent(event.getCode()));
    // find the queue unit and convert to lines
    for (int i = 0; i < queue_.getUnits().length(); i++) {
        NotebookQueueUnit unit = queue_.getUnits().get(i);
        if (unit.getChunkId() == event.getChunkId()) {
            List<Integer> lines = unit.linesFromRange(event.getExecRange());
            renderLineState(scope.getBodyStart().getRow(), lines, ChunkRowExecState.LINE_EXECUTED);
            break;
        }
    }
}
Also used : ConsoleHistoryAddedEvent(org.rstudio.studio.client.workbench.views.console.events.ConsoleHistoryAddedEvent) Scope(org.rstudio.studio.client.workbench.views.source.editors.text.Scope) NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)

Aggregations

NotebookQueueUnit (org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)1 ConsoleHistoryAddedEvent (org.rstudio.studio.client.workbench.views.console.events.ConsoleHistoryAddedEvent)1 Scope (org.rstudio.studio.client.workbench.views.source.editors.text.Scope)1