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

Function ensureLineHeights

tools/pythonauto/static/codemirrorepl/codemirror.js:1453–1469  ·  view source on GitHub ↗
(cm, lineView, rect)

Source from the content-addressed store, hash-verified

1451 // line. When lineWrapping is on, there might be more than one
1452 // height.
1453 function ensureLineHeights(cm, lineView, rect) {
1454 var wrapping = cm.options.lineWrapping;
1455 var curWidth = wrapping && cm.display.scroller.clientWidth;
1456 if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
1457 var heights = lineView.measure.heights = [];
1458 if (wrapping) {
1459 lineView.measure.width = curWidth;
1460 var rects = lineView.text.firstChild.getClientRects();
1461 for (var i = 0; i < rects.length - 1; i++) {
1462 var cur = rects[i], next = rects[i + 1];
1463 if (Math.abs(cur.bottom - next.bottom) > 2)
1464 heights.push((cur.bottom + next.top) / 2 - rect.top);
1465 }
1466 }
1467 heights.push(rect.bottom - rect.top);
1468 }
1469 }
1470
1471 // Find a line map (mapping character offsets to text nodes) and a
1472 // measurement cache for the given line number. (A line view might

Callers 1

measureCharPreparedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected