2019-07-07 22:59:15 +08:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
|
|
|
* @license MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2023-11-09 09:43:14 -08:00
|
|
|
import { Terminal, ITerminalAddon, IMarker, IBufferRange } from '@xterm/xterm';
|
2019-07-07 22:59:15 +08:00
|
|
|
|
2023-11-01 10:35:10 -07:00
|
|
|
declare module '@xterm/addon-serialize' {
|
2019-07-07 22:59:15 +08:00
|
|
|
/**
|
2021-09-15 05:04:11 -07:00
|
|
|
* An xterm.js addon that enables serialization of terminal contents.
|
2019-07-07 22:59:15 +08:00
|
|
|
*/
|
|
|
|
|
export class SerializeAddon implements ITerminalAddon {
|
|
|
|
|
|
|
|
|
|
constructor();
|
|
|
|
|
|
|
|
|
|
/**
|
2021-09-15 05:04:11 -07:00
|
|
|
* Activates the addon.
|
2019-07-07 22:59:15 +08:00
|
|
|
* @param terminal The terminal the addon is being loaded in.
|
|
|
|
|
*/
|
|
|
|
|
public activate(terminal: Terminal): void;
|
|
|
|
|
|
2019-07-12 23:21:48 +08:00
|
|
|
/**
|
2021-08-16 12:23:34 -07:00
|
|
|
* Serializes terminal rows into a string that can be written back to the terminal to restore
|
|
|
|
|
* the state. The cursor will also be positioned to the correct cell. When restoring a terminal
|
|
|
|
|
* it is best to do before `Terminal.open` is called to avoid wasting CPU cycles rendering
|
|
|
|
|
* incomplete frames.
|
2022-02-03 18:00:16 +00:00
|
|
|
*
|
2021-10-19 10:49:01 -07:00
|
|
|
* It's recommended that you write the serialized data into a terminal of the same size in which
|
|
|
|
|
* it originated from and then resize it after if needed.
|
2022-02-03 18:00:16 +00:00
|
|
|
*
|
2021-09-15 05:04:11 -07:00
|
|
|
* @param options Custom options to allow control over what gets serialized.
|
2019-07-12 23:21:48 +08:00
|
|
|
*/
|
2021-09-15 05:04:11 -07:00
|
|
|
public serialize(options?: ISerializeOptions): string;
|
2019-07-07 22:59:15 +08:00
|
|
|
|
2022-02-03 18:00:16 +00:00
|
|
|
/**
|
2022-02-12 09:42:08 +00:00
|
|
|
* Serializes terminal content as HTML, which can be written to the clipboard using the
|
|
|
|
|
* `text/html` mimetype. For applications that support it, the pasted text should then retain
|
|
|
|
|
* its colors/styles.
|
2022-02-03 18:00:16 +00:00
|
|
|
*
|
|
|
|
|
* @param options Custom options to allow control over what gets serialized.
|
|
|
|
|
*/
|
|
|
|
|
public serializeAsHTML(options?: Partial<IHTMLSerializeOptions>): string;
|
|
|
|
|
|
2019-07-07 22:59:15 +08:00
|
|
|
/**
|
|
|
|
|
* Disposes the addon.
|
|
|
|
|
*/
|
|
|
|
|
public dispose(): void;
|
|
|
|
|
}
|
2021-09-15 05:04:11 -07:00
|
|
|
|
|
|
|
|
export interface ISerializeOptions {
|
2023-11-09 09:43:14 -08:00
|
|
|
/**
|
|
|
|
|
* The row range to serialize. The an explicit range is specified, the cursor will get its final
|
|
|
|
|
* repositioning.
|
|
|
|
|
*/
|
|
|
|
|
range?: ISerializeRange;
|
|
|
|
|
|
2021-09-15 05:04:11 -07:00
|
|
|
/**
|
|
|
|
|
* The number of rows in the scrollback buffer to serialize, starting from the bottom of the
|
|
|
|
|
* scrollback buffer. When not specified, all available rows in the scrollback buffer will be
|
2023-11-09 09:43:14 -08:00
|
|
|
* serialized. This will be ignored if {@link range} is specified.
|
2021-09-15 05:04:11 -07:00
|
|
|
*/
|
|
|
|
|
scrollback?: number;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether to exclude the terminal modes from the serialization. False by default.
|
|
|
|
|
*/
|
|
|
|
|
excludeModes?: boolean;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether to exclude the alt buffer from the serialization. False by default.
|
|
|
|
|
*/
|
|
|
|
|
excludeAltBuffer?: boolean;
|
|
|
|
|
}
|
2022-02-03 18:00:16 +00:00
|
|
|
|
|
|
|
|
export interface IHTMLSerializeOptions {
|
|
|
|
|
/**
|
|
|
|
|
* The number of rows in the scrollback buffer to serialize, starting from the bottom of the
|
|
|
|
|
* scrollback buffer. When not specified, all available rows in the scrollback buffer will be
|
2022-02-12 09:42:08 +00:00
|
|
|
* serialized. This setting is ignored if {@link IHTMLSerializeOptions.onlySelection} is true.
|
2022-02-03 18:00:16 +00:00
|
|
|
*/
|
|
|
|
|
scrollback: number;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether to only serialize the selection. If false, the whole active buffer is serialized in HTML.
|
2022-02-12 09:42:08 +00:00
|
|
|
* False by default.
|
2022-02-03 18:00:16 +00:00
|
|
|
*/
|
|
|
|
|
onlySelection: boolean;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-02-12 09:42:08 +00:00
|
|
|
* Whether to include the global background of the terminal. False by default.
|
2022-02-03 18:00:16 +00:00
|
|
|
*/
|
|
|
|
|
includeGlobalBackground: boolean;
|
2025-10-28 10:27:00 -04:00
|
|
|
|
|
|
|
|
/**
|
2025-10-28 11:44:21 -04:00
|
|
|
* The range to serialize. This is prioritized over {@link onlySelection}.
|
2025-10-28 10:27:00 -04:00
|
|
|
*/
|
2025-10-28 11:44:21 -04:00
|
|
|
range?: ISerializeBufferRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ISerializeBufferRange {
|
|
|
|
|
startLine: number;
|
|
|
|
|
endLine: number;
|
|
|
|
|
startCol: number;
|
2022-02-03 18:00:16 +00:00
|
|
|
}
|
2023-11-09 09:43:14 -08:00
|
|
|
|
|
|
|
|
export interface ISerializeRange {
|
|
|
|
|
/**
|
|
|
|
|
* The line to start serializing (inclusive).
|
|
|
|
|
*/
|
|
|
|
|
start: IMarker | number;
|
|
|
|
|
/**
|
|
|
|
|
* The line to end serializing (inclusive).
|
|
|
|
|
*/
|
|
|
|
|
end: IMarker | number;
|
|
|
|
|
}
|
2019-07-07 22:59:15 +08:00
|
|
|
}
|