Search in sources :

Example 56 with Position

use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.

the class TextEditingTargetScopeHelper method getNextSweaveChunk.

public Scope getNextSweaveChunk() {
    ScopeList scopeList = new ScopeList(docDisplay_);
    scopeList.selectAll(ScopeList.CHUNK);
    final Position selectionEnd = docDisplay_.getSelectionEnd();
    return scopeList.findFirst(new ScopePredicate() {

        @Override
        public boolean test(Scope scope) {
            return scope.getPreamble().compareTo(selectionEnd) > 0;
        }
    });
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) ScopePredicate(org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList.ScopePredicate)

Example 57 with Position

use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.

the class TextEditingTargetScopeHelper method getSweaveChunkInnerRange.

public Range getSweaveChunkInnerRange(Scope chunk) {
    if (chunk == null)
        return null;
    assert chunk.isChunk();
    Position start = Position.create(chunk.getPreamble().getRow() + 1, 0);
    Position end = Position.create(chunk.getEnd().getRow(), 0);
    if (start.getRow() != end.getRow()) {
        end = Position.create(end.getRow() - 1, docDisplay_.getLine(end.getRow() - 1).length());
    }
    return Range.fromPoints(start, end);
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)

Example 58 with Position

use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.

the class TextEditingTargetPresentationHelper method getCurrentSlide.

public String getCurrentSlide() {
    // search starting two lines ahead
    Position cursorPos = docDisplay_.getCursorPosition();
    Position searchPos = Position.create(cursorPos.getRow() + 2, 0);
    InputEditorSelection sel = docDisplay_.search(SLIDE_REGEX, true, false, false, false, searchPos, null, true);
    if (sel != null) {
        InputEditorPosition titlePos = sel.getStart().moveToPreviousLine();
        String title = docDisplay_.getLine(docDisplay_.selectionToPosition(titlePos).getRow());
        title = title.trim();
        if (title.length() > 0 && SLIDE_PATTERN.match(title, 0) == null)
            return title;
        else
            return "(Untitled Slide)";
    } else
        return "(No Slides)";
}
Also used : InputEditorSelection(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) SourcePosition(org.rstudio.studio.client.workbench.views.source.model.SourcePosition) InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)

Example 59 with Position

use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.

the class TextEditingTargetRMarkdownHelper method getRmdChunkOptionText.

/**
    * For a chunk like:
    * 
    * ```{r cars, echo=FALSE}
    * ```
    * 
    * returns the text "r cars, echo=FALSE".
    * 
    * @param chunk Scope representing the chunk
    * @return Range representing the contents of the chunk's {} options block
    */
public static String getRmdChunkOptionText(Scope chunk, DocDisplay display) {
    if (chunk == null)
        return null;
    assert chunk.isChunk();
    Position start = Position.create(chunk.getPreamble().getRow(), // 4 = length of "```{"
    chunk.getPreamble().getColumn() + 4);
    Position end = Position.create(chunk.getPreamble().getRow(), display.getLine(start.getRow()).length() - 1);
    return display.getCode(start, end);
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)

Example 60 with Position

use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.

the class TextEditingTarget method moveCursorToNextInsertLocation.

private Position moveCursorToNextInsertLocation() {
    docDisplay_.collapseSelection(true);
    if (!docDisplay_.moveSelectionToBlankLine()) {
        int lastRow = docDisplay_.getRowCount();
        int lastCol = docDisplay_.getLength(lastRow);
        Position endPos = Position.create(lastRow, lastCol);
        docDisplay_.setCursorPosition(endPos);
        docDisplay_.insertCode("\n", false);
    }
    return docDisplay_.getCursorPosition();
}
Also used : InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Aggregations

Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)64 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)20 JsArrayString (com.google.gwt.core.client.JsArrayString)16 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)11 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)11 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)7 FileChangeHandler (org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)7 TokenCursor (org.rstudio.studio.client.workbench.views.source.editors.text.ace.TokenCursor)7 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)7 Handler (org.rstudio.core.client.command.Handler)6 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)6 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)6 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)6 ServerError (org.rstudio.studio.client.server.ServerError)6 AceEditor (org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor)6 Token (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Token)6 HideMessageHandler (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler)6 RecordNavigationPositionHandler (org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler)6 InputEditorLineWithCursorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorLineWithCursorPosition)4 CodeModel (org.rstudio.studio.client.workbench.views.source.editors.text.ace.CodeModel)4