fixed alt-arrow keys on Mac as well as Home and End combinations (fixes #255)

This commit is contained in:
Eugene Pankov 2018-01-24 16:40:30 +01:00
parent b007ff6ff6
commit 132d0553ae
4 changed files with 80 additions and 18 deletions

View file

@ -5,7 +5,7 @@ export const metaKeyName = {
}[process.platform]
export const altKeyName = {
darwin: 'Option',
darwin: '',
win32: 'Alt',
linux: 'Alt',
}[process.platform]

View file

@ -88,20 +88,40 @@ export class TerminalTabComponent extends BaseTabComponent {
if (!this.hasFocus) {
return
}
if (hotkey === 'copy') {
this.hterm.copySelectionToClipboard()
}
if (hotkey === 'clear') {
this.clear()
}
if (hotkey === 'zoom-in') {
this.zoomIn()
}
if (hotkey === 'zoom-out') {
this.zoomOut()
}
if (hotkey === 'reset-zoom') {
this.resetZoom()
switch (hotkey) {
case 'copy':
this.hterm.copySelectionToClipboard()
break
case 'clear':
this.clear()
break
case 'zoom-in':
this.zoomIn()
break
case 'zoom-out':
this.zoomOut()
break
case 'reset-zoom':
this.resetZoom()
break
case 'home':
this.sendInput('\x1bOH')
break
case 'end':
this.sendInput('\x1bOF')
break
case 'previous-word':
this.sendInput('\x1bb')
break
case 'next-word':
this.sendInput('\x1bf')
break
case 'delete-previous-word':
this.sendInput('\x1b\x7f')
break
case 'delete-next-word':
this.sendInput('\x1bd')
break
}
})
this.bellPlayer = document.createElement('audio')

View file

@ -75,7 +75,13 @@ export class TerminalConfigProvider extends ConfigProvider {
['Ctrl-A', 'Ctrl-C'],
'⌘-T',
'⌘-N',
]
],
'home': ['⌘-ArrowLeft', 'Home'],
'end': ['⌘-ArrowRight', 'End'],
'previous-word': ['⌥-ArrowLeft'],
'next-word': ['⌥-ArrowRight'],
'delete-previous-word': ['⌥-Backspace'],
'delete-next-word': ['⌥-Delete'],
},
},
[Platform.Windows]: {
@ -108,7 +114,13 @@ export class TerminalConfigProvider extends ConfigProvider {
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Ctrl-Shift-T',
]
],
'home': ['Home'],
'end': ['End'],
'previous-word': ['Ctrl-ArrowLeft'],
'next-word': ['Ctrl-ArrowRight'],
'delete-previous-word': ['Ctrl-Backspace'],
'delete-next-word': ['Ctrl-Delete'],
},
},
[Platform.Linux]: {
@ -139,7 +151,13 @@ export class TerminalConfigProvider extends ConfigProvider {
['Ctrl-A', 'C'],
['Ctrl-A', 'Ctrl-C'],
'Ctrl-Shift-T',
]
],
'home': ['Home'],
'end': ['End'],
'previous-word': ['Ctrl-ArrowLeft'],
'next-word': ['Ctrl-ArrowRight'],
'delete-previous-word': ['Ctrl-Backspace'],
'delete-next-word': ['Ctrl-Delete'],
},
},
}

View file

@ -8,6 +8,30 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
id: 'copy',
name: 'Copy to clipboard',
},
{
id: 'home',
name: 'Beginning of the line',
},
{
id: 'end',
name: 'End of the line',
},
{
id: 'previous-word',
name: 'Jump to previous word',
},
{
id: 'next-word',
name: 'Jump to next word',
},
{
id: 'delete-previous-word',
name: 'Delete previous word',
},
{
id: 'delete-next-word',
name: 'Delete next word',
},
{
id: 'clear',
name: 'Clear terminal',