(cm, pos, context, lineObj, preparedMeasure, varHeight)
| 2646 | // Every position after the last character on a line is considered to stick |
| 2647 | // to the last character on the line. |
| 2648 | function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { |
| 2649 | lineObj = lineObj || getLine(cm.doc, pos.line); |
| 2650 | if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); } |
| 2651 | function get(ch, right) { |
| 2652 | var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); |
| 2653 | if (right) { m.left = m.right; } else { m.right = m.left; } |
| 2654 | return intoCoordSystem(cm, lineObj, m, context) |
| 2655 | } |
| 2656 | var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky; |
| 2657 | if (ch >= lineObj.text.length) { |
| 2658 | ch = lineObj.text.length; |
| 2659 | sticky = "before"; |
| 2660 | } else if (ch <= 0) { |
| 2661 | ch = 0; |
| 2662 | sticky = "after"; |
| 2663 | } |
| 2664 | if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") } |
| 2665 | |
| 2666 | function getBidi(ch, partPos, invert) { |
| 2667 | var part = order[partPos], right = part.level == 1; |
| 2668 | return get(invert ? ch - 1 : ch, right != invert) |
| 2669 | } |
| 2670 | var partPos = getBidiPartAt(order, ch, sticky); |
| 2671 | var other = bidiOther; |
| 2672 | var val = getBidi(ch, partPos, sticky == "before"); |
| 2673 | if (other != null) { val.other = getBidi(ch, other, sticky != "before"); } |
| 2674 | return val |
| 2675 | } |
| 2676 | |
| 2677 | // Used to cheaply estimate the coordinates for a position. Used for |
| 2678 | // intermediate scroll updates. |
no test coverage detected