@xterm/xterm 6.1.0-beta.195 → 6.1.0-beta.197

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xterm/xterm",
3
3
  "description": "Full xterm terminal, in your browser",
4
- "version": "6.1.0-beta.195",
4
+ "version": "6.1.0-beta.197",
5
5
  "main": "lib/xterm.js",
6
6
  "module": "lib/xterm.mjs",
7
7
  "style": "css/xterm.css",
@@ -119,5 +119,5 @@
119
119
  "ws": "^8.2.3",
120
120
  "xterm-benchmark": "^0.3.1"
121
121
  },
122
- "commit": "1432e2008284701b6b5035de5553c6baa876bdc1"
122
+ "commit": "34e017935581b6e0081b0e2bebe53e3193b85be7"
123
123
  }
@@ -40,7 +40,7 @@ export class KeyboardService implements IKeyboardService {
40
40
  }
41
41
  const kittyFlags = this._coreService.kittyKeyboard.flags;
42
42
  return this.useKitty
43
- ? this._getKittyKeyboard().evaluate(event, kittyFlags, event.repeat ? KittyKeyboardEventType.REPEAT : KittyKeyboardEventType.PRESS)
43
+ ? this._getKittyKeyboard().evaluate(event, kittyFlags, event.repeat ? KittyKeyboardEventType.REPEAT : KittyKeyboardEventType.PRESS, isMac && this._optionsService.rawOptions.macOptionIsMeta)
44
44
  : evaluateKeyboardEvent(event, this._coreService.decPrivateModes.applicationCursorKeys, isMac, this._optionsService.rawOptions.macOptionIsMeta);
45
45
  }
46
46
 
@@ -51,7 +51,7 @@ export class KeyboardService implements IKeyboardService {
51
51
  }
52
52
  const kittyFlags = this._coreService.kittyKeyboard.flags;
53
53
  if (this.useKitty && (kittyFlags & KittyKeyboardFlags.REPORT_EVENT_TYPES)) {
54
- return this._getKittyKeyboard().evaluate(event, kittyFlags, KittyKeyboardEventType.RELEASE);
54
+ return this._getKittyKeyboard().evaluate(event, kittyFlags, KittyKeyboardEventType.RELEASE, isMac && this._optionsService.rawOptions.macOptionIsMeta);
55
55
  }
56
56
  return undefined;
57
57
  }
@@ -3,7 +3,6 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
- import { isNode } from 'common/Platform';
7
6
  import type { ILogService } from 'common/services/Services';
8
7
 
