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

Function updateDisplay

tools/pythonauto/static/codemirrorepl/codemirror.js:533–573  ·  view source on GitHub ↗
(cm, viewPort, forced)

Source from the content-addressed store, hash-verified

531 // unless forced is true.
532 // Returns true if an actual update happened, false otherwise.
533 function updateDisplay(cm, viewPort, forced) {
534 var oldFrom = cm.display.viewFrom, oldTo = cm.display.viewTo, updated;
535 var visible = visibleLines(cm.display, cm.doc, viewPort);
536 for (var first = true;; first = false) {
537 var oldWidth = cm.display.scroller.clientWidth;
538 if (!updateDisplayInner(cm, visible, forced)) break;
539 updated = true;
540
541 // If the max line changed since it was last measured, measure it,
542 // and ensure the document's width matches it.
543 if (cm.display.maxLineChanged && !cm.options.lineWrapping)
544 adjustContentWidth(cm);
545
546 var barMeasure = measureForScrollbars(cm);
547 updateSelection(cm);
548 setDocumentHeight(cm, barMeasure);
549 updateScrollbars(cm, barMeasure);
550 if (first && cm.options.lineWrapping && oldWidth != cm.display.scroller.clientWidth) {
551 forced = true;
552 continue;
553 }
554 forced = false;
555
556 // Clip forced viewport to actual scrollable area.
557 if (viewPort && viewPort.top != null)
558 viewPort = {top: Math.min(barMeasure.docHeight - scrollerCutOff - barMeasure.clientHeight, viewPort.top)};
559 // Updated line heights might result in the drawn area not
560 // actually covering the viewport. Keep looping until it does.
561 visible = visibleLines(cm.display, cm.doc, viewPort);
562 if (visible.from >= cm.display.viewFrom && visible.to <= cm.display.viewTo)
563 break;
564 }
565
566 cm.display.updateLineNumbers = null;
567 if (updated) {
568 signalLater(cm, "update", cm);
569 if (cm.display.viewFrom != oldFrom || cm.display.viewTo != oldTo)
570 signalLater(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
571 }
572 return updated;
573 }
574
575 // Does the actual updating of the line display. Bails out
576 // (returning false) when there is nothing to be done and forced is

Callers 3

endOperationFunction · 0.70
setScrollTopFunction · 0.70
onScrollWheelFunction · 0.70

Calls 8

adjustContentWidthFunction · 0.85
measureForScrollbarsFunction · 0.85
setDocumentHeightFunction · 0.85
visibleLinesFunction · 0.70
updateDisplayInnerFunction · 0.70
updateSelectionFunction · 0.70
updateScrollbarsFunction · 0.70
signalLaterFunction · 0.70

Tested by

no test coverage detected