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

Method activate

addons/addon-image/src/ImageAddon.ts:79–147  ·  view source on GitHub ↗
(terminal: ITerminalExt)

Source from the content-addressed store, hash-verified

77 }
78
79 public activate(terminal: ITerminalExt): void {
80 this._terminal = terminal;
81
82 // internal data structures
83 this._renderer = new ImageRenderer(terminal);
84 this._storage = new ImageStorage(terminal, this._renderer, this._opts);
85
86 // enable size reports
87 if (this._opts.enableSizeReports) {
88 // const windowOptions = terminal.getOption('windowOptions');
89 // windowOptions.getWinSizePixels = true;
90 // windowOptions.getCellSizePixels = true;
91 // windowOptions.getWinSizeChars = true;
92 // terminal.setOption('windowOptions', windowOptions);
93 const windowOps = terminal.options.windowOptions || {};
94 windowOps.getWinSizePixels = true;
95 windowOps.getCellSizePixels = true;
96 windowOps.getWinSizeChars = true;
97 terminal.options.windowOptions = windowOps;
98 }
99
100 this._disposeLater(
101 this._renderer,
102 this._storage,
103
104 // DECSET/DECRST/DA1/XTSMGRAPHICS handlers
105 terminal.parser.registerCsiHandler({ prefix: '?', final: 'h' }, params => this._decset(params)),
106 terminal.parser.registerCsiHandler({ prefix: '?', final: 'l' }, params => this._decrst(params)),
107 terminal.parser.registerCsiHandler({ final: 'c' }, params => this._da1(params)),
108 terminal.parser.registerCsiHandler({ prefix: '?', final: 'S' }, params => this._xtermGraphicsAttributes(params)),
109
110 // render hook
111 terminal.onRender(range => this._storage?.render(range)),
112
113 /**
114 * reset handlers covered:
115 * - DECSTR
116 * - RIS
117 * - Terminal.reset()
118 */
119 terminal.parser.registerCsiHandler({ intermediates: '!', final: 'p' }, () => this.reset()),
120 terminal.parser.registerEscHandler({ final: 'c' }, () => this.reset()),
121 terminal._core._inputHandler.onRequestReset(() => this.reset()),
122
123 // wipe canvas and delete alternate images on buffer switch
124 terminal.buffer.onBufferChange(() => this._storage?.wipeAlternate()),
125
126 // extend images to the right on resize
127 terminal.onResize(metrics => this._storage?.viewportResize(metrics))
128 );
129
130 // SIXEL handler
131 if (this._opts.sixelSupport) {
132 const sixelHandler = new SixelHandler(this._opts, this._storage!, terminal);
133 this._handlers.set('sixel', sixelHandler);
134 this._disposeLater(
135 terminal._core._inputHandler._parser.registerDcsHandler({ final: 'q' }, sixelHandler)
136 );

Callers

nothing calls this directly

Calls 15

_disposeLaterMethod · 0.95
_decsetMethod · 0.95
_decrstMethod · 0.95
_da1Method · 0.95
resetMethod · 0.95
onRequestResetMethod · 0.80
wipeAlternateMethod · 0.80
viewportResizeMethod · 0.80
registerCsiHandlerMethod · 0.65
registerEscHandlerMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected