Add option for position of version string

Version string is located at left top corner originally, but that will
cause the first line labels too long and not easy to read.
This commit add a option in config to decide which corner to display
version string.
This commit is contained in:
nyraa 2025-09-10 18:09:37 +08:00
parent ee97f3b5e1
commit 5ab0ecb229
3 changed files with 17 additions and 2 deletions

View File

@ -186,6 +186,9 @@ hide_borders = false
# Remove version number from the top left corner
hide_version_string = false
# Position of version string (0: top-left, 1: top-right, 2: bottom-left, 3: bottom-right)
version_string_pos = 0
# Remove power management command hints
hide_key_hints = false

View File

@ -48,6 +48,7 @@ gameoflife_frame_delay: usize = 6,
gameoflife_initial_density: f32 = 0.4,
hide_borders: bool = false,
hide_version_string: bool = false,
version_string_pos: u8 = 0,
hide_key_hints: bool = false,
initial_info_text: ?[]const u8 = null,
input_len: u8 = 34,

View File

@ -538,8 +538,19 @@ pub fn main() !void {
if (!animation_timed_out) animation.draw();
if (!config.hide_version_string) {
buffer.drawLabel(ly_top_str, length, 0);
length += ly_top_str.len + 1;
switch (config.version_string_pos) {
// top-right
1 => buffer.drawLabel(ly_top_str, buffer.width - ly_top_str.len, 0),
// bottom-left
2 => buffer.drawLabel(ly_top_str, 0, buffer.height - 1),
// bottom-right
3 => buffer.drawLabel(ly_top_str, buffer.width - ly_top_str.len, buffer.height - 1),
// top-left, default
else => {
buffer.drawLabel(ly_top_str, 0, 0);
length += ly_top_str.len + 1;
},
}
}
if (config.bigclock != .none and buffer.box_height + (bigclock.HEIGHT + 2) * 2 < buffer.height) {