MCPcopy
hub / github.com/tilemill-project/tilemill / cursorCoords

Function cursorCoords

assets/js/codemirror.js:2831–2859  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure, varHeight)

Source from the content-addressed store, hash-verified

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

Callers 4

codemirror.jsFile · 0.85
drawSelectionCursorFunction · 0.85
getXFunction · 0.85
scrollPosIntoViewFunction · 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