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

Function updateDisplay

GUI/codemirror/lib/codemirror.js:536–578  ·  view source on GitHub ↗
(cm, viewPort, forced)

Source from the content-addressed store, hash-verified

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

Callers 3

endOperationFunction · 0.85
setScrollTopFunction · 0.85
onScrollWheelFunction · 0.85

Calls 9

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…