reworked hotkey handling - fixes #4355, fixes #4326, fixes #4340

This commit is contained in:
Eugene Pankov
2021-08-06 09:03:55 +02:00
parent 533837f5b7
commit 7b59ba4b73
6 changed files with 221 additions and 207 deletions

View File

@@ -85,9 +85,9 @@ export class XTermFrontend extends Frontend {
this.xterm.unicode.activeVersion = '11'
const keyboardEventHandler = (name: string, event: KeyboardEvent) => {
this.hotkeysService.pushKeystroke(name, event)
this.hotkeysService.pushKeyEvent(name, event)
let ret = true
if (this.hotkeysService.getCurrentPartiallyMatchedHotkeys().length !== 0) {
if (this.hotkeysService.matchActiveHotkey(true) !== null) {
event.stopPropagation()
event.preventDefault()
ret = false

View File

@@ -100,15 +100,13 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/
events.forEach(event => {
const oldHandler = hterm.hterm.Keyboard.prototype[event.htermHandler]
hterm.hterm.Keyboard.prototype[event.htermHandler] = function (nativeEvent) {
hotkeys.pushKeystroke(event.name, nativeEvent)
if (hotkeys.getCurrentPartiallyMatchedHotkeys().length === 0) {
hotkeys.pushKeyEvent(event.name, nativeEvent)
if (hotkeys.matchActiveHotkey(true) !== null) {
oldHandler.bind(this)(nativeEvent)
} else {
nativeEvent.stopPropagation()
nativeEvent.preventDefault()
}
hotkeys.processKeystrokes()
hotkeys.emitKeyEvent(nativeEvent)
}
})
}