Serialize showCursor

Fixes #3364
This commit is contained in:
Daniel Imms
2025-12-31 08:12:39 -08:00
parent 40f2eefec7
commit 6277bb363c
6 changed files with 48 additions and 0 deletions
@@ -190,6 +190,38 @@ describe('SerializeAddon', () => {
assert.equal(buffer.scrollBottom, 3);
});
});
describe('cursor visibility', () => {
it('should serialize hidden cursor', async () => {
await writeP(terminal, 'hello\x1b[?25l');
assert.equal(terminal.modes.showCursor, false);
const result = serializeAddon.serialize();
assert.ok(result.includes('\x1b[?25l'), result);
});
it('should not serialize visible cursor (default state)', async () => {
await writeP(terminal, 'hello');
assert.equal(terminal.modes.showCursor, true);
const result = serializeAddon.serialize();
assert.ok(!result.includes('\x1b[?25l'), result);
assert.ok(!result.includes('\x1b[?25h'), result);
});
it('should not serialize cursor visibility when excludeModes is true', async () => {
await writeP(terminal, 'hello\x1b[?25l');
const result = serializeAddon.serialize({ excludeModes: true });
assert.ok(!result.includes('\x1b[?25l'), result);
});
it('should restore hidden cursor correctly when deserialized', async () => {
await writeP(terminal, 'hello\x1b[?25l');
const serialized = serializeAddon.serialize();
const terminal2 = new Terminal({ cols: 10, rows: 2, allowProposedApi: true });
terminal2.loadAddon(new SerializeAddon());
await writeP(terminal2, serialized);
assert.equal(terminal2.modes.showCursor, false);
});
});
});
describe('html', () => {
@@ -559,6 +559,12 @@ export class SerializeAddon implements ITerminalAddon , ISerializeApi {
}
}
// Cursor visibility (DECTCEM)
// Default: visible
if (!modes.showCursor) {
content += '\x1b[?25l';
}
return content;
}
+1
View File
@@ -124,6 +124,7 @@ export class Terminal extends Disposable implements ITerminalApi {
originMode: m.origin,
reverseWraparoundMode: m.reverseWraparound,
sendFocusMode: m.sendFocus,
showCursor: !this._core.coreService.isCursorHidden,
synchronizedOutputMode: m.synchronizedOutput,
wraparoundMode: m.wraparound
};
+1
View File
@@ -125,6 +125,7 @@ export class Terminal extends Disposable implements ITerminalApi {
originMode: m.origin,
reverseWraparoundMode: m.reverseWraparound,
sendFocusMode: m.sendFocus,
showCursor: !this._core.coreService.isCursorHidden,
synchronizedOutputMode: m.synchronizedOutput,
wraparoundMode: m.wraparound
};
+4
View File
@@ -1350,6 +1350,10 @@ declare module '@xterm/headless' {
* Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h`
*/
readonly sendFocusMode: boolean;
/**
* Show Cursor (DECTCEM): `CSI ? 2 5 h`
*/
readonly showCursor: boolean;
/**
* Synchronized Output Mode: `CSI ? 2 0 2 6 h`
*
+4
View File
@@ -1969,6 +1969,10 @@ declare module '@xterm/xterm' {
* Send FocusIn/FocusOut events: `CSI ? 1 0 0 4 h`
*/
readonly sendFocusMode: boolean;
/**
* Show Cursor (DECTCEM): `CSI ? 2 5 h`
*/
readonly showCursor: boolean;
/**
* Synchronized Output Mode: `CSI ? 2 0 2 6 h`
*