use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onCompilePDF.
@Handler
void onCompilePDF() {
String pdfPreview = prefs_.pdfPreview().getValue();
boolean showPdf = !pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_NONE);
boolean useInternalPreview = pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_RSTUDIO);
boolean useDesktopSynctexPreview = pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_DESKTOP_SYNCTEX) && Desktop.isDesktop();
String action = new String();
if (showPdf && !useInternalPreview && !useDesktopSynctexPreview)
action = "view_external";
handlePdfCommand(action, useInternalPreview, null);
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onInsertChunk.
@Handler
void onInsertChunk() {
InsertChunkInfo info = docDisplay_.getInsertChunkInfo();
if (info == null)
return;
onInsertChunk(info.getValue(), 1, 0);
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onRenameInScope.
@Handler
void onRenameInScope() {
docDisplay_.focus();
// Save folds (we need to remove them temporarily for the rename helper)
final JsArray<AceFold> folds = docDisplay_.getFolds();
docDisplay_.unfoldAll();
int matches = renameHelper_.renameInScope();
if (matches <= 0) {
if (!docDisplay_.getSelectionValue().isEmpty()) {
String message = "No matches for '" + docDisplay_.getSelectionValue() + "'";
view_.getStatusBar().showMessage(message, 1000);
}
for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
return;
}
String message = "Found " + matches;
if (matches == 1)
message += " match";
else
message += " matches";
String selectedItem = docDisplay_.getSelectionValue();
message += " for " + selectedItem + ".";
docDisplay_.disableSearchHighlight();
view_.getStatusBar().showMessage(message, new HideMessageHandler() {
private boolean onRenameFinished(boolean value) {
for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
return value;
}
@Override
public boolean onNativePreviewEvent(NativePreviewEvent preview) {
int type = preview.getTypeInt();
if (docDisplay_.isPopupVisible())
return false;
// End if the user clicks somewhere
if (type == Event.ONCLICK) {
docDisplay_.exitMultiSelectMode();
docDisplay_.clearSelection();
docDisplay_.enableSearchHighlight();
return onRenameFinished(true);
} else // Otherwise, handle key events
if (type == Event.ONKEYDOWN) {
switch(preview.getNativeEvent().getKeyCode()) {
case KeyCodes.KEY_ENTER:
preview.cancel();
case KeyCodes.KEY_UP:
case KeyCodes.KEY_DOWN:
case KeyCodes.KEY_ESCAPE:
docDisplay_.exitMultiSelectMode();
docDisplay_.clearSelection();
docDisplay_.enableSearchHighlight();
return onRenameFinished(true);
}
}
return false;
}
});
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onExecuteCurrentFunction.
@Handler
void onExecuteCurrentFunction() {
docDisplay_.focus();
// HACK: This is just to force the entire function tree to be built.
// It's the easiest way to make sure getCurrentScope() returns
// a Scope with an end.
docDisplay_.getScopeTree();
Scope currentFunction = docDisplay_.getCurrentFunction(false);
// an unclosed function
if (currentFunction == null || currentFunction.getEnd() == null)
return;
Position start = currentFunction.getPreamble();
Position end = currentFunction.getEnd();
codeExecution_.executeRange(Range.fromPoints(start, end));
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onExecuteFromCurrentLine.
@Handler
void onExecuteFromCurrentLine() {
docDisplay_.focus();
int startRow = docDisplay_.getSelectionStart().getRow();
int startColumn = 0;
Position start = Position.create(startRow, startColumn);
codeExecution_.executeRange(Range.fromPoints(start, endPosition()));
}
Aggregations