Search in sources :

Example 6 with InputEditorSelection

use of org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection 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 7 with InputEditorSelection

use of org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection in project rstudio by rstudio.

the class TextEditingTargetReformatHelper method alignAssignment.

void alignAssignment() {
    InputEditorSelection initialSelection = docDisplay_.getSelection();
    ArrayList<Pair<Integer, Integer>> ranges = getAlignmentRanges();
    if (ranges.isEmpty())
        return;
    for (Pair<Integer, Integer> range : ranges) doAlignAssignment(range.first, range.second);
    docDisplay_.setSelection(initialSelection.extendToLineStart().extendToLineEnd());
}
Also used : InputEditorSelection(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection) Pair(org.rstudio.core.client.Pair)

Example 8 with InputEditorSelection

use of org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection in project rstudio by rstudio.

the class CppCompletionManager method suggestCompletions.

private boolean suggestCompletions(final boolean explicit, boolean canDelay) {
    suggestionTimer_.cancel();
    // check for completions disabled
    if (!completionContext_.isCompletionEnabled())
        return false;
    // check for no selection
    InputEditorSelection selection = docDisplay_.getSelection();
    if (selection == null)
        return false;
    // check for contiguous selection
    if (!docDisplay_.isSelectionCollapsed())
        return false;
    // calculate explicit value for getting completion position (if a 
    // previous request was explicit then count this as explicit)
    boolean positionExplicit = explicit || ((request_ != null) && request_.isExplicit());
    // see if we even have a completion position
    boolean alwaysComplete = uiPrefs_.codeComplete().getValue().equals(UIPrefsAccessor.COMPLETION_ALWAYS);
    int autoChars = uiPrefs_.alwaysCompleteCharacters().getValue();
    final CompletionPosition completionPosition = CppCompletionUtils.getCompletionPosition(docDisplay_, positionExplicit, alwaysComplete, autoChars);
    if (completionPosition == null) {
        terminateCompletionRequest();
        return false;
    } else if ((request_ != null) && !request_.isTerminated() && request_.getCompletionPosition().isSupersetOf(completionPosition)) {
        request_.updateUI(false);
    } else if (canDelay && completionPosition.getScope() == CompletionPosition.Scope.Global) {
        suggestionTimer_.schedule(completionPosition);
    } else {
        performCompletionRequest(completionPosition, explicit);
    }
    return true;
}
Also used : InputEditorSelection(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection)

Aggregations

InputEditorSelection (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorSelection)8 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)4 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)2 Pair (org.rstudio.core.client.Pair)1 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 RnwWeave (org.rstudio.studio.client.common.rnw.RnwWeave)1 QualifiedName (org.rstudio.studio.client.workbench.views.console.shell.assist.CompletionRequester.QualifiedName)1 AceEditor (org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor)1 CodeModel (org.rstudio.studio.client.workbench.views.source.editors.text.ace.CodeModel)1 DplyrJoinContext (org.rstudio.studio.client.workbench.views.source.editors.text.ace.DplyrJoinContext)1 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)1 RInfixData (org.rstudio.studio.client.workbench.views.source.editors.text.ace.RInfixData)1 TokenCursor (org.rstudio.studio.client.workbench.views.source.editors.text.ace.TokenCursor)1