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

Function lineAtHeight

tools/pythonauto/static/codemirrorepl/codemirror.js:6484–6501  ·  view source on GitHub ↗
(chunk, h)

Source from the content-addressed store, hash-verified

6482 // Find the line at the given vertical position, using the height
6483 // information in the document tree.
6484 function lineAtHeight(chunk, h) {
6485 var n = chunk.first;
6486 outer: do {
6487 for (var i = 0; i < chunk.children.length; ++i) {
6488 var child = chunk.children[i], ch = child.height;
6489 if (h < ch) { chunk = child; continue outer; }
6490 h -= ch;
6491 n += child.chunkSize();
6492 }
6493 return n;
6494 } while (!chunk.lines);
6495 for (var i = 0; i < chunk.lines.length; ++i) {
6496 var line = chunk.lines[i], lh = line.height;
6497 if (h < lh) break;
6498 h -= lh;
6499 }
6500 return n + i;
6501 }
6502
6503
6504 // Find the height above the given line.

Callers 4

visibleLinesFunction · 0.70
coordsCharFunction · 0.70
gutterEventFunction · 0.70
codemirror.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected