Search in sources :

Example 1 with CommandRunner

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();
        }
    });
}
Also used : ModeInfo(net.codemirror.mode.ModeInfo) NativeString(com.google.gerrit.client.rpc.NativeString) CommandRunner(net.codemirror.lib.CodeMirror.CommandRunner) CodeMirror(net.codemirror.lib.CodeMirror)

Aggregations

NativeString (com.google.gerrit.client.rpc.NativeString)1 CodeMirror (net.codemirror.lib.CodeMirror)1 CommandRunner (net.codemirror.lib.CodeMirror.CommandRunner)1 ModeInfo (net.codemirror.mode.ModeInfo)1