Hook up vt extensions option

This commit is contained in:
Daniel Imms
2026-01-09 07:07:10 -08:00
parent 3fbaef06ef
commit 992da3cc4d
7 changed files with 66 additions and 10 deletions
+4 -2
View File
@@ -1087,7 +1087,8 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
// Use Kitty keyboard protocol if enabled, otherwise use legacy encoding
const kittyFlags = this.coreService.kittyKeyboard.flags;
const result = shouldUseKittyProtocol(kittyFlags)
const useKitty = this.options.vtExtensions?.kittyKeyboard && shouldUseKittyProtocol(kittyFlags);
const result = useKitty
? evaluateKeyboardEventKitty(event, kittyFlags, event.repeat ? KittyKeyboardEventType.REPEAT : KittyKeyboardEventType.PRESS)
: evaluateKeyboardEvent(event, this.coreService.decPrivateModes.applicationCursorKeys, this.browser.isMac, this.options.macOptionIsMeta);
@@ -1178,7 +1179,8 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
// Handle key release for Kitty keyboard protocol
const kittyFlags = this.coreService.kittyKeyboard.flags;
if (shouldUseKittyProtocol(kittyFlags) && (kittyFlags & 0b10)) { // REPORT_EVENT_TYPES flag
const useKitty = this.options.vtExtensions?.kittyKeyboard && shouldUseKittyProtocol(kittyFlags);
if (useKitty && (kittyFlags & 0b10)) { // REPORT_EVENT_TYPES flag
const result = evaluateKeyboardEventKitty(ev, kittyFlags, KittyKeyboardEventType.RELEASE);
if (result.key) {
this.coreService.triggerDataEvent(result.key, true);
+12
View File
@@ -2992,6 +2992,9 @@ export class InputHandler extends Disposable implements IInputHandler {
* @vt: #Y CSI KKBDSET "Kitty Keyboard Set" "CSI = Ps ; Pm u" "Set Kitty keyboard protocol flags."
*/
public kittyKeyboardSet(params: IParams): boolean {
if (!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard) {
return true;
}
const flags = params.params[0] || 0;
const mode = params.params[1] || 1;
const state = this._coreService.kittyKeyboard;
@@ -3018,6 +3021,9 @@ export class InputHandler extends Disposable implements IInputHandler {
* @vt: #Y CSI KKBDQUERY "Kitty Keyboard Query" "CSI ? u" "Query Kitty keyboard protocol flags."
*/
public kittyKeyboardQuery(params: IParams): boolean {
if (!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard) {
return true;
}
const flags = this._coreService.kittyKeyboard.flags;
this._coreService.triggerDataEvent(`${C0.ESC}[?${flags}u`);
return true;
@@ -3030,6 +3036,9 @@ export class InputHandler extends Disposable implements IInputHandler {
* @vt: #Y CSI KKBDPUSH "Kitty Keyboard Push" "CSI > Ps u" "Push keyboard flags to stack and set new flags."
*/
public kittyKeyboardPush(params: IParams): boolean {
if (!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard) {
return true;
}
const flags = params.params[0] || 0;
const state = this._coreService.kittyKeyboard;
const isAlt = this._bufferService.buffer === this._bufferService.buffers.alt;
@@ -3048,6 +3057,9 @@ export class InputHandler extends Disposable implements IInputHandler {
* @vt: #Y CSI KKBDPOP "Kitty Keyboard Pop" "CSI < Ps u" "Pop keyboard flags from stack."
*/
public kittyKeyboardPop(params: IParams): boolean {
if (!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard) {
return true;
}
const count = Math.max(1, params.params[0] || 1);
const state = this._coreService.kittyKeyboard;
const isAlt = this._bufferService.buffer === this._bufferService.buffers.alt;
+2 -1
View File
@@ -54,7 +54,8 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
termName: 'xterm',
cancelEvents: false,
overviewRuler: {},
quirks: {}
quirks: {},
vtExtensions: {}
};
const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
+5
View File
@@ -266,6 +266,7 @@ export interface ITerminalOptions {
overviewRuler?: IOverviewRulerOptions;
quirks?: ITerminalQuirks;
scrollOnEraseInDisplay?: boolean;
vtExtensions?: IVtExtensions;
[key: string]: any;
cancelEvents: boolean;
@@ -307,6 +308,10 @@ export interface ITerminalQuirks {
allowSetCursorBlink?: boolean;
}
export interface IVtExtensions {
kittyKeyboard?: boolean;
}
export const IOscLinkService = createDecorator<IOscLinkService>('OscLinkService');
export interface IOscLinkService {
serviceBrand: undefined;