mirror of
https://github.com/fairyglade/ly.git
synced 2026-05-13 18:40:46 +00:00
Fix labels_max_length calculation (closes #984)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
21
src/main.zig
21
src/main.zig
@@ -380,7 +380,16 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
|
|
||||||
// Initialize terminal buffer
|
// Initialize terminal buffer
|
||||||
try state.log_file.info(state.io, "tui", "initializing terminal buffer", .{});
|
try state.log_file.info(state.io, "tui", "initializing terminal buffer", .{});
|
||||||
state.labels_max_length = @max(TerminalBuffer.strWidth(state.lang.login), TerminalBuffer.strWidth(state.lang.password));
|
var labels = [_][]const u8{
|
||||||
|
state.lang.login,
|
||||||
|
state.lang.password,
|
||||||
|
state.lang.wayland,
|
||||||
|
state.lang.x11,
|
||||||
|
state.lang.shell,
|
||||||
|
state.lang.xinitrc,
|
||||||
|
state.lang.custom,
|
||||||
|
};
|
||||||
|
state.labels_max_length = maxWidths(&labels);
|
||||||
|
|
||||||
var seed: u64 = undefined;
|
var seed: u64 = undefined;
|
||||||
state.io.random(std.mem.asBytes(&seed)); // Get a random seed for the PRNG (used by animations)
|
state.io.random(std.mem.asBytes(&seed)); // Get a random seed for the PRNG (used by animations)
|
||||||
@@ -1333,6 +1342,16 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn maxWidths(labels: [][]const u8) usize {
|
||||||
|
var max_width: usize = 0;
|
||||||
|
|
||||||
|
for (labels) |label| {
|
||||||
|
max_width = @max(max_width, TerminalBuffer.strWidth(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
return max_width;
|
||||||
|
}
|
||||||
|
|
||||||
fn uiErrorHandler(err: anyerror, ctx: *anyopaque) anyerror!void {
|
fn uiErrorHandler(err: anyerror, ctx: *anyopaque) anyerror!void {
|
||||||
var state: *UiState = @ptrCast(@alignCast(ctx));
|
var state: *UiState = @ptrCast(@alignCast(ctx));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user