mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-21 03:34:54 +00:00
* Fix stray cursor, integer overflows and other bugs * check for getenvlist error, shorten code * fix cascade, set info_line before auth, make code clearer and a bug fix * Add option to turn on numlock at startup * Fix setting numlock * Update build.zig * Custom info text * Shift+Tab for previous input * update changelog and res/config * Some fixes * update build.zig * update build.zig again * Fix xauth command for some shells and fix building in ReleaseSafe * Use git describe to get dev version str * revert change to getLockState (it broke the doom animation) * add new ly error messages. Only try to make path for pam/exe during install when dest_directory is defined + print warning on error. * add warning message for workaround
34 lines
984 B
Zig
34 lines
984 B
Zig
const std = @import("std");
|
|
const utils = @import("../utils.zig");
|
|
const TerminalBuffer = @import("../TerminalBuffer.zig");
|
|
|
|
const InfoLine = @This();
|
|
|
|
text: []const u8 = "",
|
|
width: u8 = 0,
|
|
|
|
pub fn setText(self: *InfoLine, text: []const u8) !void {
|
|
self.width = if (text.len > 0) try utils.strWidth(text) else 0;
|
|
self.text = text;
|
|
}
|
|
|
|
pub fn draw(self: InfoLine, buffer: TerminalBuffer) void {
|
|
if (self.width > 0 and buffer.box_width > self.width) {
|
|
const label_y = buffer.box_y + buffer.margin_box_v;
|
|
const x = buffer.box_x + ((buffer.box_width - self.width) / 2);
|
|
|
|
buffer.drawLabel(self.text, x, label_y);
|
|
}
|
|
}
|
|
|
|
pub fn clearRendered(allocator: std.mem.Allocator, buffer: TerminalBuffer) !void {
|
|
// draw over the area
|
|
const y = buffer.box_y + buffer.margin_box_v;
|
|
const spaces = try allocator.alloc(u8, buffer.box_width);
|
|
defer allocator.free(spaces);
|
|
|
|
@memset(spaces, ' ');
|
|
|
|
buffer.drawLabel(spaces, buffer.box_x, y);
|
|
}
|