config: richer diagnostics for errors

Rather than storing a list of errors we now store a list of
"diagnostics." Each diagnostic has a richer set of structured
information, including a message, a key, the location where it occurred.

This lets us show more detailed messages, more human friendly messages, and
also let's us filter by key or location. We don't take advantage of
all of this capability in this initial commit, but we do use every field
for something.
This commit is contained in:
Mitchell Hashimoto
2024-10-16 16:45:38 -07:00
parent 3f1d6eb301
commit a4e14631ef
11 changed files with 316 additions and 169 deletions

View File

@@ -291,7 +291,7 @@ typedef struct {
typedef struct {
const char* message;
} ghostty_error_s;
} ghostty_diagnostic_s;
typedef struct {
double tl_px_x;
@@ -615,8 +615,8 @@ 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);
uint32_t ghostty_config_errors_count(ghostty_config_t);
ghostty_error_s ghostty_config_get_error(ghostty_config_t, uint32_t);
uint32_t ghostty_config_diagnostics_count(ghostty_config_t);
ghostty_diagnostic_s ghostty_config_get_diagnostic(ghostty_config_t, uint32_t);
void ghostty_config_open();
ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s*,