MCPcopy Create free account
hub / github.com/sql-js/sql.js / patchDisplay

Function patchDisplay

GUI/codemirror/lib/codemirror.js:725–765  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

723 // that are not there yet, and updating the ones that are out of
724 // date.
725 function patchDisplay(cm, updateNumbersFrom, dims) {
726 var display = cm.display, lineNumbers = cm.options.lineNumbers;
727 var container = display.lineDiv, cur = container.firstChild;
728
729 function rm(node) {
730 var next = node.nextSibling;
731 // Works around a throw-scroll bug in OS X Webkit
732 if (webkit && mac && cm.display.currentWheelTarget == node)
733 node.style.display = "none";
734 else
735 node.parentNode.removeChild(node);
736 return next;
737 }
738
739 var view = display.view, lineN = display.viewFrom;
740 // Loop over the elements in the view, syncing cur (the DOM nodes
741 // in display.lineDiv) with the view as we go.
742 for (var i = 0; i < view.length; i++) {
743 var lineView = view[i];
744 if (lineView.hidden) {
745 } else if (!lineView.node) { // Not drawn yet
746 var node = buildLineElement(cm, lineView, lineN, dims);
747 container.insertBefore(node, cur);
748 } else { // Already drawn
749 while (cur != lineView.node) cur = rm(cur);
750 var updateNumber = lineNumbers && updateNumbersFrom != null &&
751 updateNumbersFrom <= lineN && lineView.lineNumber;
752 if (lineView.changes) {
753 if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
754 updateLineForChanges(cm, lineView, lineN, dims);
755 }
756 if (updateNumber) {
757 removeChildren(lineView.lineNumber);
758 lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
759 }
760 cur = lineView.node.nextSibling;
761 }
762 lineN += lineView.size;
763 }
764 while (cur) cur = rm(cur);
765 }
766
767 // When an aspect of a line changes, a string is added to
768 // lineView.changes. This updates the relevant part of the line's

Callers 1

updateDisplayInnerFunction · 0.85

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…