()
| 1285 | } |
| 1286 | |
| 1287 | function updateGutter() { |
| 1288 | if (!options.gutter && !options.lineNumbers) return; |
| 1289 | var hText = mover.offsetHeight, hEditor = scroller.clientHeight; |
| 1290 | gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px"; |
| 1291 | var html = [], i = showingFrom, normalNode; |
| 1292 | doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) { |
| 1293 | if (line.hidden) { |
| 1294 | html.push("<pre></pre>"); |
| 1295 | } else { |
| 1296 | var marker = line.gutterMarker; |
| 1297 | var text = options.lineNumbers ? i + options.firstLineNumber : null; |
| 1298 | if (marker && marker.text) |
| 1299 | text = marker.text.replace("%N%", text != null ? text : ""); |
| 1300 | else if (text == null) |
| 1301 | text = "\u00a0"; |
| 1302 | html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text); |
| 1303 | for (var j = 1; j < line.height; ++j) html.push("<br/> "); |
| 1304 | html.push("</pre>"); |
| 1305 | if (!marker) normalNode = i; |
| 1306 | } |
| 1307 | ++i; |
| 1308 | }); |
| 1309 | gutter.style.display = "none"; |
| 1310 | gutterText.innerHTML = html.join(""); |
| 1311 | // Make sure scrolling doesn't cause number gutter size to pop |
| 1312 | if (normalNode != null) { |
| 1313 | var node = gutterText.childNodes[normalNode - showingFrom]; |
| 1314 | var minwidth = String(doc.size).length, val = eltText(node), pad = ""; |
| 1315 | while (val.length + pad.length < minwidth) pad += "\u00a0"; |
| 1316 | if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild); |
| 1317 | } |
| 1318 | gutter.style.display = ""; |
| 1319 | var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2; |
| 1320 | lineSpace.style.marginLeft = gutter.offsetWidth + "px"; |
| 1321 | gutterDirty = false; |
| 1322 | return resized; |
| 1323 | } |
| 1324 | function updateSelection() { |
| 1325 | var collapsed = posEq(sel.from, sel.to); |
| 1326 | var fromPos = localCoords(sel.from, true); |
no test coverage detected