Files

106 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

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
/**
* An xterm.js addon that enables serialization of terminal contents.
2019-07-07 22:59:15 +08:00
*/
export class SerializeAddon implements ITerminalAddon {
constructor();
/**
* 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;
/**
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
*
* 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
*
* @param options Custom options to allow control over what gets serialized.
*/
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;
}
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;
/**
* 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.
*/
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;
}
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
}