MCPcopy Index your code
hub / github.com/nwutils/nw-sample-apps / updateGutter

Function updateGutter

mini-code-edit/cm/lib/codemirror.js:1087–1123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1085 }
1086
1087 function updateGutter() {
1088 if (!options.gutter && !options.lineNumbers) return;
1089 var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
1090 gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
1091 var html = [], i = showingFrom, normalNode;
1092 doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
1093 if (line.hidden) {
1094 html.push("<pre></pre>");
1095 } else {
1096 var marker = line.gutterMarker;
1097 var text = options.lineNumbers ? i + options.firstLineNumber : null;
1098 if (marker && marker.text)
1099 text = marker.text.replace("%N%", text != null ? text : "");
1100 else if (text == null)
1101 text = "\u00a0";
1102 html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text);
1103 for (var j = 1; j < line.height; ++j) html.push("<br/>&#160;");
1104 html.push("</pre>");
1105 if (!marker) normalNode = i;
1106 }
1107 ++i;
1108 });
1109 gutter.style.display = "none";
1110 gutterText.innerHTML = html.join("");
1111 // Make sure scrolling doesn't cause number gutter size to pop
1112 if (normalNode != null) {
1113 var node = gutterText.childNodes[normalNode - showingFrom];
1114 var minwidth = String(doc.size).length, val = eltText(node), pad = "";
1115 while (val.length + pad.length < minwidth) pad += "\u00a0";
1116 if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild);
1117 }
1118 gutter.style.display = "";
1119 var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2;
1120 lineSpace.style.marginLeft = gutter.offsetWidth + "px";
1121 gutterDirty = false;
1122 return resized;
1123 }
1124 function updateSelection() {
1125 var collapsed = posEq(sel.from, sel.to);
1126 var fromPos = localCoords(sel.from, true);

Callers 2

updateDisplayFunction · 0.85
endOperationFunction · 0.85

Calls 1

eltTextFunction · 0.85

Tested by

no test coverage detected