|
|
@ -386,21 +386,32 @@ define([
|
|
|
|
exp.mkIndentSettings = function (metadataMgr) {
|
|
|
|
exp.mkIndentSettings = function (metadataMgr) {
|
|
|
|
var setIndentation = function (units, useTabs, fontSize, spellcheck) {
|
|
|
|
var setIndentation = function (units, useTabs, fontSize, spellcheck) {
|
|
|
|
if (typeof(units) !== 'number') { return; }
|
|
|
|
if (typeof(units) !== 'number') { return; }
|
|
|
|
|
|
|
|
var doc = editor.getDoc();
|
|
|
|
editor.setOption('indentUnit', units);
|
|
|
|
editor.setOption('indentUnit', units);
|
|
|
|
editor.setOption('tabSize', units);
|
|
|
|
editor.setOption('tabSize', units);
|
|
|
|
editor.setOption('indentWithTabs', useTabs);
|
|
|
|
editor.setOption('indentWithTabs', useTabs);
|
|
|
|
editor.setOption('spellcheck', spellcheck);
|
|
|
|
editor.setOption('spellcheck', spellcheck);
|
|
|
|
if (!useTabs) {
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
Tab: function() {
|
|
|
|
Tab: function() {
|
|
|
|
if (doc.somethingSelected()) {
|
|
|
|
editor.replaceSelection(Array(units + 1).join(" "));
|
|
|
|
editor.execCommand("indentMore");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
else {
|
|
|
|
} else {
|
|
|
|
if (!useTabs) { editor.execCommand("insertSoftTab"); }
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
else { editor.execCommand("insertTab"); }
|
|
|
|
Tab: undefined,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
"Shift-Tab": function () {
|
|
|
|
|
|
|
|
editor.execCommand("indentLess");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"Backspace": function () {
|
|
|
|
|
|
|
|
var cursor = doc.getCursor();
|
|
|
|
|
|
|
|
var line = doc.getLine(cursor.line);
|
|
|
|
|
|
|
|
if (line.substring(0, cursor.ch).trim() === "") { editor.execCommand("indentLess"); }
|
|
|
|
|
|
|
|
else { editor.execCommand("delCharBefore"); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
$('.CodeMirror').css('font-size', fontSize+'px');
|
|
|
|
$('.CodeMirror').css('font-size', fontSize+'px');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|