From 04e2bdd6ec6a80846322464243067bde2d0fc240 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Fri, 20 Nov 2020 19:50:03 -0600 Subject: [PATCH] Make alt+click behavior configurable --- src/browser/services/SelectionService.ts | 2 +- src/common/services/OptionsService.ts | 2 +- src/common/services/Services.ts | 1 + typings/xterm.d.ts | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 81e720871..6caca2a08 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -676,7 +676,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._bufferService.rows, false ); - if (coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { + if (this._optionsService.getOption('altClickMovesCursor') && coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { const sequence = moveToCellSequence(coordinates[0] - 1, coordinates[1] - 1, this._bufferService, this._coreService.decPrivateModes.applicationCursorKeys); this._coreService.triggerDataEvent(sequence, true); } diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 6c43c3038..b7a1c58e0 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -50,7 +50,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ windowOptions: {}, windowsMode: false, wordSeparator: ' ()[]{}\',"`', - + altClickMovesCursor: true, convertEol: false, termName: 'xterm', cancelEvents: false diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 0ea7a3080..9845fdc4a 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -220,6 +220,7 @@ export interface IPartialTerminalOptions { export interface ITerminalOptions { allowProposedApi: boolean; allowTransparency: boolean; + altClickMovesCursor: boolean; bellSound: string; bellStyle: 'none' | 'sound' /* | 'visual' | 'both' */; cols: number; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index b5a736a77..795dd2c6b 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -44,6 +44,11 @@ declare module 'xterm' { */ allowTransparency?: boolean; + /** + * If enabled, alt + click will move the prompt cursor to position underneath the mouse. + */ + altClickMovesCursor?: boolean; + /** * A data uri of the sound to use for the bell when `bellStyle = 'sound'`. */