From 33bef288506da3459d91d0bcda2ff431ca432def Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Aug 2023 13:40:57 -0700 Subject: [PATCH] rename key2callback to keycallback --- src/Surface.zig | 5 ++++- src/apprt/embedded.zig | 4 ++-- src/apprt/glfw.zig | 4 ++-- src/apprt/gtk.zig | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 077dc142e..d2a403c8b 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -987,7 +987,10 @@ pub fn preeditCallback(self: *Surface, preedit: ?u21) !void { try self.queueRender(); } -pub fn key2Callback( +/// Called for any key events. This handles keybindings, encoding and +/// sending to the termianl, etc. The return value is true if the key +/// was handled and false if it was not. +pub fn keyCallback( self: *Surface, event: input.KeyEvent, ) !bool { diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 04a868d07..68a3c805a 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -509,7 +509,7 @@ pub const Surface = struct { } else .invalid; // Invoke the core Ghostty logic to handle this input. - const consumed = self.core_surface.key2Callback(.{ + const consumed = self.core_surface.keyCallback(.{ .action = action, .key = key, .physical_key = physical_key, @@ -541,7 +541,7 @@ pub const Surface = struct { // For a char callback we just construct a key event with invalid // keys but with text. This should result in the text being sent // as-is. - _ = self.core_surface.key2Callback(.{ + _ = self.core_surface.keyCallback(.{ .action = .press, .key = .invalid, .physical_key = .invalid, diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 37faa73d1..6e823643d 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -606,7 +606,7 @@ pub const Surface = struct { }; key_event.utf8 = buf[0..len]; - _ = core_win.key2Callback(key_event) catch |err| { + _ = core_win.keyCallback(key_event) catch |err| { log.err("error in key callback err={}", .{err}); return; }; @@ -773,7 +773,7 @@ pub const Surface = struct { .utf8 = "", }; - const consumed = core_win.key2Callback(key_event) catch |err| { + const consumed = core_win.keyCallback(key_event) catch |err| { log.err("error in key callback err={}", .{err}); return; }; diff --git a/src/apprt/gtk.zig b/src/apprt/gtk.zig index 0b7bca44e..1a8d497db 100644 --- a/src/apprt/gtk.zig +++ b/src/apprt/gtk.zig @@ -1309,7 +1309,7 @@ pub const Surface = struct { } // Invoke the core Ghostty logic to handle this input. - const consumed = self.core_surface.key2Callback(.{ + const consumed = self.core_surface.keyCallback(.{ .action = action, .key = key, .physical_key = physical_key, @@ -1402,7 +1402,7 @@ pub const Surface = struct { // We're not in a keypress, so this was sent from an on-screen emoji // keyboard or someting like that. Send the characters directly to // the surface. - _ = self.core_surface.key2Callback(.{ + _ = self.core_surface.keyCallback(.{ .action = .press, .key = .invalid, .physical_key = .invalid,