positionWidgets: Less integer overflows possible

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2026-07-10 00:15:07 +02:00
parent d00780d6ce
commit 84950136c9
3 changed files with 20 additions and 9 deletions

View File

@@ -129,8 +129,10 @@ fn draw(self: *Lua) void {
cell.put(x, y) catch {};
if (self.lua_str) |str|
for (str, 0..) |c, i| {
const dwidth = @divFloor(self.width, 2);
const dlen = @divFloor(str.len, 2);
Cell.init(c, 0x00FFFFFF, 0).put(
@divFloor(self.width, 2) - @divFloor(str.len, 2) + i,
(if (dlen > dwidth) 0 else dwidth - dlen) + i,
self.margin + 5,
) catch {};
};