Add Setting for modifier Keys cmdIsMeta and altIsMeta (#686)

* Adds Setting for modifier Keys cmdIsMeta and altIsMeta

* ModifierKeys setting for redux state

* removing from default config modifierKeys
This commit is contained in:
Aurélien Bottazini 2016-09-30 14:30:11 +02:00 committed by Leo Lamprecht
parent 0c6f969b6c
commit a561f4650b
5 changed files with 32 additions and 3 deletions

View file

@ -61,6 +61,7 @@ export default class Term extends Component {
}
};
this.term.modifierKeys = props.modifierKeys;
// this.term.CursorNode_ is available at this point.
this.term.setCursorShape(props.cursorShape);
};

View file

@ -152,7 +152,8 @@ export default class Terms extends Component {
onURLAbort: this.bind(this.props.onURLAbort, null, uid),
bell: this.props.bell,
bellSoundURL: this.props.bellSoundURL,
copyOnSelect: this.props.copyOnSelect
copyOnSelect: this.props.copyOnSelect,
modifierKeys: this.props.modifierKeys
});
return (<div
key={`d${uid}`}

View file

@ -33,7 +33,8 @@ const TermsContainer = connect(
backgroundColor: state.ui.backgroundColor,
bell: state.ui.bell,
bellSoundURL: state.ui.bellSoundURL,
copyOnSelect: state.ui.copyOnSelect
copyOnSelect: state.ui.copyOnSelect,
modifierKeys: state.ui.modifierKeys
};
},
dispatch => {

View file

@ -102,6 +102,24 @@ hterm.Keyboard.prototype.onKeyDown_ = function (e) {
console.warn('Uncaught dead key on international keyboard', e);
}
const modifierKeysConf = this.terminal.modifierKeys;
if (e.altKey &&
e.code !== 'alt' &&
e.code !== 'altLeft' &&
e.code !== 'altRight' &&
modifierKeysConf.altIsMeta) {
this.terminal.onVTKeystroke('\x1b' + String.fromCharCode(e.keyCode));
e.preventDefault();
}
if (e.metaKey &&
e.code !== 'MetaLeft' &&
e.code !== 'MetaRight' &&
modifierKeysConf.cmdIsMeta) {
this.terminal.onVTKeystroke('\x1b' + String.fromCharCode(e.keyCode));
e.preventDefault();
}
if (e.metaKey || e.altKey || (e.ctrlKey && e.code === 'Tab')) {
return;
}

View file

@ -71,7 +71,11 @@ const initial = Immutable({
updateNotes: null,
bell: 'SOUND',
bellSoundURL: 'lib-resource:hterm/audio/bell',
copyOnSelect: false
copyOnSelect: false,
modifierKeys: {
altIsMeta: false,
cmdIsMeta: false
}
});
const reducer = (state = initial, action) => {
@ -157,6 +161,10 @@ const reducer = (state = initial, action) => {
}
}
if (config.modifierKeys !== null) {
ret.modifierKeys = config.modifierKeys;
}
return ret;
})());
break;