mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-26 23:44:19 +02:00
positionWidgets: Less integer overflows possible
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
d00780d6ce
commit
84950136c9
3 changed files with 20 additions and 9 deletions
|
|
@ -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 {};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue