-
Notifications
You must be signed in to change notification settings - Fork 39
Add ghostty_config_set_color_scheme C API #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ const inputpkg = @import("../input.zig"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| const state = &@import("../global.zig").state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const c = @import("../main_c.zig"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const conditional = @import("conditional.zig"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Config = @import("Config.zig"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const c_get = @import("c_get.zig"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const edit = @import("edit.zig"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -89,6 +90,24 @@ export fn ghostty_config_finalize(self: *Config) void { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Set the color scheme on a configuration's conditional state before | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// finalization. This ensures that conditional theme resolution (e.g. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// `theme = light:Foo,dark:Bar`) uses the correct scheme during | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// `ghostty_config_finalize`. Must be called before finalize. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| export fn ghostty_config_set_color_scheme(self: *Config, scheme_raw: c_int) void { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+93
to
+97
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._conditional_state.theme = switch (scheme_raw) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0 => .light, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1 => .dark, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "invalid color scheme to ghostty_config_set_color_scheme value={}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| .{scheme_raw}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+97
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The analogous functions
Suggested change
Comment on lines
+97
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every other exported function in this file has at least one Zig test (e.g. Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export fn ghostty_config_get( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| self: *Config, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ptr: *anyopaque, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const conditional = @import("conditional.zig");is currently unused in this file, which will fail Zig compilation (unused top-level declaration). Either remove the import or use it (e.g., parsescheme_rawviastd.meta.intToEnum(conditional.State.Theme, …)and assign the result).