mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 18:26:13 +03:00

This commit refactors RepeatablePath to contain a list of tagged unions containing "optional" and "required" variants. Both variants have a null terminated file path as their payload, but the tag dictates whether the path must exist or not. This implemenation is used to force consumers to handle the optional vs. required distinction. This also moves the parsing of optional file paths into RepeatablePath's parseCLI function. This allows the code to be better unit tested. Since RepeatablePath no longer contains a simple list of RepeatableStrings, many other of its methods needed to be reimplemented as well. Because all of this functionality is built into the RepeatablePath type, other config options which also use RepeatablePath gain the ability to specify optional paths as well. Right now this is only the "custom-shaders" option. The code paths in the renderer to load shader files has been updated accordingly. In the original optional config file parsing, the leading ? character was removed when paths were expanded. Thus, when config files were actually loaded recursively, they appeared to be regular (required) config files and an error occurred if the file did not exist. **This issue was not found during testing because the presence of the "theme" option masks the error**. I am not sure why the presence of "theme" does this, I did not dig into that. Now because the "optional" or "required" state of each path is tracked in the enum tag the "optional" status of the path is preserved after being expanded to an absolute path. Finally, this commit fixes a bug where missing "config-file" files were not included in the +show-config command (i.e. if a user had `config-file = foo.conf` and `foo.conf` did not exist, then `ghostty +show-config` would only display `config-file =`). This bug applied to `custom-shaders` too, where it has also been fixed.
40 lines
1.6 KiB
Zig
40 lines
1.6 KiB
Zig
const builtin = @import("builtin");
|
|
|
|
const formatter = @import("config/formatter.zig");
|
|
pub const Config = @import("config/Config.zig");
|
|
pub const string = @import("config/string.zig");
|
|
pub const edit = @import("config/edit.zig");
|
|
pub const url = @import("config/url.zig");
|
|
|
|
pub const FileFormatter = formatter.FileFormatter;
|
|
pub const entryFormatter = formatter.entryFormatter;
|
|
pub const formatEntry = formatter.formatEntry;
|
|
|
|
// Field types
|
|
pub const ClipboardAccess = Config.ClipboardAccess;
|
|
pub const CopyOnSelect = Config.CopyOnSelect;
|
|
pub const CustomShaderAnimation = Config.CustomShaderAnimation;
|
|
pub const FontSyntheticStyle = Config.FontSyntheticStyle;
|
|
pub const FontStyle = Config.FontStyle;
|
|
pub const Keybinds = Config.Keybinds;
|
|
pub const MouseShiftCapture = Config.MouseShiftCapture;
|
|
pub const NonNativeFullscreen = Config.NonNativeFullscreen;
|
|
pub const OptionAsAlt = Config.OptionAsAlt;
|
|
pub const RepeatableCodepointMap = Config.RepeatableCodepointMap;
|
|
pub const RepeatableFontVariation = Config.RepeatableFontVariation;
|
|
pub const RepeatableString = Config.RepeatableString;
|
|
pub const RepeatablePath = Config.RepeatablePath;
|
|
pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures;
|
|
pub const WindowPaddingColor = Config.WindowPaddingColor;
|
|
|
|
// Alternate APIs
|
|
pub const CAPI = @import("config/CAPI.zig");
|
|
pub const Wasm = if (!builtin.target.isWasm()) struct {} else @import("config/Wasm.zig");
|
|
|
|
test {
|
|
@import("std").testing.refAllDecls(@This());
|
|
|
|
// Vim syntax file, not used at runtime but we want to keep it tested.
|
|
_ = @import("config/vim.zig");
|
|
}
|