MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / addEditorMethods

Function addEditorMethods

static/libs/codemirror.js:8149–8581  ·  view source on GitHub ↗
(CodeMirror)

Source from the content-addressed store, hash-verified

8147// convenience.
8148
8149var 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

Callers 1

codemirror.jsFile · 0.85

Calls 15

operationFunction · 0.85
signalFunction · 0.85
getKeyMapFunction · 0.85
methodOpFunction · 0.85
insertSortedFunction · 0.85
regChangeFunction · 0.85
isLineFunction · 0.85
indentLineFunction · 0.85
replaceOneSelectionFunction · 0.85
ensureCursorVisibleFunction · 0.85
takeTokenFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected