Implement setSelection API

Fixes #1443
This commit is contained in:
Daniel Imms
2019-05-11 23:35:31 -07:00
parent 0fae9bb5a8
commit 6674f05cc8
5 changed files with 25 additions and 0 deletions
+10
View File
@@ -1535,6 +1535,16 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
return this.selectionManager ? this.selectionManager.hasSelection : false;
}
/**
* Selects text within the terminal.
* @param column The column the selection starts at..
* @param row The row the selection starts at.
* @param length The length of the selection.
*/
public setSelection(column: number, row: number, length: number): void {
this.selectionManager.setSelection(column, row, length);
}
/**
* Gets the terminal's current selection, this is useful for implementing copy
* behavior outside of xterm.js.
+3
View File
@@ -80,6 +80,9 @@ export class MockTerminal implements ITerminal {
hasSelection(): boolean {
throw new Error('Method not implemented.');
}
setSelection(column: number, row: number, length: number): void {
throw new Error('Method not implemented.');
}
getSelection(): string {
throw new Error('Method not implemented.');
}
+1
View File
@@ -249,6 +249,7 @@ export interface IPublicTerminal extends IDisposable, IEventEmitter {
deregisterCharacterJoiner(joinerId: number): void;
addMarker(cursorYOffset: number): IMarker;
hasSelection(): boolean;
setSelection(column: number, row: number, length: number): void;
getSelection(): string;
clearSelection(): void;
selectAll(): void;
+3
View File
@@ -96,6 +96,9 @@ export class Terminal implements ITerminalApi {
public hasSelection(): boolean {
return this._core.hasSelection();
}
public setSelection(column: number, row: number, length: number): void {
this._core.setSelection(column, row, length);
}
public getSelection(): string {
return this._core.getSelection();
}
+8
View File
@@ -670,6 +670,14 @@ declare module 'xterm' {
*/
hasSelection(): boolean;
/**
* Selects text within the terminal.
* @param column The column the selection starts at..
* @param row The row the selection starts at.
* @param length The length of the selection.
*/
setSelection(column: number, row: number, length: number): void;
/**
* Gets the terminal's current selection, this is useful for implementing
* copy behavior outside of xterm.js.