(cm, pos, context, lineObj, preparedMeasure, varHeight)
| 3995 | // Every position after the last character on a line is considered to stick |
| 3996 | // to the last character on the line. |
| 3997 | function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { |
| 3998 | lineObj = lineObj || getLine(cm.doc, pos.line) |
| 3999 | if (!preparedMeasure) { |
| 4000 | preparedMeasure = prepareMeasureForLine(cm, lineObj) |
| 4001 | } |
| 4002 | function get(ch, right) { |
| 4003 | var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight) |
| 4004 | if (right) { |
| 4005 | m.left = m.right |
| 4006 | } else { |
| 4007 | m.right = m.left |
| 4008 | } |
| 4009 | return intoCoordSystem(cm, lineObj, m, context) |
| 4010 | } |
| 4011 | var order = getOrder(lineObj, cm.doc.direction), |
| 4012 | ch = pos.ch, |
| 4013 | sticky = pos.sticky |
| 4014 | if (ch >= lineObj.text.length) { |
| 4015 | ch = lineObj.text.length |
| 4016 | sticky = "before" |
| 4017 | } else if (ch <= 0) { |
| 4018 | ch = 0 |
| 4019 | sticky = "after" |
| 4020 | } |
| 4021 | if (!order) { |
| 4022 | return get(sticky == "before" ? ch - 1 : ch, sticky == "before") |
| 4023 | } |
| 4024 | |
| 4025 | function getBidi(ch, partPos, invert) { |
| 4026 | var part = order[partPos], |
| 4027 | right = part.level == 1 |
| 4028 | return get(invert ? ch - 1 : ch, right != invert) |
| 4029 | } |
| 4030 | var partPos = getBidiPartAt(order, ch, sticky) |
| 4031 | var other = bidiOther |
| 4032 | var val = getBidi(ch, partPos, sticky == "before") |
| 4033 | if (other != null) { |
| 4034 | val.other = getBidi(ch, other, sticky != "before") |
| 4035 | } |
| 4036 | return val |
| 4037 | } |
| 4038 | |
| 4039 | // Used to cheaply estimate the coordinates for a position. Used for |
| 4040 | // intermediate scroll updates. |
no test coverage detected