mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Vendored
+4
@@ -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`
|
||||
*
|
||||
|
||||
Vendored
+4
@@ -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`
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user