diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 8b4923a..1fc5b2a 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -145,6 +145,13 @@ export class SelectionManager extends EventEmitter { this._buffer = buffer; } + /** + * Gets whether there is an active text selection. + */ + public get hasSelection(): boolean { + return !!this._model.finalSelectionStart && !!this._model.finalSelectionEnd; + } + /** * Gets the text currently selected. */ diff --git a/src/xterm.js b/src/xterm.js index 684ba45..09d21aa 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1373,11 +1373,18 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) { } } +/** + * Gets whether the terminal has an active selection. + */ +Terminal.prototype.hasSelection = function() { + return this.selectionManager.hasSelection; +} + /** * Gets the terminal's current selection, this is useful for implementing copy * behavior outside of xterm.js. */ -Terminal.prototype.getSelectionText = function() { +Terminal.prototype.getSelection = function() { // TODO: Should prepareTextForClipboard logic be moved to SelectionManager? return prepareTextForClipboard(this.selectionManager.selectionText); }