MCPcopy Index your code
hub / github.com/csev/py4e / CodeMirror

Function CodeMirror

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

Source from the content-addressed store, hash-verified

47 // CONSTRUCTOR
48
49 function CodeMirror(place, options) {
50 if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
51
52 this.options = options = options || {};
53 // Determine effective options based on given values and defaults.
54 for (var opt in defaults) if (!options.hasOwnProperty(opt) && defaults.hasOwnProperty(opt))
55 options[opt] = defaults[opt];
56 setGuttersForLineNumbers(options);
57
58 var docStart = typeof options.value == "string" ? 0 : options.value.first;
59 var display = this.display = makeDisplay(place, docStart);
60 display.wrapper.CodeMirror = this;
61 updateGutters(this);
62 if (options.autofocus && !mobile) focusInput(this);
63
64 this.state = {keyMaps: [],
65 overlays: [],
66 modeGen: 0,
67 overwrite: false, focused: false,
68 suppressEdits: false,
69 pasteIncoming: false, cutIncoming: false,
70 draggingText: false,
71 highlight: new Delayed()};
72
73 themeChanged(this);
74 if (options.lineWrapping)
75 this.display.wrapper.className += " CodeMirror-wrap";
76
77 var doc = options.value;
78 if (typeof doc == "string") doc = new Doc(options.value, options.mode);
79 operation(this, attachDoc)(this, doc);
80
81 // Override magic textarea content restore that IE sometimes does
82 // on our hidden textarea on reload
83 if (old_ie) setTimeout(bind(resetInput, this, true), 20);
84
85 registerEventHandlers(this);
86 // IE throws unspecified error in certain cases, when
87 // trying to access activeElement before onload
88 var hasFocus; try { hasFocus = (document.activeElement == display.input); } catch(e) { }
89 if (hasFocus || (options.autofocus && !mobile)) setTimeout(bind(onFocus, this), 20);
90 else onBlur(this);
91
92 operation(this, function() {
93 for (var opt in optionHandlers)
94 if (optionHandlers.propertyIsEnumerable(opt))
95 optionHandlers[opt](this, options[opt], Init);
96 for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
97 })();
98 }
99
100 // DISPLAY CONSTRUCTOR
101

Callers 1

codemirror.jsFile · 0.70

Calls 9

makeDisplayFunction · 0.85
setGuttersForLineNumbersFunction · 0.70
updateGuttersFunction · 0.70
focusInputFunction · 0.70
themeChangedFunction · 0.70
operationFunction · 0.70
bindFunction · 0.70
registerEventHandlersFunction · 0.70
onBlurFunction · 0.70

Tested by

no test coverage detected