terminal: convert dcs

pull/9342/head
Mitchell Hashimoto 2025-10-23 21:29:16 -07:00
parent 6902d89d91
commit 109376115b
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 20 additions and 9 deletions

View File

@ -127,6 +127,14 @@ pub const Action = union(enum) {
intermediates: []const u8 = "", intermediates: []const u8 = "",
params: []const u16 = &.{}, params: []const u16 = &.{},
final: u8, final: u8,
pub const C = extern struct {
intermediates: [*]const u8,
intermediates_len: usize,
params: [*]const u16,
params_len: usize,
final: u8,
};
}; };
// Implement formatter for logging. This is mostly copied from the // Implement formatter for logging. This is mostly copied from the

View File

@ -99,6 +99,9 @@ pub const Action = union(Key) {
kitty_keyboard_set: KittyKeyboardFlags, kitty_keyboard_set: KittyKeyboardFlags,
kitty_keyboard_set_or: KittyKeyboardFlags, kitty_keyboard_set_or: KittyKeyboardFlags,
kitty_keyboard_set_not: KittyKeyboardFlags, kitty_keyboard_set_not: KittyKeyboardFlags,
dcs_hook: Parser.Action.DCS,
dcs_put: u8,
dcs_unhook,
apc_start, apc_start,
apc_end, apc_end,
apc_put: u8, apc_put: u8,
@ -180,6 +183,9 @@ pub const Action = union(Key) {
"kitty_keyboard_set", "kitty_keyboard_set",
"kitty_keyboard_set_or", "kitty_keyboard_set_or",
"kitty_keyboard_set_not", "kitty_keyboard_set_not",
"dcs_hook",
"dcs_put",
"dcs_unhook",
"apc_start", "apc_start",
"apc_end", "apc_end",
"apc_put", "apc_put",
@ -556,15 +562,9 @@ pub fn Stream(comptime Handler: type) type {
.csi_dispatch => |csi_action| try self.csiDispatch(csi_action), .csi_dispatch => |csi_action| try self.csiDispatch(csi_action),
.esc_dispatch => |esc| try self.escDispatch(esc), .esc_dispatch => |esc| try self.escDispatch(esc),
.osc_dispatch => |cmd| try self.oscDispatch(cmd), .osc_dispatch => |cmd| try self.oscDispatch(cmd),
.dcs_hook => |dcs| if (@hasDecl(T, "dcsHook")) { .dcs_hook => |dcs| try self.handler.vt(.dcs_hook, dcs),
try self.handler.dcsHook(dcs); .dcs_put => |code| try self.handler.vt(.dcs_put, code),
} else log.warn("unimplemented DCS hook", .{}), .dcs_unhook => try self.handler.vt(.dcs_unhook, {}),
.dcs_put => |code| if (@hasDecl(T, "dcsPut")) {
try self.handler.dcsPut(code);
} else log.warn("unimplemented DCS put: {x}", .{code}),
.dcs_unhook => if (@hasDecl(T, "dcsUnhook")) {
try self.handler.dcsUnhook();
} else log.warn("unimplemented DCS unhook", .{}),
.apc_start => try self.handler.vt(.apc_start, {}), .apc_start => try self.handler.vt(.apc_start, {}),
.apc_put => |code| try self.handler.vt(.apc_put, code), .apc_put => |code| try self.handler.vt(.apc_put, code),
.apc_end => try self.handler.vt(.apc_end, {}), .apc_end => try self.handler.vt(.apc_end, {}),

View File

@ -303,6 +303,9 @@ pub const StreamHandler = struct {
.end_hyperlink => try self.endHyperlink(), .end_hyperlink => try self.endHyperlink(),
.active_status_display => self.terminal.status_display = value, .active_status_display => self.terminal.status_display = value,
.decaln => try self.decaln(), .decaln => try self.decaln(),
.dcs_hook => try self.dcsHook(value),
.dcs_put => try self.dcsPut(value),
.dcs_unhook => try self.dcsUnhook(),
.apc_start => self.apc.start(), .apc_start => self.apc.start(),
.apc_end => try self.apcEnd(), .apc_end => try self.apcEnd(),
.apc_put => self.apc.feed(self.alloc, value), .apc_put => self.apc.feed(self.alloc, value),