diff --git a/fixtures/typings-test/typings-test.ts b/fixtures/typings-test/typings-test.ts index 9d73535e..93fd501f 100644 --- a/fixtures/typings-test/typings-test.ts +++ b/fixtures/typings-test/typings-test.ts @@ -64,6 +64,7 @@ namespace methods_core { t.on('blur', () => {}); t.on('focus', () => {}); t.on('lineFeed', () => {}); + t.on('selection', () => {}); // args t.on('data', () => {}); t.on('data', (data: string) => console.log(data)); @@ -89,6 +90,7 @@ namespace methods_core { t.off('blur', () => {}); t.off('focus', () => {}); t.off('lineFeed', () => {}); + t.off('selection', () => {}); // args t.off('data', () => {}); t.off('data', (data: string) => console.log(data)); diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index bf5144cb..387ce8d1 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -255,6 +255,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager public selectAll(): void { this._model.isSelectAllActive = true; this.refresh(); + this.emit('selection'); } /** @@ -541,6 +542,9 @@ export class SelectionManager extends EventEmitter implements ISelectionManager */ private _onMouseUp(event: MouseEvent): void { this._removeMouseDownListeners(); + + if (this.hasSelection) + this.emit('selection'); } /** diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 9ab61ce6..b0f5ac4d 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -218,7 +218,7 @@ declare module 'xterm' { * @param type The type of the event. * @param listener The listener. */ - on(type: 'blur' | 'focus' | 'lineFeed', listener: () => void): void; + on(type: 'blur' | 'focus' | 'lineFeed' | 'selection', listener: () => void): void; /** * Registers an event listener. * @param type The type of the event. @@ -273,7 +273,7 @@ declare module 'xterm' { * @param type The type of the event. * @param listener The listener. */ - off(type: 'blur' | 'focus' | 'lineFeed' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; + off(type: 'blur' | 'focus' | 'lineFeed' | 'selection' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; /** * Resizes the terminal.