use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range in project rstudio by rstudio.
the class SetupChunkOptionsPopupPanel method syncSelection.
private Range syncSelection() {
Range range = findOptsChunk();
if (range == null) {
display_.clearSelection();
display_.setCursorPosition(Position.create(position_.getRow() + 1, 0));
} else {
display_.setSelectionRange(range);
}
return display_.getSelectionRange();
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range in project rstudio by rstudio.
the class YamlFrontMatter method applyFrontMatter.
/**
* Replaces the document's front matter with the given front matter;
* adds a new front matter section if none exists.
*
* @param display The editor to mutate
* @param yaml The new front matter
* @return Whether the editor buffer was mutated
*/
public static boolean applyFrontMatter(DocDisplay display, String yaml) {
if (yaml == null || yaml.isEmpty())
return false;
Range range = YamlFrontMatter.getFrontMatterRange(display);
if (range == null) {
// add the YAML if no front matter exists
range = Range.create(0, 0, 0, 0);
yaml = RmdFrontMatter.FRONTMATTER_SEPARATOR + yaml + RmdFrontMatter.FRONTMATTER_SEPARATOR;
} else if (display.getTextForRange(range) == yaml) {
return false;
}
display.replaceRange(range, yaml);
return true;
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range in project rstudio by rstudio.
the class Source method doReplaceRanges.
private void doReplaceRanges(ReplaceRangesEvent event, DocDisplay docDisplay) {
JsArray<ReplacementData> data = event.getData().getReplacementData();
for (int i = 0; i < data.length(); i++) {
ReplacementData el = data.get(i);
Range range = el.getRange();
String text = el.getText();
// A null range at this point is a proxy to use the current selection
if (range == null)
range = docDisplay.getSelectionRange();
docDisplay.replaceRange(range, text);
}
docDisplay.focus();
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range in project rstudio by rstudio.
the class EditingTargetCodeExecution method executeInlineChunk.
private boolean executeInlineChunk() {
if (!docDisplay_.getSelection().isEmpty())
return false;
Token token = docDisplay_.getTokenAt(docDisplay_.getCursorPosition());
if (token == null || !token.hasType("inline_r_chunk"))
return false;
// construct range to execute, trimming off the "`r ...`" boundaries
int row = docDisplay_.getCursorPosition().getRow();
int startColumn = token.getColumn() + 3;
int endColumn = token.getColumn() + token.getValue().length() - 1;
Range range = Range.create(row, startColumn, row, endColumn);
inlineChunkExecutor_.execute(range);
return true;
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range in project rstudio by rstudio.
the class EditingTargetCodeExecution method executeLatex.
private boolean executeLatex(boolean background) {
// need a suitable editing target to render LaTeX chunks
if (target_ == null)
return false;
Range range = MathJaxUtil.getLatexRange(docDisplay_);
if (range == null)
return false;
target_.renderLatex(range, background);
return true;
}
Aggregations