55
66import { IKeyboardService } from 'browser/services/Services' ;
77import { evaluateKeyboardEvent } from 'common/input/Keyboard' ;
8- import { evaluateKeyboardEventKitty , KittyKeyboardEventType , KittyKeyboardFlags , shouldUseKittyProtocol } from 'common/input/KittyKeyboard' ;
8+ import { KittyKeyboard , KittyKeyboardEventType , KittyKeyboardFlags } from 'common/input/KittyKeyboard' ;
99import { Win32InputMode } from 'common/input/Win32InputMode' ;
1010import { isMac } from 'common/Platform' ;
1111import { ICoreService , IOptionsService } from 'common/services/Services' ;
@@ -15,6 +15,7 @@ export class KeyboardService implements IKeyboardService {
1515 public serviceBrand : undefined ;
1616
1717 private _win32InputMode : Win32InputMode | undefined ;
18+ private _kittyKeyboard : KittyKeyboard | undefined ;
1819
1920 constructor (
2021 @ICoreService private readonly _coreService : ICoreService ,
@@ -29,14 +30,21 @@ export class KeyboardService implements IKeyboardService {
2930 return this . _win32InputMode ;
3031 }
3132
33+ private _getKittyKeyboard ( ) : KittyKeyboard {
34+ if ( ! this . _kittyKeyboard ) {
35+ this . _kittyKeyboard = new KittyKeyboard ( ) ;
36+ }
37+ return this . _kittyKeyboard ;
38+ }
39+
3240 public evaluateKeyDown ( event : KeyboardEvent ) : IKeyboardResult {
3341 // Win32 input mode takes priority (most raw)
3442 if ( this . useWin32InputMode ) {
3543 return this . _getWin32InputMode ( ) . evaluateKeyboardEvent ( event , true ) ;
3644 }
3745 const kittyFlags = this . _coreService . kittyKeyboard . flags ;
3846 return this . useKitty
39- ? evaluateKeyboardEventKitty ( event , kittyFlags , event . repeat ? KittyKeyboardEventType . REPEAT : KittyKeyboardEventType . PRESS )
47+ ? this . _getKittyKeyboard ( ) . evaluate ( event , kittyFlags , event . repeat ? KittyKeyboardEventType . REPEAT : KittyKeyboardEventType . PRESS )
4048 : evaluateKeyboardEvent ( event , this . _coreService . decPrivateModes . applicationCursorKeys , isMac , this . _optionsService . rawOptions . macOptionIsMeta ) ;
4149 }
4250
@@ -47,14 +55,14 @@ export class KeyboardService implements IKeyboardService {
4755 }
4856 const kittyFlags = this . _coreService . kittyKeyboard . flags ;
4957 if ( this . useKitty && ( kittyFlags & KittyKeyboardFlags . REPORT_EVENT_TYPES ) ) {
50- return evaluateKeyboardEventKitty ( event , kittyFlags , KittyKeyboardEventType . RELEASE ) ;
58+ return this . _getKittyKeyboard ( ) . evaluate ( event , kittyFlags , KittyKeyboardEventType . RELEASE ) ;
5159 }
5260 return undefined ;
5361 }
5462
5563 public get useKitty ( ) : boolean {
5664 const kittyFlags = this . _coreService . kittyKeyboard . flags ;
57- return ! ! ( this . _optionsService . rawOptions . vtExtensions ?. kittyKeyboard && shouldUseKittyProtocol ( kittyFlags ) ) ;
65+ return ! ! ( this . _optionsService . rawOptions . vtExtensions ?. kittyKeyboard && KittyKeyboard . shouldUseProtocol ( kittyFlags ) ) ;
5866 }
5967
6068 public get useWin32InputMode ( ) : boolean {
0 commit comments