while (i--) {
this.lines.push(this.blankLine());
}
+ // Ensure the selection manager has the correct buffer
+ if (this.selectionManager) {
+ this.selectionManager.setBuffer(this.lines);
+ }
this.tabs;
this.setupStops();
// Bind clipboard functionality
on(this.element, 'copy', event => {
- copyHandler(event, term, term.selectionManager);
+ // If mouse events are active it means the selection manager is disabled and
+ // copy should be handled by the host program.
+ if (this.mouseEvents) {
+ return;
+ }
+ copyHandler(event, term, this.selectionManager);
});
const pasteHandlerWrapper = event => pasteHandler(event, term);
on(this.textarea, 'paste', pasteHandlerWrapper);
this.charMeasure = new CharMeasure(document, this.helperContainer);
this.charMeasure.on('charsizechanged', function () {
- self.updateCharSizeCSS();
+ self.updateCharSizeStyles();
});
this.charMeasure.measure();
* Updates the helper CSS class with any changes necessary after the terminal's
* character width has been changed.
*/
-Terminal.prototype.updateCharSizeCSS = function() {
+Terminal.prototype.updateCharSizeStyles = function() {
this.charSizeStyleElement.textContent =
`.xterm-wide-char{width:${this.charMeasure.width * 2}px;}` +
- `.xterm-normal-char{width:${this.charMeasure.width}px;}`
+ `.xterm-normal-char{width:${this.charMeasure.width}px;}`;
}
/**
}
}
+/**
+ * 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.getSelection = function() {
+ return this.selectionManager.selectionText;
+}
+
+/**
+ * Clears the current terminal selection.
+ */
+Terminal.prototype.clearSelection = function() {
+ this.selectionManager.clearSelection();
+}
+
/**
* Selects all text within the terminal.
*/