Serialize scroll region

fixes #3433
This commit is contained in:
Daniel Imms
2025-12-29 07:53:43 -08:00
parent 8e6b6e7464
commit 29d3eb2e52
2 changed files with 58 additions and 1 deletions
+21 -1
View File
@@ -513,6 +513,25 @@ export class SerializeAddon implements ITerminalAddon , ISerializeApi {
return '';
}
/**
* Serializes the scroll region (DECSTBM) if it's not set to the full terminal size.
* Uses internal API access since scroll region is not exposed in the public API.
*/
private _serializeScrollRegion(terminal: Terminal): string {
// HACK: Internal API access since scroll region is not exposed in the public API
const buffer = (terminal as any)._core.buffer;
const scrollTop: number = buffer.scrollTop;
const scrollBottom: number = buffer.scrollBottom;
// Only serialize if scroll region is not the default (full terminal size)
if (scrollTop !== 0 || scrollBottom !== terminal.rows - 1) {
// DECSTBM uses 1-based indices: CSI Ps ; Ps r
return `\x1b[${scrollTop + 1};${scrollBottom + 1}r`;
}
return '';
}
private _serializeModes(terminal: Terminal): string {
let content = '';
const modes = terminal.modes;
@@ -562,9 +581,10 @@ export class SerializeAddon implements ITerminalAddon , ISerializeApi {
}
}
// Modes
// Modes and scroll region
if (!options?.excludeModes) {
content += this._serializeModes(this._terminal);
content += this._serializeScrollRegion(this._terminal);
}
return content;