core: use Kitty encoding if enabled

This commit is contained in:
Mitchell Hashimoto
2023-08-17 09:02:43 -07:00
parent fb9dc74b29
commit 37daf02804
2 changed files with 13 additions and 3 deletions

View File

@@ -24,8 +24,17 @@ keypad_key_application: bool = false,
modify_other_keys_state_2: bool = false,
kitty_flags: KittyFlags = .{},
/// Perform the proper encoding depending on the terminal state.
pub fn encode(
self: *const KeyEncoder,
buf: []u8,
) ![]const u8 {
if (self.kitty_flags.int() != 0) return try self.kitty(buf);
return try self.legacy(buf);
}
/// Perform Kitty keyboard protocol encoding of the key event.
pub fn kitty(
fn kitty(
self: *const KeyEncoder,
buf: []u8,
) ![]const u8 {
@@ -126,7 +135,7 @@ pub fn kitty(
/// These together combine the legacy protocol because they're all
/// meant to be extensions that do not change any existing behavior
/// and therefore safe to combine.
pub fn legacy(
fn legacy(
self: *const KeyEncoder,
buf: []u8,
) ![]const u8 {