diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 1fc5b2ab..02eebb1d 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -180,6 +180,16 @@ export class SelectionManager extends EventEmitter { return result.join('\n'); } + /** + * Clears the current terminal selection. + */ + public clearSelection(): void { + this._model.selectionStart = null; + this._model.selectionEnd = null; + this._removeMouseDownListeners(); + this.refresh(); + } + /** * Translates a buffer line to a string, with optional start and end columns. * Wide characters will count as two columns in the resulting string. This diff --git a/src/xterm.js b/src/xterm.js index 09d21aab..eb44d3bf 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1389,6 +1389,13 @@ Terminal.prototype.getSelection = function() { return prepareTextForClipboard(this.selectionManager.selectionText); } +/** + * Clears the current terminal selection. + */ +Terminal.prototype.clearSelection = function() { + this.selectionManager.clearSelection(); +} + /** * Selects all text within the terminal. */