mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt/embedded: API for checking if there are global keybinds
This commit is contained in:
@ -531,6 +531,7 @@ void ghostty_app_keyboard_changed(ghostty_app_t);
|
||||
void ghostty_app_open_config(ghostty_app_t);
|
||||
void ghostty_app_reload_config(ghostty_app_t);
|
||||
bool ghostty_app_needs_confirm_quit(ghostty_app_t);
|
||||
bool ghostty_app_has_global_keybinds(ghostty_app_t);
|
||||
|
||||
ghostty_surface_config_s ghostty_surface_config_new();
|
||||
|
||||
|
@ -161,6 +161,19 @@ pub const App = struct {
|
||||
self.keymap.deinit();
|
||||
}
|
||||
|
||||
/// Returns true if there are any global keybinds in the configuration.
|
||||
pub fn hasGlobalKeybinds(self: *const App) bool {
|
||||
var it = self.config.keybind.set.bindings.iterator();
|
||||
while (it.next()) |entry| {
|
||||
switch (entry.value_ptr.*) {
|
||||
.leader => {},
|
||||
.leaf => |leaf| if (leaf.flags.global) return true,
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// This should be called whenever the keyboard layout was changed.
|
||||
pub fn reloadKeymap(self: *App) !void {
|
||||
// Reload the keymap
|
||||
@ -1514,6 +1527,11 @@ pub const CAPI = struct {
|
||||
return v.core_app.needsConfirmQuit();
|
||||
}
|
||||
|
||||
/// Returns true if the app has global keybinds.
|
||||
export fn ghostty_app_has_global_keybinds(v: *App) bool {
|
||||
return v.hasGlobalKeybinds();
|
||||
}
|
||||
|
||||
/// Returns initial surface options.
|
||||
export fn ghostty_surface_config_new() apprt.Surface.Options {
|
||||
return .{};
|
||||
|
Reference in New Issue
Block a user