(CodeMirror)
| 7664 | var optionHandlers = {}; |
| 7665 | |
| 7666 | function defineOptions(CodeMirror) { |
| 7667 | var optionHandlers = CodeMirror.optionHandlers; |
| 7668 | |
| 7669 | function option(name, deflt, handle, notOnInit) { |
| 7670 | CodeMirror.defaults[name] = deflt; |
| 7671 | if (handle) { optionHandlers[name] = |
| 7672 | notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; } |
| 7673 | } |
| 7674 | |
| 7675 | CodeMirror.defineOption = option; |
| 7676 | |
| 7677 | // Passed to option handlers when there is no old value. |
| 7678 | CodeMirror.Init = Init; |
| 7679 | |
| 7680 | // These two are, on init, called from the constructor because they |
| 7681 | // have to be initialized before the editor can start at all. |
| 7682 | option("value", "", function (cm, val) { return cm.setValue(val); }, true); |
| 7683 | option("mode", null, function (cm, val) { |
| 7684 | cm.doc.modeOption = val; |
| 7685 | loadMode(cm); |
| 7686 | }, true); |
| 7687 | |
| 7688 | option("indentUnit", 2, loadMode, true); |
| 7689 | option("indentWithTabs", false); |
| 7690 | option("smartIndent", true); |
| 7691 | option("tabSize", 4, function (cm) { |
| 7692 | resetModeState(cm); |
| 7693 | clearCaches(cm); |
| 7694 | regChange(cm); |
| 7695 | }, true); |
| 7696 | |
| 7697 | option("lineSeparator", null, function (cm, val) { |
| 7698 | cm.doc.lineSep = val; |
| 7699 | if (!val) { return } |
| 7700 | var newBreaks = [], lineNo = cm.doc.first; |
| 7701 | cm.doc.iter(function (line) { |
| 7702 | for (var pos = 0;;) { |
| 7703 | var found = line.text.indexOf(val, pos); |
| 7704 | if (found == -1) { break } |
| 7705 | pos = found + val.length; |
| 7706 | newBreaks.push(Pos(lineNo, found)); |
| 7707 | } |
| 7708 | lineNo++; |
| 7709 | }); |
| 7710 | for (var i = newBreaks.length - 1; i >= 0; i--) |
| 7711 | { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); } |
| 7712 | }); |
| 7713 | option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, function (cm, val, old) { |
| 7714 | cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); |
| 7715 | if (old != Init) { cm.refresh(); } |
| 7716 | }); |
| 7717 | option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true); |
| 7718 | option("electricChars", true); |
| 7719 | option("inputStyle", mobile ? "contenteditable" : "textarea", function () { |
| 7720 | throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME |
| 7721 | }, true); |
| 7722 | option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true); |
| 7723 | option("autocorrect", false, function (cm, val) { return cm.getInputField().autocorrect = val; }, true); |
no test coverage detected