feat: display pending integer argument in keybind widget

This commit is contained in:
CJ van den Berg 2025-04-08 18:04:02 +02:00
parent 6946cb4010
commit d594e42f1a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -29,9 +29,12 @@ pub fn layout(_: *Self) Widget.Layout {
var buf: [256]u8 = undefined;
var fbs = std.io.fixedBufferStream(&buf);
const writer = fbs.writer();
writer.print("{}", .{keybind.current_key_event_sequence_fmt()}) catch {};
writer.print(" ", .{}) catch {};
if (keybind.current_integer_argument()) |integer_argument|
writer.print("{}", .{integer_argument}) catch {};
writer.print("{} ", .{keybind.current_key_event_sequence_fmt()}) catch {};
const len = fbs.getWritten().len;
return .{ .static = if (len > 0) len + 2 else 0 };
return .{ .static = if (len > 0) len else 0 };
}
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
@ -41,6 +44,9 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
self.plane.set_style(theme.statusbar);
self.plane.fill(" ");
self.plane.home();
_ = self.plane.print(" {} ", .{keybind.current_key_event_sequence_fmt()}) catch {};
_ = self.plane.print(" ", .{}) catch {};
if (keybind.current_integer_argument()) |integer_argument|
_ = self.plane.print("{}", .{integer_argument}) catch {};
_ = self.plane.print("{} ", .{keybind.current_key_event_sequence_fmt()}) catch {};
return false;
}