use of net.codemirror.lib.CodeMirror.CommandRunner in project gerrit by GerritCodeReview.
the class EditScreen method initEditor.
private void initEditor() {
ModeInfo mode = null;
String editContent = "";
if (content != null && content.getResult() != null) {
editContent = content.getResult().asString();
if (prefs.syntaxHighlighting()) {
mode = ModeInfo.findMode(content.getContentType(), path);
}
}
mv = MergeView.create(editor, Configuration.create().set("autoCloseBrackets", prefs.autoCloseBrackets()).set("cursorBlinkRate", prefs.cursorBlinkRate()).set("cursorHeight", 0.85).set("indentUnit", prefs.indentUnit()).set("keyMap", prefs.keyMapType().name().toLowerCase()).set("lineNumbers", prefs.hideLineNumbers()).set("lineWrapping", false).set("matchBrackets", prefs.matchBrackets()).set("mode", mode != null ? mode.mime() : null).set("origLeft", editContent).set("scrollbarStyle", "overlay").set("showTrailingSpace", prefs.showWhitespaceErrors()).set("styleSelectedText", true).set("tabSize", prefs.tabSize()).set("theme", prefs.theme().name().toLowerCase()).set("value", ""));
cmBase = mv.leftOriginal();
cmBase.getWrapperElement().addClassName(style.base());
cmEdit = mv.editor();
setCmBaseValue();
cmEdit.setValue(editContent);
CodeMirror.addCommand("save", new CommandRunner() {
@Override
public void run(CodeMirror instance) {
save().run();
}
});
}
Aggregations