Skip to content

Commit 5cb0480

Browse files
authored
Merge pull request #3181 from awmottaz/master
Make alt+click behavior configurable
2 parents 84fa6be + e3cccd6 commit 5cb0480

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

src/browser/public/Terminal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class Terminal implements ITerminalApi {
170170
this._core.paste(data);
171171
}
172172
public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
173-
public getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
173+
public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
174174
public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
175175
public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight;
176176
public getOption(key: string): any;
@@ -182,7 +182,7 @@ export class Terminal implements ITerminalApi {
182182
public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;
183183
public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
184184
public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
185-
public setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
185+
public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
186186
public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
187187
public setOption(key: 'theme', value: ITheme): void;
188188
public setOption(key: 'cols' | 'rows', value: number): void;

src/browser/services/SelectionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ export class SelectionService extends Disposable implements ISelectionService {
667667

668668
this._removeMouseDownListeners();
669669

670-
if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey) {
670+
if (this.selectionText.length <= 1 && timeElapsed < ALT_CLICK_MOVE_CURSOR_TIME && event.altKey && this._optionsService.getOption('altClickMovesCursor')) {
671671
if (this._bufferService.buffer.ybase === this._bufferService.buffer.ydisp) {
672672
const coordinates = this._mouseService.getCoords(
673673
event,

src/common/services/OptionsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
5050
windowOptions: {},
5151
windowsMode: false,
5252
wordSeparator: ' ()[]{}\',"`',
53-
53+
altClickMovesCursor: true,
5454
convertEol: false,
5555
termName: 'xterm',
5656
cancelEvents: false

src/common/services/Services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
184184
export type RendererType = 'dom' | 'canvas';
185185

186186
export interface IPartialTerminalOptions {
187+
altClickMovesCursor?: boolean;
187188
allowTransparency?: boolean;
188189
bellSound?: string;
189190
bellStyle?: 'none' | 'sound' /* | 'visual' | 'both' */;
@@ -220,6 +221,7 @@ export interface IPartialTerminalOptions {
220221
export interface ITerminalOptions {
221222
allowProposedApi: boolean;
222223
allowTransparency: boolean;
224+
altClickMovesCursor: boolean;
223225
bellSound: string;
224226
bellStyle: 'none' | 'sound' /* | 'visual' | 'both' */;
225227
cols: number;

typings/xterm.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ declare module 'xterm' {
4444
*/
4545
allowTransparency?: boolean;
4646

47+
/**
48+
* If enabled, alt + click will move the prompt cursor to position
49+
* underneath the mouse. The default is true.
50+
*/
51+
altClickMovesCursor?: boolean;
52+
4753
/**
4854
* A data uri of the sound to use for the bell when `bellStyle = 'sound'`.
4955
*/

0 commit comments

Comments
 (0)