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

Function coordsChar

tools/pythonauto/static/codemirrorepl/codemirror.js:1769–1788  ·  view source on GitHub ↗
(cm, x, y)

Source from the content-addressed store, hash-verified

1767 // Compute the character position closest to the given coordinates.
1768 // Input must be lineSpace-local ("div" coordinate system).
1769 function coordsChar(cm, x, y) {
1770 var doc = cm.doc;
1771 y += cm.display.viewOffset;
1772 if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
1773 var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
1774 if (lineN > last)
1775 return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
1776 if (x < 0) x = 0;
1777
1778 var lineObj = getLine(doc, lineN);
1779 for (;;) {
1780 var found = coordsCharInner(cm, lineObj, lineN, x, y);
1781 var merged = collapsedSpanAtEnd(lineObj);
1782 var mergedPos = merged && merged.find(0, true);
1783 if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
1784 lineN = lineNo(lineObj = mergedPos.to.line);
1785 else
1786 return found;
1787 }
1788 }
1789
1790 function coordsCharInner(cm, lineObj, lineNo, x, y) {
1791 var innerOff = y - heightAtLine(lineObj);

Callers 3

posFromMouseFunction · 0.70
findPosVFunction · 0.70
codemirror.jsFile · 0.70

Calls 7

PosWithInfoFunction · 0.70
lineAtHeightFunction · 0.70
getLineFunction · 0.70
coordsCharInnerFunction · 0.70
collapsedSpanAtEndFunction · 0.70
lineNoFunction · 0.70
findMethod · 0.45

Tested by

no test coverage detected