use of net.codemirror.mode.ModeInfo in project gerrit by GerritCodeReview.
the class EditScreen method setSyntaxHighlighting.
void setSyntaxHighlighting(boolean b) {
ModeInfo modeInfo = ModeInfo.findMode(content.getContentType(), path);
final String mode = modeInfo != null ? modeInfo.mime() : null;
if (b && mode != null && !mode.isEmpty()) {
injectMode(mode, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
cmBase.setOption("mode", mode);
cmEdit.setOption("mode", mode);
}
@Override
public void onFailure(Throwable caught) {
prefs.syntaxHighlighting(false);
}
});
} else {
cmBase.setOption("mode", (String) null);
cmEdit.setOption("mode", (String) null);
}
}
use of net.codemirror.mode.ModeInfo 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