refactor: prefer Plane.fill for blanking with alpha

This commit is contained in:
CJ van den Berg 2024-12-12 19:25:44 +01:00
parent fa25d250c6
commit f7ba83fd83
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
18 changed files with 20 additions and 20 deletions

View file

@ -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 {};

View file

@ -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 {};

View file

@ -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];

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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) |_|

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -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 {};

View file

@ -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;

View file

@ -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} ", .{

View file

@ -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;