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

Function patchDisplay

tools/pythonauto/static/codemirrorepl/codemirror.js:710–750  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

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

Callers 1

updateDisplayInnerFunction · 0.70

Calls 8

updateLineForChangesFunction · 0.85
buildLineElementFunction · 0.70
rmFunction · 0.70
indexOfFunction · 0.70
removeChildrenFunction · 0.70
lineNumberForFunction · 0.70
insertBeforeMethod · 0.45
appendChildMethod · 0.45

Tested by

no test coverage detected