Merge pull request #1113 from bmf-ribeiro/selection-event-1093

Expose a selection event
This commit is contained in:
Daniel Imms
2017-11-07 13:56:07 -08:00
committed by GitHub
3 changed files with 8 additions and 2 deletions
+2
View File
@@ -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));
+4
View File
@@ -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');
}
/**
+2 -2
View File
@@ -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.