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

Function prepareCopyCut

tools/pythonauto/static/codemirrorepl/codemirror.js:2419–2444  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

2417 });
2418
2419 function prepareCopyCut(e) {
2420 if (cm.somethingSelected()) {
2421 if (d.inaccurateSelection) {
2422 d.prevInput = "";
2423 d.inaccurateSelection = false;
2424 d.input.value = cm.getSelection();
2425 selectInput(d.input);
2426 }
2427 } else {
2428 var text = "", ranges = [];
2429 for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
2430 var line = cm.doc.sel.ranges[i].head.line;
2431 var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
2432 ranges.push(lineRange);
2433 text += cm.getRange(lineRange.anchor, lineRange.head);
2434 }
2435 if (e.type == "cut") {
2436 cm.setSelections(ranges, null, sel_dontScroll);
2437 } else {
2438 d.prevInput = "";
2439 d.input.value = text;
2440 selectInput(d.input);
2441 }
2442 }
2443 if (e.type == "cut") cm.state.cutIncoming = true;
2444 }
2445 on(d.input, "cut", prepareCopyCut);
2446 on(d.input, "copy", prepareCopyCut);
2447

Callers

nothing calls this directly

Calls 2

PosFunction · 0.85
selectInputFunction · 0.70

Tested by

no test coverage detected