@volter/supercode-terminal 0.2.43 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/substrate/tmux.js +20 -17
package/package.json
CHANGED
package/substrate/tmux.js
CHANGED
|
@@ -849,29 +849,32 @@ function terminalInputRunOptions(deadlineMs) {
|
|
|
849
849
|
throw new Error("Terminal input expired before delivery.");
|
|
850
850
|
return { timeoutMs };
|
|
851
851
|
}
|
|
852
|
+
// The escape sequences a keystream carries for named keys, as tmux names them.
|
|
853
|
+
const ESCAPE_SEQUENCE_KEYS = [
|
|
854
|
+
["\u001b[A", "Up"],
|
|
855
|
+
["\u001b[B", "Down"],
|
|
856
|
+
["\u001b[C", "Right"],
|
|
857
|
+
["\u001b[D", "Left"],
|
|
858
|
+
["\u001b[H", "Home"],
|
|
859
|
+
["\u001b[F", "End"],
|
|
860
|
+
["\u001b[Z", "BTab"],
|
|
861
|
+
["\u001b[3~", "DC"],
|
|
862
|
+
["\u001b[5~", "PPage"],
|
|
863
|
+
["\u001b[6~", "NPage"],
|
|
864
|
+
];
|
|
852
865
|
function tokenizeTerminalInput(data) {
|
|
853
866
|
const tokens = [];
|
|
854
867
|
for (let i = 0; i < data.length; i += 1) {
|
|
855
868
|
const char = data[i];
|
|
856
|
-
const
|
|
857
|
-
if (
|
|
858
|
-
tokens.push({ key:
|
|
859
|
-
i +=
|
|
860
|
-
continue;
|
|
861
|
-
}
|
|
862
|
-
if (next3 === "\u001b[B") {
|
|
863
|
-
tokens.push({ key: "Down" });
|
|
864
|
-
i += 2;
|
|
865
|
-
continue;
|
|
866
|
-
}
|
|
867
|
-
if (next3 === "\u001b[C") {
|
|
868
|
-
tokens.push({ key: "Right" });
|
|
869
|
-
i += 2;
|
|
869
|
+
const sequence = ESCAPE_SEQUENCE_KEYS.find(([bytes]) => data.startsWith(bytes, i));
|
|
870
|
+
if (sequence) {
|
|
871
|
+
tokens.push({ key: sequence[1] });
|
|
872
|
+
i += sequence[0].length - 1;
|
|
870
873
|
continue;
|
|
871
874
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
+
// A lone ESC (no sequence after it) is the Escape key.
|
|
876
|
+
if (char === "\u001b") {
|
|
877
|
+
tokens.push({ key: "Escape" });
|
|
875
878
|
continue;
|
|
876
879
|
}
|
|
877
880
|
if (char === "\r" || char === "\n") {
|