termites 1.0.15 → 1.0.16

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +25 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termites",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Web terminal with server-client architecture for remote shell access",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -1088,22 +1088,35 @@ class TermitesServer {
1088
1088
  term.onData(data => {
1089
1089
  if (ws?.readyState === WebSocket.OPEN && selectedClientId) {
1090
1090
  let sendData = data;
1091
+ let shouldSend = true;
1092
+
1091
1093
  // Apply Ctrl modifier to keyboard input
1092
1094
  if (modifiers.ctrl) {
1093
- // Handle single character or IME input
1094
- const char = data.length >= 1 ? data[0] : '';
1095
- const code = char.toUpperCase().charCodeAt(0);
1096
- if (code >= 65 && code <= 90) { // A-Z
1097
- sendData = String.fromCharCode(code - 64);
1098
- console.log('Sending Ctrl+' + char.toUpperCase());
1099
- // Reset Ctrl after successful use
1100
- modifiers.ctrl = false;
1101
- if (ctrlTimeout) { clearTimeout(ctrlTimeout); ctrlTimeout = null; }
1102
- document.querySelectorAll('.mod-btn[data-mod="ctrl"]').forEach(b => b.classList.remove('active'));
1095
+ // Look for any letter in the input (handles IME)
1096
+ let foundLetter = false;
1097
+ for (let i = 0; i < data.length; i++) {
1098
+ const char = data[i];
1099
+ const code = char.toUpperCase().charCodeAt(0);
1100
+ if (code >= 65 && code <= 90) { // A-Z
1101
+ sendData = String.fromCharCode(code - 64);
1102
+ foundLetter = true;
1103
+ // Reset Ctrl after successful use
1104
+ modifiers.ctrl = false;
1105
+ if (ctrlTimeout) { clearTimeout(ctrlTimeout); ctrlTimeout = null; }
1106
+ document.querySelectorAll('.mod-btn[data-mod="ctrl"]').forEach(b => b.classList.remove('active'));
1107
+ break;
1108
+ }
1103
1109
  }
1110
+ // If Ctrl is active but no letter found, don't send (wait for letter)
1111
+ if (!foundLetter) {
1112
+ shouldSend = false;
1113
+ }
1114
+ }
1115
+
1116
+ if (shouldSend) {
1117
+ ws.send(JSON.stringify({ type: 'input', clientId: selectedClientId, text: sendData }));
1118
+ term.scrollToBottom();
1104
1119
  }
1105
- ws.send(JSON.stringify({ type: 'input', clientId: selectedClientId, text: sendData }));
1106
- term.scrollToBottom();
1107
1120
  }
1108
1121
  });
1109
1122
  function handleResize() {