MCPcopy Create free account
hub / github.com/breck7/scroll / cursorCoords

Function cursorCoords

external/.scrollLibs.js:3997–4037  ·  view source on GitHub ↗
(cm, pos, context, lineObj, preparedMeasure, varHeight)

Source from the content-addressed store, hash-verified

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.

Callers 6

coordsCharInnerFunction · 0.85
coordsBidiPartFunction · 0.85
drawSelectionCursorFunction · 0.85
scrollPosIntoViewFunction · 0.85
addEditorMethodsFunction · 0.85
.scrollLibs.jsFile · 0.85

Calls 6

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

Tested by

no test coverage detected