MCPcopy Create free account
hub / github.com/sql-js/sql.js / updateSelection

Function updateSelection

GUI/codemirror/lib/codemirror.js:1240–1268  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

1238
1239 // Redraw the selection and/or cursor
1240 function updateSelection(cm) {
1241 var display = cm.display, doc = cm.doc;
1242 var curFragment = document.createDocumentFragment();
1243 var selFragment = document.createDocumentFragment();
1244
1245 for (var i = 0; i < doc.sel.ranges.length; i++) {
1246 var range = doc.sel.ranges[i];
1247 var collapsed = range.empty();
1248 if (collapsed || cm.options.showCursorWhenSelecting)
1249 drawSelectionCursor(cm, range, curFragment);
1250 if (!collapsed)
1251 drawSelectionRange(cm, range, selFragment);
1252 }
1253
1254 // Move the hidden textarea near the cursor to prevent scrolling artifacts
1255 if (cm.options.moveInputWithCursor) {
1256 var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
1257 var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
1258 var top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
1259 headPos.top + lineOff.top - wrapOff.top));
1260 var left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
1261 headPos.left + lineOff.left - wrapOff.left));
1262 display.inputDiv.style.top = top + "px";
1263 display.inputDiv.style.left = left + "px";
1264 }
1265
1266 removeChildrenAndAdd(display.cursorDiv, curFragment);
1267 removeChildrenAndAdd(display.selectionDiv, selFragment);
1268 }
1269
1270 // Draws a cursor for the given range
1271 function drawSelectionCursor(cm, range, output) {

Callers 2

updateDisplayFunction · 0.85
endOperationFunction · 0.85

Calls 4

drawSelectionCursorFunction · 0.85
drawSelectionRangeFunction · 0.85
cursorCoordsFunction · 0.85
removeChildrenAndAddFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…