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

Function Display

tools/pythonauto/static/codemirrorepl/codemirror.js:120–234  ·  view source on GitHub ↗
(place, doc)

Source from the content-addressed store, hash-verified

118 // display-related state.
119
120 function Display(place, doc) {
121 var d = this;
122
123 // The semihidden textarea that is focused when the editor is
124 // focused, and receives input.
125 var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
126 // The textarea is kept positioned near the cursor to prevent the
127 // fact that it'll be scrolled into view on input from scrolling
128 // our fake cursor out of view. On webkit, when wrap=off, paste is
129 // very slow. So make the area wide instead.
130 if (webkit) input.style.width = "1000px";
131 else input.setAttribute("wrap", "off");
132 // If border: 0; -- iOS fails to open keyboard (issue #1287)
133 if (ios) input.style.border = "1px solid black";
134 input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off"); input.setAttribute("spellcheck", "false");
135
136 // Wraps and hides input textarea
137 d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
138 // The fake scrollbar elements.
139 d.scrollbarH = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
140 d.scrollbarV = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
141 // Covers bottom-right square when both scrollbars are present.
142 d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
143 // Covers bottom of gutter when coverGutterNextToScrollbar is on
144 // and h scrollbar is present.
145 d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
146 // Will contain the actual code, positioned to cover the viewport.
147 d.lineDiv = elt("div", null, "CodeMirror-code");
148 // Elements are added to these to represent selection and cursors.
149 d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
150 d.cursorDiv = elt("div", null, "CodeMirror-cursors");
151 // A visibility: hidden element used to find the size of things.
152 d.measure = elt("div", null, "CodeMirror-measure");
153 // When lines outside of the viewport are measured, they are drawn in this.
154 d.lineMeasure = elt("div", null, "CodeMirror-measure");
155 // Wraps everything that needs to exist inside the vertically-padded coordinate system
156 d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
157 null, "position: relative; outline: none");
158 // Moved around its parent to cover visible view.
159 d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
160 // Set to the height of the document, allowing scrolling.
161 d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
162 // Behavior of elts with overflow: auto and padding is
163 // inconsistent across browsers. This is used to ensure the
164 // scrollable area is big enough.
165 d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerCutOff + "px; width: 1px;");
166 // Will contain the gutters, if any.
167 d.gutters = elt("div", null, "CodeMirror-gutters");
168 d.lineGutter = null;
169 // Actual scrollable element.
170 d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
171 d.scroller.setAttribute("tabIndex", "-1");
172 // The element in which the editor lives.
173 d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
174 d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
175
176 // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
177 if (ie_upto7) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }

Callers

nothing calls this directly

Calls 3

eltFunction · 0.70
placeFunction · 0.50
appendChildMethod · 0.45

Tested by

no test coverage detected