MCPcopy
hub / github.com/csev/py4e / updateSelection

Function updateSelection

tools/pythonauto/static/codemirrorepl/codemirror.js:1225–1253  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

1223
1224 // Redraw the selection and/or cursor
1225 function updateSelection(cm) {
1226 var display = cm.display, doc = cm.doc;
1227 var curFragment = document.createDocumentFragment();
1228 var selFragment = document.createDocumentFragment();
1229
1230 for (var i = 0; i < doc.sel.ranges.length; i++) {
1231 var range = doc.sel.ranges[i];
1232 var collapsed = range.empty();
1233 if (collapsed || cm.options.showCursorWhenSelecting)
1234 drawSelectionCursor(cm, range, curFragment);
1235 if (!collapsed)
1236 drawSelectionRange(cm, range, selFragment);
1237 }
1238
1239 // Move the hidden textarea near the cursor to prevent scrolling artifacts
1240 if (cm.options.moveInputWithCursor) {
1241 var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
1242 var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
1243 var top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
1244 headPos.top + lineOff.top - wrapOff.top));
1245 var left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
1246 headPos.left + lineOff.left - wrapOff.left));
1247 display.inputDiv.style.top = top + "px";
1248 display.inputDiv.style.left = left + "px";
1249 }
1250
1251 removeChildrenAndAdd(display.cursorDiv, curFragment);
1252 removeChildrenAndAdd(display.selectionDiv, selFragment);
1253 }
1254
1255 // Draws a cursor for the given range
1256 function drawSelectionCursor(cm, range, output) {

Callers 2

updateDisplayFunction · 0.70
endOperationFunction · 0.70

Calls 4

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

Tested by

no test coverage detected