MCPcopy
hub / github.com/witheve/Eve / CodeMirror

Function CodeMirror

src/codemirror.js:62–129  ·  view source on GitHub ↗
(place, options)

Source from the content-addressed store, hash-verified

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

Callers 2

codemirror.jsFile · 0.85
constructorMethod · 0.85

Calls 15

copyObjFunction · 0.85
setGuttersForLineNumbersFunction · 0.85
updateGuttersFunction · 0.85
themeChangedFunction · 0.85
initScrollbarsFunction · 0.85
registerEventHandlersFunction · 0.85
ensureGlobalHandlersFunction · 0.85
startOperationFunction · 0.85
attachDocFunction · 0.85
bindFunction · 0.85
onBlurFunction · 0.85

Tested by

no test coverage detected