diff --git a/src/config.zig b/src/config.zig index 8f011f4..eb37c6d 100644 --- a/src/config.zig +++ b/src/config.zig @@ -22,6 +22,8 @@ tab_width: usize = 8, top_bar: []const u8 = "tabs", bottom_bar: []const u8 = "mode file log selection diagnostics keybind linenumber clock spacer", +show_scrollbars: bool = true, +show_fileicons: bool = true, lsp_request_timeout: usize = 10, diff --git a/src/tui/Menu.zig b/src/tui/Menu.zig index 0a2090c..14f68f1 100644 --- a/src/tui/Menu.zig +++ b/src/tui/Menu.zig @@ -6,6 +6,7 @@ const WidgetList = @import("WidgetList.zig"); const Button = @import("Button.zig"); const scrollbar_v = @import("scrollbar_v.zig"); const Plane = @import("renderer").Plane; +const tui = @import("tui.zig"); pub const Container = WidgetList; pub const scroll_lines = 3; @@ -61,7 +62,10 @@ pub fn create(ctx_type: type, allocator: std.mem.Allocator, parent: Plane, opts: .menu = try WidgetList.createV(allocator, container.plane, @typeName(@This()), .dynamic), .container = container, .container_widget = container.widget(), - .scrollbar = if (opts.on_scroll) |on_scroll| (try scrollbar_v.create(allocator, parent, null, on_scroll)).dynamic_cast(scrollbar_v).? else null, + .scrollbar = if (tui.config().show_scrollbars) + if (opts.on_scroll) |on_scroll| (try scrollbar_v.create(allocator, parent, null, on_scroll)).dynamic_cast(scrollbar_v).? else null + else + null, .opts = opts, }; self.menu.ctx = self; diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 22de20f..a253a83 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5512,7 +5512,8 @@ pub const EditorWidget = struct { const editorWidget = Widget.to(self); try container.add(try editor_gutter.create(allocator, container.widget(), editorWidget, &self.editor)); try container.add(editorWidget); - try container.add(try scrollbar_v.create(allocator, container.plane, editorWidget, EventHandler.to_unowned(container))); + if (tui.config().show_scrollbars) + try container.add(try scrollbar_v.create(allocator, container.plane, editorWidget, EventHandler.to_unowned(container))); return container.widget(); } diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index 0c2c662..017da56 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -61,7 +61,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget { .on_click5 = mouse_click_button5, }), }; - self.menu.scrollbar.?.style_factory = scrollbar_style; + if (self.menu.scrollbar) |scrollbar| scrollbar.style_factory = scrollbar_style; try self.commands.init(self); return Widget.to(self); } @@ -184,7 +184,8 @@ fn handle_scroll(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!void { } fn update_scrollbar(self: *Self) void { - self.menu.scrollbar.?.set(@intCast(self.entries.items.len), @intCast(self.view_rows), @intCast(self.view_pos)); + if (self.menu.scrollbar) |scrollbar| + scrollbar.set(@intCast(self.entries.items.len), @intCast(self.view_rows), @intCast(self.view_pos)); } fn mouse_click_button4(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void { diff --git a/src/tui/mode/overlay/buffer_palette.zig b/src/tui/mode/overlay/buffer_palette.zig index f9814dd..3db56c1 100644 --- a/src/tui/mode/overlay/buffer_palette.zig +++ b/src/tui/mode/overlay/buffer_palette.zig @@ -84,7 +84,10 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonState, theme: *const Widget. if (!(cbor.matchString(&iter, &file_path_) catch false)) @panic("invalid buffer file path"); if (!(cbor.matchString(&iter, &icon) catch false)) @panic("invalid buffer file type icon"); if (!(cbor.matchInt(u24, &iter, &color) catch false)) @panic("invalid buffer file type color"); - tui.render_file_icon(&button.plane, icon, color); + if (tui.config().show_fileicons) { + tui.render_file_icon(&button.plane, icon, color); + _ = button.plane.print(" ", .{}) catch {}; + } button.plane.set_style(style_label); _ = button.plane.print(" {s} ", .{file_path_}) catch {}; diff --git a/src/tui/mode/overlay/file_type_palette.zig b/src/tui/mode/overlay/file_type_palette.zig index 9a065e5..4c439cf 100644 --- a/src/tui/mode/overlay/file_type_palette.zig +++ b/src/tui/mode/overlay/file_type_palette.zig @@ -90,9 +90,12 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonState, theme: *const Widget. if (!(cbor.matchString(&iter, &description_) catch false)) @panic("invalid file_type description"); if (!(cbor.matchString(&iter, &icon) catch false)) @panic("invalid file_type icon"); if (!(cbor.matchInt(u24, &iter, &color) catch false)) @panic("invalid file_type color"); - tui.render_file_icon(&button.plane, icon, color); + if (tui.config().show_fileicons) { + tui.render_file_icon(&button.plane, icon, color); + _ = button.plane.print(" ", .{}) catch {}; + } button.plane.set_style(style_label); - _ = button.plane.print(" {s} ", .{description_}) catch {}; + _ = button.plane.print("{s} ", .{description_}) catch {}; var name_: []const u8 = undefined; if (!(cbor.matchString(&iter, &name_) catch false)) diff --git a/src/tui/mode/overlay/palette.zig b/src/tui/mode/overlay/palette.zig index 9366c4a..87f31f7 100644 --- a/src/tui/mode/overlay/palette.zig +++ b/src/tui/mode/overlay/palette.zig @@ -70,7 +70,7 @@ pub fn Create(options: type) type { .view_rows = get_view_rows(tui.screen()), .entries = std.ArrayList(Entry).init(allocator), }; - self.menu.scrollbar.?.style_factory = scrollbar_style; + if (self.menu.scrollbar) |scrollbar| scrollbar.style_factory = scrollbar_style; self.longest_hint = try options.load_entries(self); if (@hasDecl(options, "restore_state")) options.restore_state(self) catch {}; @@ -173,7 +173,8 @@ pub fn Create(options: type) type { } fn update_scrollbar(self: *Self) void { - self.menu.scrollbar.?.set(@intCast(@max(self.total_items, 1) - 1), @intCast(self.view_rows), @intCast(self.view_pos)); + if (self.menu.scrollbar) |scrollbar| + scrollbar.set(@intCast(@max(self.total_items, 1) - 1), @intCast(self.view_rows), @intCast(self.view_pos)); } fn mouse_click_button4(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void { diff --git a/src/tui/status/filestate.zig b/src/tui/status/filestate.zig index c9f2e10..82af48c 100644 --- a/src/tui/status/filestate.zig +++ b/src/tui/status/filestate.zig @@ -131,7 +131,7 @@ fn render_mini_mode(plane: *Plane, theme: *const Widget.Theme) void { fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void { plane.on_styles(style.italic); _ = plane.putstr(" ") catch {}; - if (self.file_icon.len > 0) { + if (self.file_icon.len > 0 and tui.config().show_fileicons) { self.render_file_icon(plane, theme); _ = plane.print(" ", .{}) catch {}; } @@ -143,7 +143,7 @@ fn render_normal(self: *Self, plane: *Plane, theme: *const Widget.Theme) void { fn render_detailed(self: *Self, plane: *Plane, theme: *const Widget.Theme) void { plane.on_styles(style.italic); _ = plane.putstr(" ") catch {}; - if (self.file_icon.len > 0) { + if (self.file_icon.len > 0 and tui.config().show_fileicons) { self.render_file_icon(plane, theme); _ = plane.print(" ", .{}) catch {}; }