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

Function cursorCoords

samples/common/codehighlight/codemirror.js:2648–2675  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure, varHeight)

Source from the content-addressed store, hash-verified

2646 // Every position after the last character on a line is considered to stick
2647 // to the last character on the line.
2648 function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
2649 lineObj = lineObj || getLine(cm.doc, pos.line);
2650 if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
2651 function get(ch, right) {
2652 var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
2653 if (right) { m.left = m.right; } else { m.right = m.left; }
2654 return intoCoordSystem(cm, lineObj, m, context)
2655 }
2656 var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
2657 if (ch >= lineObj.text.length) {
2658 ch = lineObj.text.length;
2659 sticky = "before";
2660 } else if (ch <= 0) {
2661 ch = 0;
2662 sticky = "after";
2663 }
2664 if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
2665
2666 function getBidi(ch, partPos, invert) {
2667 var part = order[partPos], right = part.level == 1;
2668 return get(invert ? ch - 1 : ch, right != invert)
2669 }
2670 var partPos = getBidiPartAt(order, ch, sticky);
2671 var other = bidiOther;
2672 var val = getBidi(ch, partPos, sticky == "before");
2673 if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
2674 return val
2675 }
2676
2677 // Used to cheaply estimate the coordinates for a position. Used for
2678 // intermediate scroll updates.

Callers 6

coordsCharInnerFunction · 0.85
coordsBidiPartFunction · 0.85
drawSelectionCursorFunction · 0.85
scrollPosIntoViewFunction · 0.85
addEditorMethodsFunction · 0.85
codemirror.jsFile · 0.85

Calls 6

getLineFunction · 0.85
prepareMeasureForLineFunction · 0.85
getOrderFunction · 0.85
getFunction · 0.85
getBidiPartAtFunction · 0.85
getBidiFunction · 0.85

Tested by

no test coverage detected