From 2db1d55fcfbac1034d6fd7e0ed1b72db4322dc10 Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Wed, 9 Oct 2024 21:13:07 +0200 Subject: [PATCH] mod(Header): move name to the right hand side --- src/widget/Header.zig | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/widget/Header.zig b/src/widget/Header.zig index c85fe15..44c3f7e 100644 --- a/src/widget/Header.zig +++ b/src/widget/Header.zig @@ -33,6 +33,18 @@ pub fn deinit(this: *@This()) void { fn fillView(this: *@This()) void { this.view.?.clear(); + if (this.path) |path| { + for (0..path.len, this.view.?.screen.width / 2 - path.len / 2..) |i, col| { + const cell: vaxis.Cell = .{ + .char = .{ .grapheme = path[i .. i + 1] }, + .style = .{ + .ul_style = .single, + }, + }; + this.view.?.writeCell(col, 0, cell); + } + } + const msg = "Yves Biener"; for (msg, 0..) |_, i| { const cell: vaxis.Cell = .{ @@ -46,25 +58,7 @@ fn fillView(this: *@This()) void { .bold = true, }, }; - this.view.?.writeCell(i, 0, cell); - } - - if (this.path) |path| { - // TODO: this could be a static string on the heap (due to the size of `513`) - for (0..path.len, this.view.?.screen.width / 2 - path.len / 2..) |i, col| { - const cell: vaxis.Cell = .{ - .char = .{ .grapheme = path[i .. i + 1] }, - .style = .{ - .ul_style = .single, - }, - }; - this.view.?.writeCell(col, 0, cell); - } - - // fill rest with default cells - for (this.view.?.screen.width / 2 + path.len..this.view.?.screen.width) |i| { - this.view.?.writeCell(i, 0, .{ .default = true }); - } + this.view.?.writeCell(this.view.?.screen.width - msg.len - 3 + i, 0, cell); } }