Allow selection and alt click to live conflict free
This commit is contained in:
+10
-1
@@ -11,6 +11,7 @@ import { CircularList } from './utils/CircularList';
|
|||||||
import { EventEmitter } from './EventEmitter';
|
import { EventEmitter } from './EventEmitter';
|
||||||
import { SelectionModel } from './SelectionModel';
|
import { SelectionModel } from './SelectionModel';
|
||||||
import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './Buffer';
|
import { CHAR_DATA_WIDTH_INDEX, CHAR_DATA_CHAR_INDEX } from './Buffer';
|
||||||
|
import { AltClickHandler } from './handlers/AltClickHandler';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of pixels the mouse needs to be above or below the viewport in
|
* The number of pixels the mouse needs to be above or below the viewport in
|
||||||
@@ -96,6 +97,8 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
private _mouseUpListener: EventListener;
|
private _mouseUpListener: EventListener;
|
||||||
private _trimListener: (...args: any[]) => void;
|
private _trimListener: (...args: any[]) => void;
|
||||||
|
|
||||||
|
private _mouseDownTimeStamp: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _terminal: ITerminal,
|
private _terminal: ITerminal,
|
||||||
private _charMeasure: CharMeasure
|
private _charMeasure: CharMeasure
|
||||||
@@ -317,6 +320,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
* @param event The mousedown event.
|
* @param event The mousedown event.
|
||||||
*/
|
*/
|
||||||
public onMouseDown(event: MouseEvent): void {
|
public onMouseDown(event: MouseEvent): void {
|
||||||
|
this._mouseDownTimeStamp = event.timeStamp;
|
||||||
// If we have selection, we want the context menu on right click even if the
|
// If we have selection, we want the context menu on right click even if the
|
||||||
// terminal is in mouse mode.
|
// terminal is in mouse mode.
|
||||||
if (event.button === 2 && this.hasSelection) {
|
if (event.button === 2 && this.hasSelection) {
|
||||||
@@ -536,10 +540,15 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
* @param event The mouseup event.
|
* @param event The mouseup event.
|
||||||
*/
|
*/
|
||||||
private _onMouseUp(event: MouseEvent): void {
|
private _onMouseUp(event: MouseEvent): void {
|
||||||
|
let timeElapsed = event.timeStamp - this._mouseDownTimeStamp;
|
||||||
|
|
||||||
this._removeMouseDownListeners();
|
this._removeMouseDownListeners();
|
||||||
|
|
||||||
if (this.hasSelection)
|
if (this.selectionText.length <= 1 && timeElapsed < 500) {
|
||||||
|
(new AltClickHandler(event, this._terminal)).move();
|
||||||
|
} else if (this.hasSelection) {
|
||||||
this._terminal.emit('selection');
|
this._terminal.emit('selection');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
|
private _onBufferActivate(e: {activeBuffer: IBuffer, inactiveBuffer: IBuffer}): void {
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import { CompositionHelper } from './CompositionHelper';
|
|||||||
import { EventEmitter } from './EventEmitter';
|
import { EventEmitter } from './EventEmitter';
|
||||||
import { Viewport } from './Viewport';
|
import { Viewport } from './Viewport';
|
||||||
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './handlers/Clipboard';
|
import { rightClickHandler, moveTextAreaUnderMouseCursor, pasteHandler, copyHandler } from './handlers/Clipboard';
|
||||||
import { AltClickHandler } from './handlers/AltClickHandler';
|
|
||||||
import { CircularList } from './utils/CircularList';
|
import { CircularList } from './utils/CircularList';
|
||||||
import { C0 } from './EscapeSequences';
|
import { C0 } from './EscapeSequences';
|
||||||
import { InputHandler } from './InputHandler';
|
import { InputHandler } from './InputHandler';
|
||||||
@@ -953,7 +952,6 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
// if the selection manager is having selection forced (ie. a modifier is
|
// if the selection manager is having selection forced (ie. a modifier is
|
||||||
// held).
|
// held).
|
||||||
if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) {
|
if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) {
|
||||||
(new AltClickHandler(ev, this)).move();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user