Skip to content

Commit

Permalink
Merge pull request #797 from mofux/guard_selection_api
Browse files Browse the repository at this point in the history
Guard public selection api
  • Loading branch information
Tyriar committed Jul 14, 2017
2 parents 1fd087e + e2b43a4 commit c94fdae
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/xterm.js
Expand Up @@ -1437,29 +1437,33 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) {
* Gets whether the terminal has an active selection.
*/
Terminal.prototype.hasSelection = function() {
return this.selectionManager.hasSelection;
return this.selectionManager ? this.selectionManager.hasSelection : false;
};

/**
* Gets the terminal's current selection, this is useful for implementing copy
* behavior outside of xterm.js.
*/
Terminal.prototype.getSelection = function() {
return this.selectionManager.selectionText;
return this.selectionManager ? this.selectionManager.selectionText : '';
};

/**
* Clears the current terminal selection.
*/
Terminal.prototype.clearSelection = function() {
this.selectionManager.clearSelection();
if (this.selectionManager) {
this.selectionManager.clearSelection();
}
};

/**
* Selects all text within the terminal.
*/
Terminal.prototype.selectAll = function() {
this.selectionManager.selectAll();
if (this.selectionManager) {
this.selectionManager.selectAll();
}
};

/**
Expand Down

0 comments on commit c94fdae

Please sign in to comment.