From 5d33727ae4dcc8335351b723af9fcb484fdf6d49 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Wed, 7 Jun 2017 13:07:34 -0700 Subject: [PATCH] Add clearSelection API --- src/SelectionManager.ts | 10 ++++++++++ src/xterm.js | 7 +++++++ 2 files changed, 17 insertions(+) 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. */