mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: log configuration errors
This commit is contained in:
@ -250,6 +250,10 @@ typedef struct {
|
|||||||
// Fully defined types. This MUST be kept in sync with equivalent Zig
|
// Fully defined types. This MUST be kept in sync with equivalent Zig
|
||||||
// structs. To find the Zig struct, grep for this type name. The documentation
|
// structs. To find the Zig struct, grep for this type name. The documentation
|
||||||
// for all of these types is available in the Zig source.
|
// for all of these types is available in the Zig source.
|
||||||
|
typedef struct {
|
||||||
|
const char *message;
|
||||||
|
} ghostty_error_s;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *userdata;
|
void *userdata;
|
||||||
void *nsview;
|
void *nsview;
|
||||||
@ -303,6 +307,8 @@ void ghostty_config_load_recursive_files(ghostty_config_t);
|
|||||||
void ghostty_config_finalize(ghostty_config_t);
|
void ghostty_config_finalize(ghostty_config_t);
|
||||||
bool ghostty_config_get(ghostty_config_t, void *, const char *, uintptr_t);
|
bool ghostty_config_get(ghostty_config_t, void *, const char *, uintptr_t);
|
||||||
ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t, const char *, uintptr_t);
|
ghostty_input_trigger_s ghostty_config_trigger(ghostty_config_t, const char *, uintptr_t);
|
||||||
|
uint32_t ghostty_config_errors_count(ghostty_config_t);
|
||||||
|
ghostty_error_s ghostty_config_get_error(ghostty_config_t, uint32_t);
|
||||||
|
|
||||||
ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s *, ghostty_config_t);
|
ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s *, ghostty_config_t);
|
||||||
void ghostty_app_free(ghostty_app_t);
|
void ghostty_app_free(ghostty_app_t);
|
||||||
|
@ -128,6 +128,20 @@ extension Ghostty {
|
|||||||
// Finalize will make our defaults available.
|
// Finalize will make our defaults available.
|
||||||
ghostty_config_finalize(cfg)
|
ghostty_config_finalize(cfg)
|
||||||
|
|
||||||
|
// Log any configuration errors. These will be automatically shown in a
|
||||||
|
// pop-up window too.
|
||||||
|
let errCount = ghostty_config_errors_count(cfg)
|
||||||
|
if errCount > 0 {
|
||||||
|
AppDelegate.logger.warning("config error: \(errCount) configuration errors on reload")
|
||||||
|
var errors: [String] = [];
|
||||||
|
for i in 0..<errCount {
|
||||||
|
let err = ghostty_config_get_error(cfg, UInt32(i))
|
||||||
|
let message = String(cString: err.message)
|
||||||
|
errors.append(message)
|
||||||
|
AppDelegate.logger.warning("config error: \(message)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,3 +108,18 @@ fn config_trigger_(
|
|||||||
const action = try inputpkg.Binding.Action.parse(str);
|
const action = try inputpkg.Binding.Action.parse(str);
|
||||||
return self.keybind.set.getTrigger(action) orelse .{};
|
return self.keybind.set.getTrigger(action) orelse .{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export fn ghostty_config_errors_count(self: *Config) u32 {
|
||||||
|
return @intCast(self._errors.list.items.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn ghostty_config_get_error(self: *Config, idx: u32) Error {
|
||||||
|
if (idx >= self._errors.list.items.len) return .{};
|
||||||
|
const err = self._errors.list.items[idx];
|
||||||
|
return .{ .message = err.message.ptr };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sync with ghostty_error_s
|
||||||
|
const Error = extern struct {
|
||||||
|
message: [*:0]const u8 = "",
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user