From f7ba83fd830813a3adbe7658930ca9eb93fe071c Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 12 Dec 2024 19:25:44 +0100 Subject: [PATCH] refactor: prefer Plane.fill for blanking with alpha --- src/tui/InputBox.zig | 2 +- src/tui/Menu.zig | 2 +- src/tui/filelist_view.zig | 2 +- src/tui/home.zig | 2 +- src/tui/mode/overlay/file_type_palette.zig | 2 +- src/tui/mode/overlay/open_recent.zig | 2 +- src/tui/mode/overlay/palette.zig | 2 +- src/tui/status/blank.zig | 2 +- src/tui/status/clock.zig | 2 +- src/tui/status/diagstate.zig | 2 +- src/tui/status/filestate.zig | 4 ++-- src/tui/status/keybindstate.zig | 2 +- src/tui/status/keystate.zig | 2 +- src/tui/status/linenumstate.zig | 2 +- src/tui/status/minilog.zig | 2 +- src/tui/status/modestate.zig | 4 ++-- src/tui/status/modstate.zig | 2 +- src/tui/status/selectionstate.zig | 2 +- 18 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/tui/InputBox.zig b/src/tui/InputBox.zig index 1957969..6ded557 100644 --- a/src/tui/InputBox.zig +++ b/src/tui/InputBox.zig @@ -27,7 +27,7 @@ pub fn Options(context: type) type { self.plane.erase(); self.plane.home(); self.plane.set_style(style_label); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); if (self.text.items.len > 0) { _ = self.plane.print(" {s} ", .{self.text.items}) catch {}; diff --git a/src/tui/Menu.zig b/src/tui/Menu.zig index b09cb51..c4dbdba 100644 --- a/src/tui/Menu.zig +++ b/src/tui/Menu.zig @@ -33,7 +33,7 @@ pub fn Options(context: type) type { button.plane.home(); if (button.active or button.hover or selected) { button.plane.set_style(style_label); - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } _ = button.plane.print(" {s} ", .{button.opts.label}) catch {}; diff --git a/src/tui/filelist_view.zig b/src/tui/filelist_view.zig index cf576bc..022add5 100644 --- a/src/tui/filelist_view.zig +++ b/src/tui/filelist_view.zig @@ -155,7 +155,7 @@ fn handle_render_menu(self: *Self, button: *Button.State(*Menu.State(*Self)), th button.plane.home(); button.plane.set_style(style_label); if (button.active or button.hover or selected) { - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } const entry = &self.entries.items[idx]; diff --git a/src/tui/home.zig b/src/tui/home.zig index 2ea1b1e..85bce2c 100644 --- a/src/tui/home.zig +++ b/src/tui/home.zig @@ -127,7 +127,7 @@ fn menu_on_render(_: *Self, button: *Button.State(*Menu.State(*Self)), theme: *c button.plane.home(); button.plane.set_style(style_label); if (button.active or button.hover or selected) { - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } const style_text = if (tui.find_scope_style(theme, "keyword")) |sty| sty.style else style_label; diff --git a/src/tui/mode/overlay/file_type_palette.zig b/src/tui/mode/overlay/file_type_palette.zig index ae7e3d8..f09df23 100644 --- a/src/tui/mode/overlay/file_type_palette.zig +++ b/src/tui/mode/overlay/file_type_palette.zig @@ -75,7 +75,7 @@ pub fn on_render_menu(_: *Type, button: *Type.ButtonState, theme: *const Widget. button.plane.home(); button.plane.set_style(style_label); if (button.active or button.hover or selected) { - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } diff --git a/src/tui/mode/overlay/open_recent.zig b/src/tui/mode/overlay/open_recent.zig index 08817fb..50050cc 100644 --- a/src/tui/mode/overlay/open_recent.zig +++ b/src/tui/mode/overlay/open_recent.zig @@ -102,7 +102,7 @@ fn on_render_menu(_: *Self, button: *Button.State(*Menu.State(*Self)), theme: *c button.plane.home(); button.plane.set_style(style_label); if (button.active or button.hover or selected) { - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } var file_path: []const u8 = undefined; diff --git a/src/tui/mode/overlay/palette.zig b/src/tui/mode/overlay/palette.zig index a9dd0d9..717cf7a 100644 --- a/src/tui/mode/overlay/palette.zig +++ b/src/tui/mode/overlay/palette.zig @@ -117,7 +117,7 @@ pub fn Create(options: type) type { button.plane.home(); button.plane.set_style(style_label); if (button.active or button.hover or selected) { - _ = button.plane.fill_width(" ", .{}) catch {}; + button.plane.fill(" "); button.plane.home(); } var label: []const u8 = undefined; diff --git a/src/tui/status/blank.zig b/src/tui/status/blank.zig index 2cb1733..17dfdf4 100644 --- a/src/tui/status/blank.zig +++ b/src/tui/status/blank.zig @@ -39,7 +39,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); return false; } diff --git a/src/tui/status/clock.zig b/src/tui/status/clock.zig index a171e36..127109c 100644 --- a/src/tui/status/clock.zig +++ b/src/tui/status/clock.zig @@ -63,7 +63,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); const now = zeit.instant(.{ .timezone = &self.tz }) catch return false; diff --git a/src/tui/status/diagstate.zig b/src/tui/status/diagstate.zig index 74d84a9..8a7f057 100644 --- a/src/tui/status/diagstate.zig +++ b/src/tui/status/diagstate.zig @@ -44,7 +44,7 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme) btn.plane.erase(); btn.plane.home(); btn.plane.set_style(bg_style); - _ = btn.plane.fill_width(" ", .{}) catch {}; + btn.plane.fill(" "); btn.plane.home(); _ = btn.plane.putstr(self.rendered) catch {}; return false; diff --git a/src/tui/status/filestate.zig b/src/tui/status/filestate.zig index f428fe4..58190c6 100644 --- a/src/tui/status/filestate.zig +++ b/src/tui/status/filestate.zig @@ -82,11 +82,11 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme) btn.plane.erase(); btn.plane.home(); btn.plane.set_style(style_base); - _ = btn.plane.fill_width(" ", .{}) catch {}; + btn.plane.fill(" "); btn.plane.home(); btn.plane.set_style(style_label); if (btn.active) { - _ = btn.plane.fill_width(" ", .{}) catch {}; + btn.plane.fill(" "); btn.plane.home(); } if (tui.current().mini_mode) |_| diff --git a/src/tui/status/keybindstate.zig b/src/tui/status/keybindstate.zig index 8d73fe0..ebf013a 100644 --- a/src/tui/status/keybindstate.zig +++ b/src/tui/status/keybindstate.zig @@ -39,7 +39,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); _ = self.plane.print(" {} ", .{keybind.current_key_event_sequence_fmt()}) catch {}; return false; diff --git a/src/tui/status/keystate.zig b/src/tui/status/keystate.zig index c9bbbee..ee854e3 100644 --- a/src/tui/status/keystate.zig +++ b/src/tui/status/keystate.zig @@ -99,7 +99,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(if (self.hover) theme.statusbar_hover else theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); return if (self.keys[0].id > 0) self.render_active() else self.render_idle(); } diff --git a/src/tui/status/linenumstate.zig b/src/tui/status/linenumstate.zig index 7de44ee..cbeec3f 100644 --- a/src/tui/status/linenumstate.zig +++ b/src/tui/status/linenumstate.zig @@ -45,7 +45,7 @@ pub fn render(self: *Self, btn: *Button.State(Self), theme: *const Widget.Theme) btn.plane.erase(); btn.plane.home(); btn.plane.set_style(if (btn.active) theme.editor_cursor else if (btn.hover) theme.statusbar_hover else theme.statusbar); - _ = btn.plane.fill_width(" ", .{}) catch {}; + btn.plane.fill(" "); btn.plane.home(); _ = btn.plane.putstr(self.rendered) catch {}; return false; diff --git a/src/tui/status/minilog.zig b/src/tui/status/minilog.zig index 777c724..56a9c03 100644 --- a/src/tui/status/minilog.zig +++ b/src/tui/status/minilog.zig @@ -73,7 +73,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(style_normal); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); self.plane.set_style(if (self.level == .err) style_error else style_info); _ = self.plane.print(" {s} ", .{self.msg.items}) catch {}; diff --git a/src/tui/status/modestate.zig b/src/tui/status/modestate.zig index 7dbef00..0e285d9 100644 --- a/src/tui/status/modestate.zig +++ b/src/tui/status/modestate.zig @@ -47,10 +47,10 @@ pub fn render(_: *void, self: *Button.State(void), theme: *const Widget.Theme) b self.plane.erase(); self.plane.home(); self.plane.set_style(style_base); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); self.plane.set_style(style_label); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); self.plane.on_styles(style.bold); var buf: [31:0]u8 = undefined; diff --git a/src/tui/status/modstate.zig b/src/tui/status/modstate.zig index 88dc9af..9e01881 100644 --- a/src/tui/status/modstate.zig +++ b/src/tui/status/modstate.zig @@ -49,7 +49,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(if (self.hover) theme.statusbar_hover else theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); _ = self.plane.print(" {s}{s}{s} ", .{ diff --git a/src/tui/status/selectionstate.zig b/src/tui/status/selectionstate.zig index 631e701..8ac3d99 100644 --- a/src/tui/status/selectionstate.zig +++ b/src/tui/status/selectionstate.zig @@ -43,7 +43,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool { self.plane.erase(); self.plane.home(); self.plane.set_style(theme.statusbar); - _ = self.plane.fill_width(" ", .{}) catch {}; + self.plane.fill(" "); self.plane.home(); _ = self.plane.putstr(self.rendered) catch {}; return false;