MCPcopy
hub / github.com/csev/py4e / CodeMirror

Function CodeMirror

tools/pythonauto/static/codemirrorepl/codemirror.js:61–112  ·  view source on GitHub ↗
(place, options)

Source from the content-addressed store, hash-verified

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

Callers 1

codemirror.jsFile · 0.70

Calls 11

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

Tested by

no test coverage detected