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

Function cursorCoords

static/editor.md/lib/codemirror/lib/codemirror.js:2723–2751  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure, varHeight)

Source from the content-addressed store, hash-verified

2721 // 'other' property containing the position of the secondary cursor
2722 // on a bidi boundary.
2723 function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
2724 lineObj = lineObj || getLine(cm.doc, pos.line);
2725 if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
2726 function get(ch, right) {
2727 var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
2728 if (right) m.left = m.right; else m.right = m.left;
2729 return intoCoordSystem(cm, lineObj, m, context);
2730 }
2731 function getBidi(ch, partPos) {
2732 var part = order[partPos], right = part.level % 2;
2733 if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
2734 part = order[--partPos];
2735 ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
2736 right = true;
2737 } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
2738 part = order[++partPos];
2739 ch = bidiLeft(part) - part.level % 2;
2740 right = false;
2741 }
2742 if (right && ch == part.to && ch > part.from) return get(ch - 1);
2743 return get(ch, right);
2744 }
2745 var order = getOrder(lineObj), ch = pos.ch;
2746 if (!order) return get(ch);
2747 var partPos = getBidiPartAt(order, ch);
2748 var val = getBidi(ch, partPos);
2749 if (bidiOther != null) val.other = getBidi(ch, bidiOther);
2750 return val;
2751 }
2752
2753 // Used to cheaply estimate the coordinates for a position. Used for
2754 // 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