MCPcopy
hub / github.com/tilemill-project/tilemill / visibleLines

Function visibleLines

assets/js/codemirror.js:563–582  ·  view source on GitHub ↗
(display, doc, viewport)

Source from the content-addressed store, hash-verified

561 // the the current scroll position). viewport may contain top,
562 // height, and ensure (see op.scrollToPos) properties.
563 function visibleLines(display, doc, viewport) {
564 var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
565 top = Math.floor(top - paddingTop(display));
566 var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
567
568 var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
569 // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
570 // forces those lines into the viewport (if possible).
571 if (viewport && viewport.ensure) {
572 var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
573 if (ensureFrom < from) {
574 from = ensureFrom;
575 to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
576 } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
577 from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
578 to = ensureTo;
579 }
580 }
581 return {from: from, to: Math.max(to, from + 1)};
582 }
583
584 // LINE NUMBERS
585

Callers 3

DisplayUpdateFunction · 0.85
postUpdateDisplayFunction · 0.85
extendFunction · 0.85

Calls 4

paddingTopFunction · 0.85
lineAtHeightFunction · 0.85
heightAtLineFunction · 0.85
getLineFunction · 0.85

Tested by

no test coverage detected