MCPcopy
hub / github.com/nwutils/nw-sample-apps / readInput

Function readInput

mini-code-edit/cm/lib/codemirror.js:854–869  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852 // supported or compatible enough yet to rely on.)
853 var prevInput = "";
854 function readInput() {
855 if (leaveInputAlone || !focused || hasSelection(input) || options.readOnly) return false;
856 var text = input.value;
857 if (text == prevInput) return false;
858 shiftSelecting = null;
859 var same = 0, l = Math.min(prevInput.length, text.length);
860 while (same < l && prevInput[same] == text[same]) ++same;
861 if (same < prevInput.length)
862 sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
863 else if (overwrite && posEq(sel.from, sel.to))
864 sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
865 replaceSelection(text.slice(same), "end");
866 if (text.length > 1000) { input.value = prevInput = ""; }
867 else prevInput = text;
868 return true;
869 }
870 function resetInput(user) {
871 if (!posEq(sel.from, sel.to)) {
872 prevInput = "";

Callers 4

onKeyDownFunction · 0.85
onKeyPressFunction · 0.85
slowPollFunction · 0.85
pFunction · 0.85

Calls 3

posEqFunction · 0.85
getLineFunction · 0.85
replaceSelectionFunction · 0.85

Tested by

no test coverage detected