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