9
8
  interface ITaskQueue {
@@ -148,7 +147,7 @@ class IdleTaskQueueInternal extends TaskQueue {
148
147
  * This reverts to a {@link PriorityTaskQueue} if the environment does not support idle callbacks.
149
148
  */
150
149
  // eslint-disable-next-line @typescript-eslint/naming-convention
151
- export const IdleTaskQueue = (!isNode && 'requestIdleCallback' in window) ? IdleTaskQueueInternal : PriorityTaskQueue;
150
+ export const IdleTaskQueue = ('requestIdleCallback' in globalThis) ? IdleTaskQueueInternal : PriorityTaskQueue;
152
151
 
153
152
  /**
154
153
  * An object that tracks a single debounced task that will run on the next idle frame. When called
@@ -6,4 +6,4 @@
6
6
  /**
7
7
  * The xterm.js version. This is updated by the publish script from package.json.
8
8
  */
9
- export const XTERM_VERSION = '6.1.0-beta.195';
9
+ export const XTERM_VERSION = '6.1.0-beta.197';
@@ -218,7 +218,7 @@ export class KittyKeyboard {
218
218
  * Returns the lowercase codepoint for letters.
219
219
  * For shifted keys, uses the code property to get the base key.
220
220
  */
221
- private _getKeyCode(ev: IKeyboardEvent): number | undefined {
221
+ private _getKeyCode(ev: IKeyboardEvent, macOptionAsAlt: boolean): number | undefined {
222
222
  const numpadCode = this._getNumpadKeyCode(ev);
223
223
  if (numpadCode !== undefined) {
224
224
  return numpadCode;
@@ -234,7 +234,7 @@ export class KittyKeyboard {
234
234
  return funcCode;
235
235
  }
236
236
 
237
- if (ev.shiftKey && ev.code) {
237
+ if ((ev.shiftKey || (macOptionAsAlt && ev.altKey)) && ev.code) {
238
238
  if (ev.code.startsWith('Digit') && ev.code.length === 6) {
239
239
  const digit = ev.code.charAt(5);
240
240
  if (digit >= '0' && digit <= '9') {
@@ -265,6 +265,19 @@ export class KittyKeyboard {
265
265
  return ev.key === 'Shift' || ev.key === 'Control' || ev.key === 'Alt' || ev.key === 'Meta';
266
266
  }
267
267
 
268
+ /**
269
+ * Check if a key is a lock key (CapsLock/NumLock/ScrollLock).
270
+ *
271
+ * Kitty's reference implementation classifies these as modifier keys for the
272
+ * purpose of suppressing press events (kitty/keys.c `is_modifier_key()`
273
+ * includes `GLFW_FKEY_CAPS_LOCK`, `GLFW_FKEY_SCROLL_LOCK`, `GLFW_FKEY_NUM_LOCK`),
274
+ * and its test suite asserts that a CapsLock press with no protocol flags
275
+ * produces empty output.
276
+ */
277
+ private _isLockKey(ev: IKeyboardEvent): boolean {
278
+ return ev.key === 'CapsLock' || ev.key === 'NumLock' || ev.key === 'ScrollLock';
279
+ }
280
+
268
281
  /**
269
282
  * Build CSI letter sequence for arrow keys, Home, End.
270
283
  * Format: CSI [1;mod] letter
@@ -397,12 +410,14 @@ export class KittyKeyboard {
397
410
  * @param ev The keyboard event.
398
411
  * @param flags The active Kitty keyboard enhancement flags.
399
412
  * @param eventType The event type (press, repeat, release).
413
+ * @param macOptionAsAlt When true, macOS Option-composed ev.key values are unwound via ev.code.
400
414
  * @returns The keyboard result with the encoded key sequence.
401
415
  */
402
416
  public evaluate(
403
417
  ev: IKeyboardEvent,
404
418
  flags: number,
405
- eventType: KittyKeyboardEventType = KittyKeyboardEventType.PRESS
419
+ eventType: KittyKeyboardEventType = KittyKeyboardEventType.PRESS,
420
+ macOptionAsAlt: boolean = false
406
421
  ): IKeyboardResult {
407
422
  const result: IKeyboardResult = {
408
423
  type: KeyboardResultType.SEND_KEY,
@@ -422,6 +437,14 @@ export class KittyKeyboard {
422
437
  return result;
423
438
  }
424
439
 
440
+ // Spec § "Report all keys as escape codes": "Additionally, with this mode,
441
+ // events for pressing modifier keys are reported." — i.e. *without* this
442
+ // mode, modifier-key press events are suppressed. Kitty's is_modifier_key()
443
+ // treats CapsLock/NumLock/ScrollLock as modifier keys for this rule.
444
+ if (this._isLockKey(ev) && !(flags & KittyKeyboardFlags.REPORT_ALL_KEYS_AS_ESCAPE_CODES)) {
445
+ return result;
446
+ }
447
+
425
448
  const csiLetter = this._csiLetterKeys[ev.key];
426
449
  if (csiLetter) {
427
450
  result.key = this._buildCsiLetterSequence(csiLetter, modifiers, eventType, reportEventTypes);
@@ -443,7 +466,7 @@ export class KittyKeyboard {
443
466
  return result;
444
467
  }
445
468
 
446
- const keyCode = this._getKeyCode(ev);
469
+ const keyCode = this._getKeyCode(ev, macOptionAsAlt);
447
470
  if (keyCode === undefined) {
448
471
  return result;
449
472
  }