(cm, pos, context, lineObj, preparedMeasure, varHeight)
| 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. |
no test coverage detected