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

Function visibleLines

tools/pythonauto/static/codemirrorepl/codemirror.js:454–472  ·  view source on GitHub ↗
(display, doc, viewPort)

Source from the content-addressed store, hash-verified

452 // the the current scroll position). viewPort may contain top,
453 // height, and ensure (see op.scrollToPos) properties.
454 function visibleLines(display, doc, viewPort) {
455 var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop;
456 top = Math.floor(top - paddingTop(display));
457 var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight;
458
459 var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
460 // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
461 // forces those lines into the viewport (if possible).
462 if (viewPort && viewPort.ensure) {
463 var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line;
464 if (ensureFrom < from)
465 return {from: ensureFrom,
466 to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)};
467 if (Math.min(ensureTo, doc.lastLine()) >= to)
468 return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight),
469 to: ensureTo};
470 }
471 return {from: from, to: to};
472 }
473
474 // LINE NUMBERS
475

Callers 2

updateDisplayFunction · 0.70
extendFunction · 0.70

Calls 4

paddingTopFunction · 0.70
lineAtHeightFunction · 0.70
heightAtLineFunction · 0.70
getLineFunction · 0.70

Tested by

no test coverage detected