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

Class TerminalProxy

test/playwright/TestUtils.ts:133–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 'loadAddon'
132);
133export class TerminalProxy implements ITerminalProxyCustomMethods, PlaywrightApiProxy<Terminal, TerminalProxyAsyncPropOverrides, TerminalProxyAsyncMethodOverrides, TerminalProxyCustomOverrides> {
134 constructor(private readonly _page: Page) {
135 }
136
137 /**
138 * Initialize the proxy for a new playwright page.
139 */
140 public async initPage(): Promise<void> {
141 await this._page.exposeFunction('onBell', () => this._onBell.fire());
142 await this._page.exposeFunction('onBinary', (e: string) => this._onBinary.fire(e));
143 await this._page.exposeFunction('onCursorMove', () => this._onCursorMove.fire());
144 await this._page.exposeFunction('onData', (e: string) => this._onData.fire(e));
145 await this._page.exposeFunction('onKey', (e: { key: string, domEvent: KeyboardEvent }) => this._onKey.fire(e));
146 await this._page.exposeFunction('onLineFeed', () => this._onLineFeed.fire());
147 await this._page.exposeFunction('onRender', (e: { start: number, end: number }) => this._onRender.fire(e));
148 await this._page.exposeFunction('onResize', (e: { cols: number, rows: number }) => this._onResize.fire(e));
149 await this._page.exposeFunction('onScroll', (e: number) => this._onScroll.fire(e));
150 await this._page.exposeFunction('onSelectionChange', () => this._onSelectionChange.fire());
151 await this._page.exposeFunction('onTitleChange', (e: string) => this._onTitleChange.fire(e));
152 await this._page.exposeFunction('onWriteParsed', () => this._onWriteParsed.fire());
153 }
154
155 /**
156 * Initialize the proxy for a new terminal object.
157 */
158 public async initTerm(): Promise<void> {
159 this._onBell.dispose();
160 this._onBinary.dispose();
161 this._onCursorMove.dispose();
162 this._onData.dispose();
163 this._onKey.dispose();
164 this._onLineFeed.dispose();
165 this._onRender.dispose();
166 this._onResize.dispose();
167 this._onScroll.dispose();
168 this._onSelectionChange.dispose();
169 this._onTitleChange.dispose();
170 this._onWriteParsed.dispose();
171
172 this._onBell = new EventEmitter();
173 this._onBinary = new EventEmitter();
174 this._onCursorMove = new EventEmitter();
175 this._onData = new EventEmitter();
176 this._onKey = new EventEmitter();
177 this._onLineFeed = new EventEmitter();
178 this._onRender = new EventEmitter();
179 this._onResize = new EventEmitter();
180 this._onScroll = new EventEmitter();
181 this._onSelectionChange = new EventEmitter();
182 this._onTitleChange = new EventEmitter();
183 this._onWriteParsed = new EventEmitter();
184
185 await this.evaluate(([term]) => term.onBell((window as any).onBell));
186 await this.evaluate(([term]) => term.onBinary((window as any).onBinary));
187 await this.evaluate(([term]) => term.onCursorMove((window as any).onCursorMove));
188 await this.evaluate(([term]) => term.onData((window as any).onData));
189 await this.evaluate(([term]) => term.onKey((window as any).onKey));
190 await this.evaluate(([term]) => term.onLineFeed((window as any).onLineFeed));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected