From 04e2bdd6ec6a80846322464243067bde2d0fc240 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Fri, 20 Nov 2020 19:50:03 -0600 Subject: [PATCH 1/5] 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 81e72087..6caca2a0 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 6c43c303..b7a1c58e 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 0ea7a308..9845fdc4 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 b5a736a7..795dd2c6 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'`. */ From f68ff2a455f3618d638baf25503c8c932e291506 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:00:02 -0600 Subject: [PATCH 2/5] Check for alt+click option sooner --- src/browser/services/SelectionService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/services/SelectionService.ts b/src/browser/services/SelectionService.ts index 6caca2a0..a3d8d12c 100644 --- a/src/browser/services/SelectionService.ts +++ b/src/browser/services/SelectionService.ts @@ -667,7 +667,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._removeMouseDownListeners(); - if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey) { + if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.getOption('altClickMovesCursor')) { if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) { const coordinates = this._mouseService.getCoords( event, @@ -676,7 +676,7 @@ export class SelectionService extends Disposable implements ISelectionService { this._bufferService.rows, false ); - if (this._optionsService.getOption('altClickMovesCursor') && coordinates && coordinates[0] !== undefined && coordinates[1] !== undefined) { + if (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); } From 78ddb9febaac00bddd5c0953c15a6534d619a833 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:00:41 -0600 Subject: [PATCH 3/5] Add 'altClickMovesCursor' option to getOption/setOption in Terminal --- src/browser/public/Terminal.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/public/Terminal.ts b/src/browser/public/Terminal.ts index 33aa9024..64c65fe9 100644 --- a/src/browser/public/Terminal.ts +++ b/src/browser/public/Terminal.ts @@ -170,7 +170,7 @@ export class Terminal implements ITerminalApi { this._core.paste(data); } public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; + public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight; public getOption(key: string): any; @@ -182,7 +182,7 @@ export class Terminal implements ITerminalApi { public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - public setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; + public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; public setOption(key: 'theme', value: ITheme): void; public setOption(key: 'cols' | 'rows', value: number): void; From 88f0b91056adc444bd1197d42c2bfdc112d4c1b2 Mon Sep 17 00:00:00 2001 From: Tony Mottaz Date: Sun, 22 Nov 2020 10:01:02 -0600 Subject: [PATCH 4/5] add altClickMovesCursor option to Services type --- src/common/services/Services.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 9845fdc4..c733e73e 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -184,6 +184,7 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; export type RendererType = 'dom' | 'canvas'; export interface IPartialTerminalOptions { + altClickMovesCursor?: boolean; allowTransparency?: boolean; bellSound?: string; bellStyle?: 'none' | 'sound' /* | 'visual' | 'both' */; From e3cccd619b541bf7ce88e65a9c3d10a7fca0af58 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 24 Nov 2020 09:03:59 -0800 Subject: [PATCH 5/5] Update typings/xterm.d.ts --- typings/xterm.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 795dd2c6..d860ddfa 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -45,7 +45,8 @@ declare module 'xterm' { allowTransparency?: boolean; /** - * If enabled, alt + click will move the prompt cursor to position underneath the mouse. + * If enabled, alt + click will move the prompt cursor to position + * underneath the mouse. The default is true. */ altClickMovesCursor?: boolean;