MCPcopy Index your code
hub / github.com/csev/py4e / measureChar

Function measureChar

tools/pythonauto/static/codemirror/codemirror.js:997–1017  ·  view source on GitHub ↗
(cm, line, ch, data, bias)

Source from the content-addressed store, hash-verified

995 }
996
997 function measureChar(cm, line, ch, data, bias) {
998 var dir = -1;
999 data = data || measureLine(cm, line);
1000 if (data.crude) {
1001 var left = data.left + ch * data.width;
1002 return {left: left, right: left + data.width, top: data.top, bottom: data.bottom};
1003 }
1004
1005 for (var pos = ch;; pos += dir) {
1006 var r = data[pos];
1007 if (r) break;
1008 if (dir < 0 && pos == 0) dir = 1;
1009 }
1010 bias = pos > ch ? "left" : pos < ch ? "right" : bias;
1011 if (bias == "left" && r.leftSide) r = r.leftSide;
1012 else if (bias == "right" && r.rightSide) r = r.rightSide;
1013 return {left: pos < ch ? r.right : r.left,
1014 right: pos > ch ? r.left : r.right,
1015 top: r.top,
1016 bottom: r.bottom};
1017 }
1018
1019 function findCachedMeasurement(cm, line) {
1020 var cache = cm.display.measureLineCache;

Callers 4

crudelyMeasureLineFunction · 0.70
measureLineWidthFunction · 0.70
charCoordsFunction · 0.70
getFunction · 0.70

Calls 1

measureLineFunction · 0.70

Tested by

no test coverage detected