MCPcopy
hub / github.com/csev/py4e / cursorCoords

Function cursorCoords

tools/pythonauto/static/codemirrorepl/codemirror.js:1714–1742  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure)

Source from the content-addressed store, hash-verified

1712 // 'other' property containing the position of the secondary cursor
1713 // on a bidi boundary.
1714 function cursorCoords(cm, pos, context, lineObj, preparedMeasure) {
1715 lineObj = lineObj || getLine(cm.doc, pos.line);
1716 if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
1717 function get(ch, right) {
1718 var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left");
1719 if (right) m.left = m.right; else m.right = m.left;
1720 return intoCoordSystem(cm, lineObj, m, context);
1721 }
1722 function getBidi(ch, partPos) {
1723 var part = order[partPos], right = part.level % 2;
1724 if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
1725 part = order[--partPos];
1726 ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
1727 right = true;
1728 } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
1729 part = order[++partPos];
1730 ch = bidiLeft(part) - part.level % 2;
1731 right = false;
1732 }
1733 if (right && ch == part.to && ch > part.from) return get(ch - 1);
1734 return get(ch, right);
1735 }
1736 var order = getOrder(lineObj), ch = pos.ch;
1737 if (!order) return get(ch);
1738 var partPos = getBidiPartAt(order, ch);
1739 var val = getBidi(ch, partPos);
1740 if (bidiOther != null) val.other = getBidi(ch, bidiOther);
1741 return val;
1742 }
1743
1744 // Used to cheaply estimate the coordinates for a position. Used for
1745 // intermediate scroll updates.

Callers 5

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

Calls 6

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

Tested by

no test coverage detected