MCPcopy
hub / github.com/xtermjs/xterm.js / serialize

Method serialize

addons/addon-serialize/src/SerializeAddon.ts:511–536  ·  view source on GitHub ↗
(options?: ISerializeOptions)

Source from the content-addressed store, hash-verified

509 }
510
511 public serialize(options?: ISerializeOptions): string {
512 // TODO: Add combinedData support
513 if (!this._terminal) {
514 throw new Error('Cannot use addon until it has been loaded');
515 }
516
517 // Normal buffer
518 let content = options?.range
519 ? this._serializeBufferByRange(this._terminal, this._terminal.buffer.normal, options.range, true)
520 : this._serializeBufferByScrollback(this._terminal, this._terminal.buffer.normal, options?.scrollback);
521
522 // Alternate buffer
523 if (!options?.excludeAltBuffer) {
524 if (this._terminal.buffer.active.type === 'alternate') {
525 const alternativeScreenContent = this._serializeBufferByScrollback(this._terminal, this._terminal.buffer.alternate, undefined);
526 content += `\u001b[?1049h\u001b[H${alternativeScreenContent}`;
527 }
528 }
529
530 // Modes
531 if (!options?.excludeModes) {
532 content += this._serializeModes(this._terminal);
533 }
534
535 return content;
536 }
537
538 public serializeAsHTML(options?: Partial<IHTMLSerializeOptions>): string {
539 if (!this._terminal) {

Calls 3

_serializeModesMethod · 0.95

Tested by

no test coverage detected