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

Function readInput

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:1054–1069  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1052 // supported or compatible enough yet to rely on.)
1053 var prevInput = "";
1054 function readInput() {
1055 if (leaveInputAlone || !focused || hasSelection(input) || options.readOnly) return false;
1056 var text = input.value;
1057 if (text == prevInput) return false;
1058 shiftSelecting = null;
1059 var same = 0, l = Math.min(prevInput.length, text.length);
1060 while (same < l && prevInput[same] == text[same]) ++same;
1061 if (same < prevInput.length)
1062 sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
1063 else if (overwrite && posEq(sel.from, sel.to))
1064 sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
1065 replaceSelection(text.slice(same), "end");
1066 if (text.length > 1000) { input.value = prevInput = ""; }
1067 else prevInput = text;
1068 return true;
1069 }
1070 function resetInput(user) {
1071 if (!posEq(sel.from, sel.to)) {
1072 prevInput = "";

Callers 4

onKeyDownFunction · 0.70
onKeyPressFunction · 0.70
slowPollFunction · 0.70
pFunction · 0.70

Calls 4

replaceSelectionFunction · 0.85
sliceMethod · 0.80
posEqFunction · 0.70
getLineFunction · 0.70

Tested by

no test coverage detected