mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
+15
-2
@@ -293,10 +293,23 @@ export class SelectionManager extends EventEmitter {
|
||||
/**
|
||||
* Queues a refresh, redrawing the selection on the next opportunity.
|
||||
*/
|
||||
public refresh(): void {
|
||||
public refresh(fromMouseEvent?: boolean): void {
|
||||
// Queue the refresh for the renderer
|
||||
if (!this._refreshAnimationFrame) {
|
||||
this._refreshAnimationFrame = window.requestAnimationFrame(() => this._refresh());
|
||||
}
|
||||
|
||||
// If the refresh comes from a mouse event then emit a newselection event
|
||||
if (!fromMouseEvent) {
|
||||
return;
|
||||
}
|
||||
// TODO: Only do this when the selection has actually changed
|
||||
// TODO: Ensure we're not doing more work than absolutely necessary, particularly for large selections
|
||||
// TODO: Only do this on Linux
|
||||
const selectionText = this.selectionText;
|
||||
if (selectionText.length) {
|
||||
this.emit('newselection', this.selectionText);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -392,7 +405,7 @@ export class SelectionManager extends EventEmitter {
|
||||
}
|
||||
|
||||
this._addMouseDownListeners();
|
||||
this.refresh();
|
||||
this.refresh(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-1
@@ -703,7 +703,14 @@ Terminal.prototype.open = function(parent, focus) {
|
||||
this.viewport = new Viewport(this, this.viewportElement, this.viewportScrollArea, this.charMeasure);
|
||||
this.renderer = new Renderer(this);
|
||||
this.selectionManager = new SelectionManager(this, this.lines, this.rowContainer, this.charMeasure);
|
||||
this.selectionManager.on('refresh', data => this.renderer.refreshSelection(data.start, data.end));
|
||||
this.selectionManager.on('refresh', data => {
|
||||
this.renderer.refreshSelection(data.start, data.end);
|
||||
});
|
||||
this.selectionManager.on('newselection', text => {
|
||||
this.textarea.value = text;
|
||||
this.textarea.focus();
|
||||
this.textarea.select();
|
||||
});
|
||||
this.on('scroll', () => this.selectionManager.refresh());
|
||||
this.viewportElement.addEventListener('scroll', () => this.selectionManager.refresh());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user