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)";
}
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());
}
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;
}
Aggregations