MCPcopy
hub / github.com/DHTMLX/gantt / coordsChar

Function coordsChar

samples/common/codehighlight/codemirror.js:2703–2721  ·  view source on GitHub ↗
(cm, x, y)

Source from the content-addressed store, hash-verified

2701 // Compute the character position closest to the given coordinates.
2702 // Input must be lineSpace-local ("div" coordinate system).
2703 function coordsChar(cm, x, y) {
2704 var doc = cm.doc;
2705 y += cm.display.viewOffset;
2706 if (y < 0) { return PosWithInfo(doc.first, 0, null, -1, -1) }
2707 var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
2708 if (lineN > last)
2709 { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, 1, 1) }
2710 if (x < 0) { x = 0; }
2711
2712 var lineObj = getLine(doc, lineN);
2713 for (;;) {
2714 var found = coordsCharInner(cm, lineObj, lineN, x, y);
2715 var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 || found.outside > 0 ? 1 : 0));
2716 if (!collapsed) { return found }
2717 var rangeEnd = collapsed.find(1);
2718 if (rangeEnd.line == lineN) { return rangeEnd }
2719 lineObj = getLine(doc, lineN = rangeEnd.line);
2720 }
2721 }
2722
2723 function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
2724 y -= widgetTopHeight(lineObj);

Callers 3

posFromMouseFunction · 0.85
addEditorMethodsFunction · 0.85
findPosVFunction · 0.85

Calls 5

PosWithInfoFunction · 0.85
lineAtHeightFunction · 0.85
getLineFunction · 0.85
coordsCharInnerFunction · 0.85
collapsedSpanAroundFunction · 0.85

Tested by

no test coverage detected