|
|
|
@ -386,21 +386,32 @@ define([
|
|
|
|
|
exp.mkIndentSettings = function (metadataMgr) {
|
|
|
|
|
var setIndentation = function (units, useTabs, fontSize, spellcheck) {
|
|
|
|
|
if (typeof(units) !== 'number') { return; }
|
|
|
|
|
var doc = editor.getDoc();
|
|
|
|
|
editor.setOption('indentUnit', units);
|
|
|
|
|
editor.setOption('tabSize', units);
|
|
|
|
|
editor.setOption('indentWithTabs', useTabs);
|
|
|
|
|
editor.setOption('spellcheck', spellcheck);
|
|
|
|
|
if (!useTabs) {
|
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
|
Tab: function() {
|
|
|
|
|
editor.replaceSelection(Array(units + 1).join(" "));
|
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
|
Tab: function() {
|
|
|
|
|
if (doc.somethingSelected()) {
|
|
|
|
|
editor.execCommand("indentMore");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
editor.setOption("extraKeys", {
|
|
|
|
|
Tab: undefined,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!useTabs) { editor.execCommand("insertSoftTab"); }
|
|
|
|
|
else { editor.execCommand("insertTab"); }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"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');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|