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

Function patchDisplay

src/codemirror.js:851–891  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

849 // that are not there yet, and updating the ones that are out of
850 // date.
851 function patchDisplay(cm, updateNumbersFrom, dims) {
852 var display = cm.display, lineNumbers = cm.options.lineNumbers;
853 var container = display.lineDiv, cur = container.firstChild;
854
855 function rm(node) {
856 var next = node.nextSibling;
857 // Works around a throw-scroll bug in OS X Webkit
858 if (webkit && mac && cm.display.currentWheelTarget == node)
859 node.style.display = "none";
860 else
861 node.parentNode.removeChild(node);
862 return next;
863 }
864
865 var view = display.view, lineN = display.viewFrom;
866 // Loop over the elements in the view, syncing cur (the DOM nodes
867 // in display.lineDiv) with the view as we go.
868 for (var i = 0; i < view.length; i++) {
869 var lineView = view[i];
870 if (lineView.hidden) {
871 } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
872 var node = buildLineElement(cm, lineView, lineN, dims);
873 container.insertBefore(node, cur);
874 } else { // Already drawn
875 while (cur != lineView.node) cur = rm(cur);
876 var updateNumber = lineNumbers && updateNumbersFrom != null &&
877 updateNumbersFrom <= lineN && lineView.lineNumber;
878 if (lineView.changes) {
879 if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
880 updateLineForChanges(cm, lineView, lineN, dims);
881 }
882 if (updateNumber) {
883 removeChildren(lineView.lineNumber);
884 lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
885 }
886 cur = lineView.node.nextSibling;
887 }
888 lineN += lineView.size;
889 }
890 while (cur) cur = rm(cur);
891 }
892
893 // When an aspect of a line changes, a string is added to
894 // lineView.changes. This updates the relevant part of the line's

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 6

buildLineElementFunction · 0.85
rmFunction · 0.85
indexOfFunction · 0.85
updateLineForChangesFunction · 0.85
removeChildrenFunction · 0.85
lineNumberForFunction · 0.85

Tested by

no test coverage detected