diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 4f86c6de..c11f49c6 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -376,7 +376,11 @@ export class SelectionManager extends EventEmitter implements ISelectionManager * @param event The mouse event. */ public shouldForceSelection(event: MouseEvent): boolean { - return Browser.isMac ? event.altKey : event.shiftKey; + if (Browser.isMac) { + return event.altKey && this._terminal.options.macOptionClickForcesSelection; + } + + return event.shiftKey; } /** diff --git a/src/Terminal.ts b/src/Terminal.ts index b754b6f6..e2fa8bef 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -98,6 +98,7 @@ const DEFAULT_OPTIONS: ITerminalOptions = { screenReaderMode: false, debug: false, macOptionIsMeta: false, + macOptionClickForcesSelection: false, cancelEvents: false, disableStdin: false, useFlowControl: false, diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index bda984b7..94fa0432 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -124,6 +124,15 @@ declare module 'xterm' { */ macOptionIsMeta?: boolean; + /** + * Whether holding a modifier key will force normal selection behavior, + * regardless of whether the terminal is in mouse events mode. This will + * also prevent mouse events from being emitted by the terminal. For example, + * this allows you to use xterm.js' regular selection inside tmux with + * mouse mode enabled. + */ + macOptionClickForcesSelection?: boolean; + /** * (EXPERIMENTAL) The type of renderer to use, this allows using the * fallback DOM renderer when canvas is too slow for the environment. The @@ -562,7 +571,7 @@ declare module 'xterm' { * Retrieves an option's value from the terminal. * @param key The option key. */ - getOption(key: 'colors'): string[]; + getOption(key: 'columnSelectModifiers' | 'colors'): string[]; /** * Retrieves an option's value from the terminal. * @param key The option key.