termites 1.0.15 → 1.0.17
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/server.js +50 -12
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -725,6 +725,9 @@ class TermitesServer {
|
|
|
725
725
|
<button data-seq="\\x04">^D</button>
|
|
726
726
|
<button data-seq="\\x1a">^Z</button>
|
|
727
727
|
<button data-seq="\\x0c">^L</button>
|
|
728
|
+
<div class="sep"></div>
|
|
729
|
+
<button id="copy-btn">Copy</button>
|
|
730
|
+
<button id="paste-btn">Paste</button>
|
|
728
731
|
</div>
|
|
729
732
|
|
|
730
733
|
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.min.js"></script>
|
|
@@ -1030,6 +1033,28 @@ class TermitesServer {
|
|
|
1030
1033
|
btn.addEventListener('touchstart', handler, { passive: false });
|
|
1031
1034
|
btn.addEventListener('click', handler);
|
|
1032
1035
|
});
|
|
1036
|
+
|
|
1037
|
+
// Copy button - copy selection or last line
|
|
1038
|
+
document.getElementById('copy-btn').addEventListener('click', async () => {
|
|
1039
|
+
const selection = term.getSelection();
|
|
1040
|
+
if (selection) {
|
|
1041
|
+
await navigator.clipboard.writeText(selection);
|
|
1042
|
+
term.clearSelection();
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
// Paste button
|
|
1047
|
+
document.getElementById('paste-btn').addEventListener('click', async () => {
|
|
1048
|
+
try {
|
|
1049
|
+
const text = await navigator.clipboard.readText();
|
|
1050
|
+
if (text && ws?.readyState === WebSocket.OPEN && selectedClientId) {
|
|
1051
|
+
ws.send(JSON.stringify({ type: 'input', clientId: selectedClientId, text }));
|
|
1052
|
+
}
|
|
1053
|
+
} catch (e) {
|
|
1054
|
+
console.error('Paste failed:', e);
|
|
1055
|
+
}
|
|
1056
|
+
term.focus();
|
|
1057
|
+
});
|
|
1033
1058
|
}
|
|
1034
1059
|
|
|
1035
1060
|
function updateClientList() {
|
|
@@ -1088,22 +1113,35 @@ class TermitesServer {
|
|
|
1088
1113
|
term.onData(data => {
|
|
1089
1114
|
if (ws?.readyState === WebSocket.OPEN && selectedClientId) {
|
|
1090
1115
|
let sendData = data;
|
|
1116
|
+
let shouldSend = true;
|
|
1117
|
+
|
|
1091
1118
|
// Apply Ctrl modifier to keyboard input
|
|
1092
1119
|
if (modifiers.ctrl) {
|
|
1093
|
-
//
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1120
|
+
// Look for any letter in the input (handles IME)
|
|
1121
|
+
let foundLetter = false;
|
|
1122
|
+
for (let i = 0; i < data.length; i++) {
|
|
1123
|
+
const char = data[i];
|
|
1124
|
+
const code = char.toUpperCase().charCodeAt(0);
|
|
1125
|
+
if (code >= 65 && code <= 90) { // A-Z
|
|
1126
|
+
sendData = String.fromCharCode(code - 64);
|
|
1127
|
+
foundLetter = true;
|
|
1128
|
+
// Reset Ctrl after successful use
|
|
1129
|
+
modifiers.ctrl = false;
|
|
1130
|
+
if (ctrlTimeout) { clearTimeout(ctrlTimeout); ctrlTimeout = null; }
|
|
1131
|
+
document.querySelectorAll('.mod-btn[data-mod="ctrl"]').forEach(b => b.classList.remove('active'));
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
// If Ctrl is active but no letter found, don't send (wait for letter)
|
|
1136
|
+
if (!foundLetter) {
|
|
1137
|
+
shouldSend = false;
|
|
1103
1138
|
}
|
|
1104
1139
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1140
|
+
|
|
1141
|
+
if (shouldSend) {
|
|
1142
|
+
ws.send(JSON.stringify({ type: 'input', clientId: selectedClientId, text: sendData }));
|
|
1143
|
+
term.scrollToBottom();
|
|
1144
|
+
}
|
|
1107
1145
|
}
|
|
1108
1146
|
});
|
|
1109
1147
|
function handleResize() {
|