@tuidom/terminal-backend 0.20.0 → 0.22.0

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.
@@ -36,6 +36,8 @@ export declare class NodeTerminalBackend implements ITerminalBackend {
36
36
  private cleanupHandlers;
37
37
  /** The title stack got a push from {@link setWindowTitle}; teardown owes it a pop. */
38
38
  private titlePushed;
39
+ /** The pointer shape the terminal shows; teardown owes it a reset when not `"default"`. */
40
+ private pointerShape;
39
41
  private readonly isTmux;
40
42
  private readonly isGnuScreen;
41
43
  private readonly inputParser;
@@ -82,6 +84,12 @@ export declare class NodeTerminalBackend implements ITerminalBackend {
82
84
  * on the terminal's title stack; {@link teardown} restores it.
83
85
  */
84
86
  setWindowTitle(title: string): void;
87
+ /**
88
+ * Set the mouse pointer shape (OSC 22). Writes only when the shape changes, so a run
89
+ * that never leaves `"default"` writes nothing. Not under GNU Screen: it has no
90
+ * passthrough the way tmux does.
91
+ */
92
+ setPointerShape(shape: string): void;
85
93
  onInput(callback: (event: KeyPressEvent) => void): void;
86
94
  onMouse(callback: (event: MouseToken) => void): void;
87
95
  onPaste(callback: (text: string) => void): void;
@@ -46,6 +46,14 @@ const BRACKETED_PASTE_DISABLE = "\x1b[?2004l";
46
46
  */
47
47
  const TITLE_PUSH = "\x1b[22;0t";
48
48
  const TITLE_POP = "\x1b[23;0t";
49
+ /**
50
+ * OSC 22 — set the mouse pointer shape to a CSS cursor name (kitty's pointer-shapes
51
+ * protocol: kitty, Ghostty, foot, iTerm2, xterm). Terminals without it drop the
52
+ * sequence. tmux doesn't know it, so it goes through passthrough.
53
+ */
54
+ function pointerShapeSequence(shape) {
55
+ return `\x1b]22;${shape}\x1b\\`;
56
+ }
49
57
  /**
50
58
  * Color-scheme reports (DEC private mode 2031, the Contour protocol): with the mode on the
51
59
  * terminal sends `CSI ? 997 ; 1|2 n` whenever its scheme flips; `CSI ? 996 n` asks for the
@@ -173,6 +181,8 @@ export class NodeTerminalBackend {
173
181
  cleanupHandlers = [];
174
182
  /** The title stack got a push from {@link setWindowTitle}; teardown owes it a pop. */
175
183
  titlePushed = false;
184
+ /** The pointer shape the terminal shows; teardown owes it a reset when not `"default"`. */
185
+ pointerShape = "default";
176
186
  isTmux;
177
187
  isGnuScreen;
178
188
  inputParser = new KeyInputParser();
@@ -236,6 +246,17 @@ export class NodeTerminalBackend {
236
246
  }
237
247
  this.writeDirect(windowTitleSequence(title));
238
248
  }
249
+ /**
250
+ * Set the mouse pointer shape (OSC 22). Writes only when the shape changes, so a run
251
+ * that never leaves `"default"` writes nothing. Not under GNU Screen: it has no
252
+ * passthrough the way tmux does.
253
+ */
254
+ setPointerShape(shape) {
255
+ if (shape === this.pointerShape || this.isGnuScreen)
256
+ return;
257
+ this.writePassthrough(pointerShapeSequence(shape));
258
+ this.pointerShape = shape;
259
+ }
239
260
  onInput(callback) {
240
261
  this.inputCallbacks.push(callback);
241
262
  }
@@ -530,6 +551,8 @@ export class NodeTerminalBackend {
530
551
  this.writeDirect(COLOR_SCHEME_REPORTS_DISABLE);
531
552
  this.colorSchemeReportsOn = false;
532
553
  }
554
+ // Bring back the default pointer, or the shell keeps the last one (a resize arrow).
555
+ this.setPointerShape("default");
533
556
  // Restore cursor
534
557
  this.stdout.write("\x1b[?25h");
535
558
  // Restore normal screen buffer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuidom/terminal-backend",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "description": "Experimental terminal UI DOM — real terminal backend for Node (tty, ANSI diffing, Kitty protocol). API is unstable.",
6
6
  "license": "MIT",
@@ -28,6 +28,6 @@
28
28
  "./*": "./dist/*.js"
29
29
  },
30
30
  "dependencies": {
31
- "@tuidom/core": "0.20.0"
31
+ "@tuidom/core": "0.22.0"
32
32
  }
33
33
  }