mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-24 14:14:24 +03:00
fixed xterm hotkeys - fixed #696
This commit is contained in:
parent
3a522f4f73
commit
89e4a80a37
@ -1,6 +1,6 @@
|
||||
import { Observable, Subject, AsyncSubject, ReplaySubject, BehaviorSubject } from 'rxjs'
|
||||
import { ResizeEvent } from '../api'
|
||||
import { ConfigService, ThemesService } from 'terminus-core'
|
||||
import { ConfigService, ThemesService, HotkeysService } from 'terminus-core'
|
||||
|
||||
/**
|
||||
* Extend to add support for a different VT frontend implementation
|
||||
@ -8,6 +8,7 @@ import { ConfigService, ThemesService } from 'terminus-core'
|
||||
export abstract class Frontend {
|
||||
configService: ConfigService
|
||||
themesService: ThemesService
|
||||
hotkeysService: HotkeysService
|
||||
|
||||
enableResizing = true
|
||||
protected ready = new AsyncSubject<void>()
|
||||
|
@ -42,6 +42,21 @@ export class XTermFrontend extends Frontend {
|
||||
this.copySelection()
|
||||
}
|
||||
})
|
||||
|
||||
const keyboardEventHandler = (name: string, event: KeyboardEvent) => {
|
||||
this.hotkeysService.pushKeystroke(name, event)
|
||||
let ret = true
|
||||
if (this.hotkeysService.getCurrentPartiallyMatchedHotkeys().length !== 0) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
ret = false
|
||||
}
|
||||
this.hotkeysService.processKeystrokes()
|
||||
this.hotkeysService.emitKeyEvent(event)
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
this.xterm.attachCustomKeyEventHandler((event: KeyboardEvent) => {
|
||||
if ((event.getModifierState('Control') || event.getModifierState('Meta')) && event.key.toLowerCase() === 'v') {
|
||||
event.preventDefault()
|
||||
@ -50,7 +65,8 @@ export class XTermFrontend extends Frontend {
|
||||
if (event.getModifierState('Meta') && event.key.startsWith('Arrow')) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
return keyboardEventHandler('keydown', event)
|
||||
})
|
||||
|
||||
this.xtermCore._scrollToBottom = this.xtermCore.scrollToBottom.bind(this.xtermCore)
|
||||
@ -63,6 +79,11 @@ export class XTermFrontend extends Frontend {
|
||||
// tends to throw when element wasn't shown yet
|
||||
}
|
||||
}
|
||||
|
||||
this.xtermCore._keyUp = (e: KeyboardEvent) => {
|
||||
this.xtermCore.updateCursorStyle(e)
|
||||
keyboardEventHandler('keyup', e)
|
||||
}
|
||||
}
|
||||
|
||||
attach (host: HTMLElement): void {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ConfigService, ThemesService } from 'terminus-core'
|
||||
import { ConfigService, ThemesService, HotkeysService } from 'terminus-core'
|
||||
import { Frontend } from '../frontends/frontend'
|
||||
import { HTermFrontend } from '../frontends/htermFrontend'
|
||||
import { XTermFrontend } from '../frontends/xtermFrontend'
|
||||
@ -10,7 +10,11 @@ export class TerminalFrontendService {
|
||||
private containers = new WeakMap<BaseSession, Frontend>()
|
||||
|
||||
/** @hidden */
|
||||
constructor (private config: ConfigService, private themes: ThemesService) { }
|
||||
constructor (
|
||||
private config: ConfigService,
|
||||
private themes: ThemesService,
|
||||
private hotkeys: HotkeysService,
|
||||
) { }
|
||||
|
||||
getFrontend (session?: BaseSession): Frontend {
|
||||
if (!session) {
|
||||
@ -19,6 +23,7 @@ export class TerminalFrontendService {
|
||||
: new HTermFrontend()
|
||||
frontend.configService = this.config
|
||||
frontend.themesService = this.themes
|
||||
frontend.hotkeysService = this.hotkeys
|
||||
return frontend
|
||||
}
|
||||
if (!this.containers.has(session)) {
|
||||
|
Loading…
Reference in New Issue
Block a user