feat: use icons in mini mode labels
This commit is contained in:
parent
9ba773c4a4
commit
cf22ba38e7
7 changed files with 21 additions and 28 deletions
|
@ -4,6 +4,7 @@ const nc = @import("notcurses");
|
|||
const tp = @import("thespian");
|
||||
const tracy = @import("tracy");
|
||||
const root = @import("root");
|
||||
const Buffer = @import("Buffer");
|
||||
|
||||
const Widget = @import("../Widget.zig");
|
||||
const command = @import("../command.zig");
|
||||
|
@ -37,7 +38,10 @@ pub fn deinit(self: *Self, a: Allocator) void {
|
|||
}
|
||||
|
||||
pub fn layout(_: *Self) Widget.Layout {
|
||||
return .{ .static = if (is_mini_mode()) tui.get_mode().len + 5 else tui.get_mode().len - 1 };
|
||||
const name = tui.get_mode();
|
||||
const width = Buffer.egc_chunk_width(name, 0);
|
||||
const padding: usize = if (is_mini_mode()) 3 else 2;
|
||||
return .{ .static = width + padding };
|
||||
}
|
||||
|
||||
fn is_mini_mode() bool {
|
||||
|
@ -45,30 +49,19 @@ fn is_mini_mode() bool {
|
|||
}
|
||||
|
||||
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||
if (is_mini_mode())
|
||||
self.render_mode(theme)
|
||||
else
|
||||
self.render_logo(theme);
|
||||
return false;
|
||||
}
|
||||
|
||||
fn render_mode(self: *Self, theme: *const Widget.Theme) void {
|
||||
tui.set_base_style(&self.plane, " ", theme.statusbar_hover);
|
||||
self.plane.on_styles(nc.style.bold);
|
||||
self.plane.erase();
|
||||
self.plane.home();
|
||||
var buf: [31:0]u8 = undefined;
|
||||
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, " {s} ", .{tui.get_mode()}) catch return) catch {};
|
||||
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, " {s} ", .{tui.get_mode()}) catch return false) catch {};
|
||||
if (is_mini_mode())
|
||||
self.render_separator(theme);
|
||||
return false;
|
||||
}
|
||||
|
||||
fn render_separator(self: *Self, theme: *const Widget.Theme) void {
|
||||
if (theme.statusbar_hover.bg) |bg| self.plane.set_fg_rgb(bg) catch {};
|
||||
if (theme.statusbar.bg) |bg| self.plane.set_bg_rgb(bg) catch {};
|
||||
_ = self.plane.putstr("") catch {};
|
||||
}
|
||||
|
||||
fn render_logo(self: *Self, theme: *const Widget.Theme) void {
|
||||
tui.set_base_style(&self.plane, " ", theme.statusbar_hover);
|
||||
self.plane.on_styles(nc.style.bold);
|
||||
self.plane.erase();
|
||||
self.plane.home();
|
||||
var buf: [31:0]u8 = undefined;
|
||||
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, " {s} ", .{tui.get_mode()}) catch return) catch {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue