(CodeMirror)
| 8147 | // convenience. |
| 8148 | |
| 8149 | var addEditorMethods = function(CodeMirror) { |
| 8150 | var optionHandlers = CodeMirror.optionHandlers; |
| 8151 | |
| 8152 | var helpers = CodeMirror.helpers = {}; |
| 8153 | |
| 8154 | CodeMirror.prototype = { |
| 8155 | constructor: CodeMirror, |
| 8156 | focus: function(){window.focus(); this.display.input.focus();}, |
| 8157 | |
| 8158 | setOption: function(option, value) { |
| 8159 | var options = this.options, old = options[option]; |
| 8160 | if (options[option] == value && option != "mode") { return } |
| 8161 | options[option] = value; |
| 8162 | if (optionHandlers.hasOwnProperty(option)) |
| 8163 | { operation(this, optionHandlers[option])(this, value, old); } |
| 8164 | signal(this, "optionChange", this, option); |
| 8165 | }, |
| 8166 | |
| 8167 | getOption: function(option) {return this.options[option]}, |
| 8168 | getDoc: function() {return this.doc}, |
| 8169 | |
| 8170 | addKeyMap: function(map$$1, bottom) { |
| 8171 | this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1)); |
| 8172 | }, |
| 8173 | removeKeyMap: function(map$$1) { |
| 8174 | var maps = this.state.keyMaps; |
| 8175 | for (var i = 0; i < maps.length; ++i) |
| 8176 | { if (maps[i] == map$$1 || maps[i].name == map$$1) { |
| 8177 | maps.splice(i, 1); |
| 8178 | return true |
| 8179 | } } |
| 8180 | }, |
| 8181 | |
| 8182 | addOverlay: methodOp(function(spec, options) { |
| 8183 | var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); |
| 8184 | if (mode.startState) { throw new Error("Overlays may not be stateful.") } |
| 8185 | insertSorted(this.state.overlays, |
| 8186 | {mode: mode, modeSpec: spec, opaque: options && options.opaque, |
| 8187 | priority: (options && options.priority) || 0}, |
| 8188 | function (overlay) { return overlay.priority; }); |
| 8189 | this.state.modeGen++; |
| 8190 | regChange(this); |
| 8191 | }), |
| 8192 | removeOverlay: methodOp(function(spec) { |
| 8193 | var this$1 = this; |
| 8194 | |
| 8195 | var overlays = this.state.overlays; |
| 8196 | for (var i = 0; i < overlays.length; ++i) { |
| 8197 | var cur = overlays[i].modeSpec; |
| 8198 | if (cur == spec || typeof spec == "string" && cur.name == spec) { |
| 8199 | overlays.splice(i, 1); |
| 8200 | this$1.state.modeGen++; |
| 8201 | regChange(this$1); |
| 8202 | return |
| 8203 | } |
| 8204 | } |
| 8205 | }), |
| 8206 |
no test coverage detected