MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / drawSelectionCursor

Function drawSelectionCursor

lib/web/CodeMirror/src/display/selection.js:32–48  ·  view source on GitHub ↗
(cm, head, output)

Source from the content-addressed store, hash-verified

30
31// Draws a cursor for the given range
32export function drawSelectionCursor(cm, head, output) {
33 let pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine)
34
35 let cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"))
36 cursor.style.left = pos.left + "px"
37 cursor.style.top = pos.top + "px"
38 cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"
39
40 if (pos.other) {
41 // Secondary cursor, shown when on a 'jump' in bi-directional text
42 let otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"))
43 otherCursor.style.display = ""
44 otherCursor.style.left = pos.other.left + "px"
45 otherCursor.style.top = pos.other.top + "px"
46 otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"
47 }
48}
49
50function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
51

Callers 2

onDragOverFunction · 0.90
prepareSelectionFunction · 0.70

Calls 3

cursorCoordsFunction · 0.90
eltFunction · 0.90
maxMethod · 0.45

Tested by

no test coverage detected