MCPcopy Create free account
hub / github.com/TruthHun/BookStack / cursorCoords

Function cursorCoords

static/mergely/lib/codemirror.js:2829–2857  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure, varHeight)

Source from the content-addressed store, hash-verified

2827 // 'other' property containing the position of the secondary cursor
2828 // on a bidi boundary.
2829 function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
2830 lineObj = lineObj || getLine(cm.doc, pos.line);
2831 if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
2832 function get(ch, right) {
2833 var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
2834 if (right) m.left = m.right; else m.right = m.left;
2835 return intoCoordSystem(cm, lineObj, m, context);
2836 }
2837 function getBidi(ch, partPos) {
2838 var part = order[partPos], right = part.level % 2;
2839 if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
2840 part = order[--partPos];
2841 ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
2842 right = true;
2843 } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
2844 part = order[++partPos];
2845 ch = bidiLeft(part) - part.level % 2;
2846 right = false;
2847 }
2848 if (right && ch == part.to && ch > part.from) return get(ch - 1);
2849 return get(ch, right);
2850 }
2851 var order = getOrder(lineObj), ch = pos.ch;
2852 if (!order) return get(ch);
2853 var partPos = getBidiPartAt(order, ch);
2854 var val = getBidi(ch, partPos);
2855 if (bidiOther != null) val.other = getBidi(ch, bidiOther);
2856 return val;
2857 }
2858
2859 // Used to cheaply estimate the coordinates for a position. Used for
2860 // intermediate scroll updates.

Callers 4

codemirror.jsFile · 0.70
drawSelectionCursorFunction · 0.70
getXFunction · 0.70
scrollPosIntoViewFunction · 0.70

Calls 6

getLineFunction · 0.70
prepareMeasureForLineFunction · 0.70
getOrderFunction · 0.70
getFunction · 0.70
getBidiPartAtFunction · 0.70
getBidiFunction · 0.70

Tested by

no test coverage detected