mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
core: use Kitty encoding if enabled
This commit is contained in:
@ -1037,11 +1037,12 @@ pub fn keyCallback(
|
||||
.cursor_key_application = t.modes.get(.cursor_keys),
|
||||
.keypad_key_application = t.modes.get(.keypad_keys),
|
||||
.modify_other_keys_state_2 = t.flags.modify_other_keys_2,
|
||||
.kitty_flags = t.screen.kitty_keyboard.current(),
|
||||
};
|
||||
};
|
||||
|
||||
var data: termio.Message.WriteReq.Small.Array = undefined;
|
||||
const seq = try enc.legacy(&data);
|
||||
const seq = try enc.encode(&data);
|
||||
if (seq.len == 0) return false;
|
||||
|
||||
_ = self.io_thread.mailbox.push(.{
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user