From e19a23b54c680223df83a47bcc592ad5080dce2f Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 6 Mar 2025 21:16:24 +0100 Subject: [PATCH] Allow using up to a UTF-32 codepoint as a password asterisk (closes #715) Signed-off-by: AnErrupTion --- res/config.ini | 2 ++ src/config/Config.zig | 2 +- src/tui/TerminalBuffer.zig | 2 +- src/tui/components/Text.zig | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/res/config.ini b/res/config.ini index b6def9a..6dd7af3 100644 --- a/res/config.ini +++ b/res/config.ini @@ -28,6 +28,8 @@ animation = none animation_timeout_sec = 0 # The character used to mask the password +# You can either type it directly as a UTF-8 character (like *), or use a UTF-32 +# codepoint (for example 0x2022 for a bullet point) # If null, the password will be hidden # Note: you can use a # by escaping it like so: \# asterisk = * diff --git a/src/config/Config.zig b/src/config/Config.zig index 0478173..6e4c6eb 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -8,7 +8,7 @@ const Bigclock = enums.Bigclock; animation: Animation = .none, animation_timeout_sec: u12 = 0, -asterisk: ?u8 = '*', +asterisk: ?u32 = '*', auth_fails: u64 = 10, bg: u32 = 0x00000000, bigclock: Bigclock = .none, diff --git a/src/tui/TerminalBuffer.zig b/src/tui/TerminalBuffer.zig index 8281814..ba75516 100644 --- a/src/tui/TerminalBuffer.zig +++ b/src/tui/TerminalBuffer.zig @@ -202,7 +202,7 @@ pub fn drawConfinedLabel(self: TerminalBuffer, text: []const u8, x: usize, y: us } } -pub fn drawCharMultiple(self: TerminalBuffer, char: u8, x: usize, y: usize, length: usize) void { +pub fn drawCharMultiple(self: TerminalBuffer, char: u32, x: usize, y: usize, length: usize) void { const cell = utils.initCell(char, self.fg, self.bg); for (0..length) |xx| utils.putCell(x + xx, y, cell); } diff --git a/src/tui/components/Text.zig b/src/tui/components/Text.zig index d694eb4..f2502d5 100644 --- a/src/tui/components/Text.zig +++ b/src/tui/components/Text.zig @@ -19,9 +19,9 @@ visible_length: usize, x: usize, y: usize, masked: bool, -maybe_mask: ?u8, +maybe_mask: ?u32, -pub fn init(allocator: Allocator, buffer: *TerminalBuffer, masked: bool, maybe_mask: ?u8) Text { +pub fn init(allocator: Allocator, buffer: *TerminalBuffer, masked: bool, maybe_mask: ?u32) Text { const text = DynamicString.init(allocator); return .{