apprt: add config_change action

This commit is contained in:
Mitchell Hashimoto
2024-11-20 15:08:47 -08:00
parent 3404816875
commit fadfb08efe
6 changed files with 56 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const apprt = @import("../apprt.zig");
const configpkg = @import("../config.zig");
const input = @import("../input.zig");
const renderer = @import("../renderer.zig");
const terminal = @import("../terminal/main.zig");
@@ -200,6 +201,20 @@ pub const Action = union(Key) {
/// on the app or surface.
config_change_conditional_state,
/// The configuration has changed. The value is a pointer to the new
/// configuration. The pointer is only valid for the duration of the
/// action and should not be stored.
///
/// This should be used by apprts to update any internal state that
/// depends on configuration for the given target (i.e. headerbar colors).
/// The apprt should copy any data it needs since the memory lifetime
/// is only valid for the duration of the action.
///
/// This allows an apprt to have config-dependent state reactively
/// change without having to store the entire configuration or poll
/// for changes.
config_change: ConfigChange,
/// Sync with: ghostty_action_tag_e
pub const Key = enum(c_int) {
new_window,
@@ -236,6 +251,7 @@ pub const Action = union(Key) {
key_sequence,
color_change,
config_change_conditional_state,
config_change,
};
/// Sync with: ghostty_action_u
@@ -497,3 +513,18 @@ pub const ColorKind = enum(c_int) {
// 0+ values indicate a palette index
_,
};
pub const ConfigChange = struct {
config: *const configpkg.Config,
// Sync with: ghostty_action_config_change_s
pub const C = extern struct {
config: *const configpkg.Config,
};
pub fn cval(self: ConfigChange) C {
return .{
.config = self.config,
};
}
};

View File

@@ -226,6 +226,7 @@ pub const App = struct {
.color_change,
.pwd,
.config_change_conditional_state,
.config_change,
=> log.info("unimplemented action={}", .{action}),
}
}

View File

@@ -488,6 +488,7 @@ pub fn performAction(
.render_inspector,
.renderer_health,
.color_change,
.config_change,
=> log.warn("unimplemented action={}", .{action}),
}
}