diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index 6cb01e5..f0bcae5 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -21,6 +21,7 @@ const MessageFilter = @import("MessageFilter.zig"); const Menu = @import("Menu.zig"); const EventHandler = @import("EventHandler.zig"); const Button = @import("Button.zig"); +const scrollbar_v = @import("scrollbar_v.zig"); const escape = fmt.fmtSliceEscapeLower; @@ -68,6 +69,7 @@ pub fn create(allocator: Allocator, parent: Plane) !Widget { .on_click5 = mouse_click_button5, }), }; + self.menu.scrollbar.?.style_factory = scrollbar_style; try self.commands.init(self); return Widget.to(self); } @@ -78,6 +80,15 @@ pub fn deinit(self: *Self, a: Allocator) void { a.destroy(self); } +fn scrollbar_style(sb: *scrollbar_v, theme: *const Widget.Theme) Widget.Theme.Style { + return if (sb.active) + .{ .fg = theme.scrollbar_active.fg, .bg = theme.panel.bg } + else if (sb.hover) + .{ .fg = theme.scrollbar_hover.fg, .bg = theme.panel.bg } + else + .{ .fg = theme.scrollbar.fg, .bg = theme.panel.bg }; +} + pub fn handle_resize(self: *Self, pos: Widget.Box) void { self.plane.move_yx(@intCast(pos.y), @intCast(pos.x)) catch return; self.plane.resize_simple(@intCast(pos.h), @intCast(pos.w)) catch return; @@ -195,6 +206,7 @@ fn mouse_click_button5(menu: **Menu.State(*Self), _: *Button.State(*Menu.State(* if (self.view_pos < @max(self.entries.items.len, self.view_rows) - self.view_rows) self.view_pos += Menu.scroll_lines; self.update_selected(); + self.update_scrollbar(); } fn update_selected(self: *Self) void {