feat: make status bars configurable

This commit is contained in:
CJ van den Berg 2024-08-25 20:46:18 +02:00
parent 9efff08e1f
commit 4df737e78f
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
14 changed files with 131 additions and 64 deletions

22
src/tui/status/widget.zig Normal file
View file

@ -0,0 +1,22 @@
const std = @import("std");
const Widget = @import("../Widget.zig");
const Plane = @import("renderer").Plane;
const widgets = std.static_string_map.StaticStringMap(create_fn).initComptime(.{
.{ "mode", @import("modestate.zig").create },
.{ "file", @import("filestate.zig").create },
.{ "log", @import("minilog.zig").create },
.{ "selection", @import("selectionstate.zig").create },
.{ "diagnostics", @import("diagstate.zig").create },
.{ "linenumber", @import("linenumstate.zig").create },
.{ "modifiers", @import("modstate.zig").create },
.{ "keystate", @import("keystate.zig").create },
.{ "expander", @import("expander.zig").create },
});
pub const CreateError = error{ OutOfMemory, Exit };
const create_fn = *const fn (a: std.mem.Allocator, parent: Plane, event_handler: ?Widget.EventHandler) CreateError!Widget;
pub fn create(name: []const u8, a: std.mem.Allocator, parent: Plane, event_handler: ?Widget.EventHandler) CreateError!?Widget {
const create_ = widgets.get(name) orelse return null;
return try create_(a, parent, event_handler);
}