mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
apprt/gtk: support new config diagnostics API
This commit is contained in:
@ -123,9 +123,13 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
|
||||
errdefer config.deinit();
|
||||
|
||||
// If we had configuration errors, then log them.
|
||||
if (!config._errors.empty()) {
|
||||
for (config._errors.list.items) |err| {
|
||||
log.warn("configuration error: {s}", .{err.message});
|
||||
if (!config._diagnostics.empty()) {
|
||||
var buf = std.ArrayList(u8).init(core_app.alloc);
|
||||
defer buf.deinit();
|
||||
for (config._diagnostics.items()) |diag| {
|
||||
try diag.write(buf.writer());
|
||||
log.warn("configuration error: {s}", .{buf.items});
|
||||
buf.clearRetainingCapacity();
|
||||
}
|
||||
}
|
||||
|
||||
@ -815,7 +819,7 @@ fn syncConfigChanges(self: *App) !void {
|
||||
/// there are new configuration errors and hide the window if the errors
|
||||
/// are resolved.
|
||||
fn updateConfigErrors(self: *App) !void {
|
||||
if (!self.config._errors.empty()) {
|
||||
if (!self.config._diagnostics.empty()) {
|
||||
if (self.config_errors_window == null) {
|
||||
try ConfigErrorsWindow.create(self);
|
||||
assert(self.config_errors_window != null);
|
||||
|
@ -28,7 +28,7 @@ pub fn create(app: *App) !void {
|
||||
}
|
||||
|
||||
pub fn update(self: *ConfigErrors) void {
|
||||
if (self.app.config._errors.empty()) {
|
||||
if (self.app.config._diagnostics.empty()) {
|
||||
c.gtk_window_destroy(@ptrCast(self.window));
|
||||
return;
|
||||
}
|
||||
@ -130,8 +130,21 @@ const PrimaryView = struct {
|
||||
const buf = c.gtk_text_buffer_new(null);
|
||||
errdefer c.g_object_unref(buf);
|
||||
|
||||
for (config._errors.list.items) |err| {
|
||||
c.gtk_text_buffer_insert_at_cursor(buf, err.message, @intCast(err.message.len));
|
||||
var msg_buf: [4096]u8 = undefined;
|
||||
var fbs = std.io.fixedBufferStream(&msg_buf);
|
||||
|
||||
for (config._diagnostics.items()) |diag| {
|
||||
fbs.reset();
|
||||
diag.write(fbs.writer()) catch |err| {
|
||||
log.warn(
|
||||
"error writing diagnostic to buffer err={}",
|
||||
.{err},
|
||||
);
|
||||
continue;
|
||||
};
|
||||
|
||||
const msg = fbs.getWritten();
|
||||
c.gtk_text_buffer_insert_at_cursor(buf, msg.ptr, @intCast(msg.len));
|
||||
c.gtk_text_buffer_insert_at_cursor(buf, "\n", -1);
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ pub const DiagnosticList = struct {
|
||||
return self.list.items.len == 0;
|
||||
}
|
||||
|
||||
pub fn items(self: *DiagnosticList) []Diagnostic {
|
||||
pub fn items(self: *const DiagnosticList) []const Diagnostic {
|
||||
return self.list.items;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user