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
This commit is contained in:
CHaBou 2019-01-11 14:31:11 +01:00 committed by GitHub
parent 3136c64f4a
commit b709a3a971
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 8 deletions

View file

@ -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 // 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) // 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 // URL to custom bell
// bellSoundURL: 'http://example.com/bell.mp3', // bellSoundURL: 'http://example.com/bell.mp3',

View file

@ -93,6 +93,7 @@ class TermGroup_ extends React.PureComponent {
selectionColor: this.props.selectionColor, selectionColor: this.props.selectionColor,
quickEdit: this.props.quickEdit, quickEdit: this.props.quickEdit,
webGLRenderer: this.props.webGLRenderer, webGLRenderer: this.props.webGLRenderer,
macOptionSelectionMode: this.props.macOptionSelectionMode,
uid uid
}); });

View file

@ -36,6 +36,7 @@ const getTermOptions = props => {
lineHeight: props.lineHeight, lineHeight: props.lineHeight,
letterSpacing: props.letterSpacing, letterSpacing: props.letterSpacing,
allowTransparency: needTransparency, allowTransparency: needTransparency,
macOptionClickForcesSelection: props.macOptionSelectionMode === 'force',
// HACK: Terminal.setOption breaks if we don't apply these in this order // HACK: Terminal.setOption breaks if we don't apply these in this order
// TODO: The above notice can be removed once this is addressed: // TODO: The above notice can be removed once this is addressed:
// https://github.com/xtermjs/xterm.js/pull/1790#issuecomment-450000121 // https://github.com/xtermjs/xterm.js/pull/1790#issuecomment-450000121

View file

@ -117,6 +117,7 @@ export default class Terms extends React.Component {
onContextMenu: this.props.onContextMenu, onContextMenu: this.props.onContextMenu,
quickEdit: this.props.quickEdit, quickEdit: this.props.quickEdit,
webGLRenderer: this.props.webGLRenderer, webGLRenderer: this.props.webGLRenderer,
macOptionSelectionMode: this.props.macOptionSelectionMode,
parentProps: this.props parentProps: this.props
}); });

View file

@ -46,7 +46,8 @@ const TermsContainer = connect(
copyOnSelect: state.ui.copyOnSelect, copyOnSelect: state.ui.copyOnSelect,
modifierKeys: state.ui.modifierKeys, modifierKeys: state.ui.modifierKeys,
quickEdit: state.ui.quickEdit, quickEdit: state.ui.quickEdit,
webGLRenderer: state.ui.webGLRenderer webGLRenderer: state.ui.webGLRenderer,
macOptionSelectionMode: state.ui.macOptionSelectionMode
}; };
}, },
dispatch => { dispatch => {

View file

@ -97,7 +97,8 @@ const initial = Immutable({
showHamburgerMenu: '', showHamburgerMenu: '',
showWindowControls: '', showWindowControls: '',
quickEdit: false, quickEdit: false,
webGLRenderer: true webGLRenderer: true,
macOptionSelectionMode: 'vertical'
}); });
const currentWindow = remote.getCurrentWindow(); const currentWindow = remote.getCurrentWindow();
@ -242,6 +243,10 @@ const reducer = (state = initial, action) => {
ret.webGLRenderer = config.webGLRenderer; ret.webGLRenderer = config.webGLRenderer;
} }
if (config.macOptionSelectionMode) {
ret.macOptionSelectionMode = config.macOptionSelectionMode;
}
ret._lastUpdate = now; ret._lastUpdate = now;
return ret; return ret;

View file

@ -11,10 +11,8 @@
"test:unit": "ava test/unit", "test:unit": "ava test/unit",
"test:unit:watch": "yarn run test:unit -- --watch", "test:unit:watch": "yarn run test:unit -- --watch",
"prepush": "yarn test", "prepush": "yarn test",
"postinstall": "postinstall": "electron-builder install-app-deps && yarn run rebuild-node-pty",
"electron-builder install-app-deps && yarn run rebuild-node-pty", "rebuild-node-pty": "electron-rebuild -f -w app/node_modules/node-pty -m app",
"rebuild-node-pty":
"electron-rebuild -f -w app/node_modules/node-pty -m app",
"dist": "dist":
"yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build", "yarn run build && cross-env BABEL_ENV=production babel --out-file app/renderer/bundle.js --no-comments --minified app/renderer/bundle.js && build",
"clean": "clean":
@ -64,7 +62,7 @@
}, },
"overrides": [ "overrides": [
{ {
"files": "app/config/config-default.js", "files": ["app/config/config-default.js", ".hyper.js"],
"rules": { "rules": {
"prettier/prettier": [ "prettier/prettier": [
"error", "error",