From b709a3a971c513d86c572c394063a390ee595c81 Mon Sep 17 00:00:00 2001 From: CHaBou Date: Fri, 11 Jan 2019 14:31:11 +0100 Subject: [PATCH] Add macOptionSelectionMode option (#3406) Two possible value: * `'vertical'` (Default): enable column selection when Option key is hold * `'force'`: force selection regardless of whether the terminal is in mouse events mode --- app/config/config-default.js | 7 ++++++- lib/components/term-group.js | 1 + lib/components/term.js | 1 + lib/components/terms.js | 1 + lib/containers/terms.js | 3 ++- lib/reducers/ui.js | 7 ++++++- package.json | 8 +++----- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/config/config-default.js b/app/config/config-default.js index 9badfb52..67429815 100644 --- a/app/config/config-default.js +++ b/app/config/config-default.js @@ -123,7 +123,12 @@ module.exports = { // if `true` (without backticks and without quotes), on right click selected text will be copied or pasted if no // selection is present (`true` by default on Windows and disables the context menu feature) - // quickEdit: true, + quickEdit: false, + + // choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default) + // or `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode + // (inside tmux or vim with mouse mode enabled for example). + macOptionSelectionMode: 'vertical', // URL to custom bell // bellSoundURL: 'http://example.com/bell.mp3', diff --git a/lib/components/term-group.js b/lib/components/term-group.js index 319c2ded..b588eef2 100644 --- a/lib/components/term-group.js +++ b/lib/components/term-group.js @@ -93,6 +93,7 @@ class TermGroup_ extends React.PureComponent { selectionColor: this.props.selectionColor, quickEdit: this.props.quickEdit, webGLRenderer: this.props.webGLRenderer, + macOptionSelectionMode: this.props.macOptionSelectionMode, uid }); diff --git a/lib/components/term.js b/lib/components/term.js index 16cd1fb4..e678a4f2 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -36,6 +36,7 @@ const getTermOptions = props => { lineHeight: props.lineHeight, letterSpacing: props.letterSpacing, allowTransparency: needTransparency, + macOptionClickForcesSelection: props.macOptionSelectionMode === 'force', // HACK: Terminal.setOption breaks if we don't apply these in this order // TODO: The above notice can be removed once this is addressed: // https://github.com/xtermjs/xterm.js/pull/1790#issuecomment-450000121 diff --git a/lib/components/terms.js b/lib/components/terms.js index 88921b7a..45b800db 100644 --- a/lib/components/terms.js +++ b/lib/components/terms.js @@ -117,6 +117,7 @@ export default class Terms extends React.Component { onContextMenu: this.props.onContextMenu, quickEdit: this.props.quickEdit, webGLRenderer: this.props.webGLRenderer, + macOptionSelectionMode: this.props.macOptionSelectionMode, parentProps: this.props }); diff --git a/lib/containers/terms.js b/lib/containers/terms.js index 24a83cd3..1bf590bb 100644 --- a/lib/containers/terms.js +++ b/lib/containers/terms.js @@ -46,7 +46,8 @@ const TermsContainer = connect( copyOnSelect: state.ui.copyOnSelect, modifierKeys: state.ui.modifierKeys, quickEdit: state.ui.quickEdit, - webGLRenderer: state.ui.webGLRenderer + webGLRenderer: state.ui.webGLRenderer, + macOptionSelectionMode: state.ui.macOptionSelectionMode }; }, dispatch => { diff --git a/lib/reducers/ui.js b/lib/reducers/ui.js index ac1363b3..b70fffa8 100644 --- a/lib/reducers/ui.js +++ b/lib/reducers/ui.js @@ -97,7 +97,8 @@ const initial = Immutable({ showHamburgerMenu: '', showWindowControls: '', quickEdit: false, - webGLRenderer: true + webGLRenderer: true, + macOptionSelectionMode: 'vertical' }); const currentWindow = remote.getCurrentWindow(); @@ -242,6 +243,10 @@ const reducer = (state = initial, action) => { ret.webGLRenderer = config.webGLRenderer; } + if (config.macOptionSelectionMode) { + ret.macOptionSelectionMode = config.macOptionSelectionMode; + } + ret._lastUpdate = now; return ret; diff --git a/package.json b/package.json index 7ec704bf..c644e627 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,8 @@ "test:unit": "ava test/unit", "test:unit:watch": "yarn run test:unit -- --watch", "prepush": "yarn test", - "postinstall": - "electron-builder install-app-deps && yarn run rebuild-node-pty", - "rebuild-node-pty": - "electron-rebuild -f -w app/node_modules/node-pty -m app", + "postinstall": "electron-builder install-app-deps && yarn run rebuild-node-pty", + "rebuild-node-pty": "electron-rebuild -f -w app/node_modules/node-pty -m app", "dist": "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", "clean": @@ -64,7 +62,7 @@ }, "overrides": [ { - "files": "app/config/config-default.js", + "files": ["app/config/config-default.js", ".hyper.js"], "rules": { "prettier/prettier": [ "error",