MCPcopy Create free account
hub / github.com/sql-js/sql.js / CodeMirror

Function CodeMirror

GUI/codemirror/lib/codemirror.js:60–111  ·  view source on GitHub ↗
(place, options)

Source from the content-addressed store, hash-verified

58 // that user code is usually dealing with.
59
60 function CodeMirror(place, options) {
61 if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
62
63 this.options = options = options || {};
64 // Determine effective options based on given values and defaults.
65 copyObj(defaults, options, false);
66 setGuttersForLineNumbers(options);
67
68 var doc = options.value;
69 if (typeof doc == "string") doc = new Doc(doc, options.mode);
70 this.doc = doc;
71
72 var display = this.display = new Display(place, doc);
73 display.wrapper.CodeMirror = this;
74 updateGutters(this);
75 themeChanged(this);
76 if (options.lineWrapping)
77 this.display.wrapper.className += " CodeMirror-wrap";
78 if (options.autofocus && !mobile) focusInput(this);
79
80 this.state = {
81 keyMaps: [], // stores maps added by addKeyMap
82 overlays: [], // highlighting overlays, as added by addOverlay
83 modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
84 overwrite: false, focused: false,
85 suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
86 pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in readInput
87 draggingText: false,
88 highlight: new Delayed() // stores highlight worker timeout
89 };
90
91 // Override magic textarea content restore that IE sometimes does
92 // on our hidden textarea on reload
93 if (ie_upto10) setTimeout(bind(resetInput, this, true), 20);
94
95 registerEventHandlers(this);
96
97 var cm = this;
98 runInOp(this, function() {
99 cm.curOp.forceUpdate = true;
100 attachDoc(cm, doc);
101
102 if ((options.autofocus && !mobile) || activeElt() == display.input)
103 setTimeout(bind(onFocus, cm), 20);
104 else
105 onBlur(cm);
106
107 for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
108 optionHandlers[opt](cm, options[opt], Init);
109 for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);
110 });
111 }
112
113 // DISPLAY CONSTRUCTOR
114

Callers 1

codemirror.jsFile · 0.85

Calls 11

copyObjFunction · 0.85
setGuttersForLineNumbersFunction · 0.85
updateGuttersFunction · 0.85
themeChangedFunction · 0.85
focusInputFunction · 0.85
bindFunction · 0.85
registerEventHandlersFunction · 0.85
runInOpFunction · 0.85
attachDocFunction · 0.85
activeEltFunction · 0.85
onBlurFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…