From 2e7bb3eb58855034be63c682460d6486a948a791 Mon Sep 17 00:00:00 2001 From: Theo Gaige Date: Mon, 29 Dec 2025 23:39:10 +0100 Subject: [PATCH] Use buf_height and buf_width in Matrix.draw() (#903) ## What are the changes about? buf_height is declared at the start of the draw() function of the Matrix animation but both buf_height and self.terminal_buffer.height are used in the function. replace every occurence of self.terminal_buffer.height by buf_height for consistency. The same goes for buf_width and self.terminal_buffer.width. no functionnal changes ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/903 Reviewed-by: AnErrupTion Co-authored-by: Theo Gaige Co-committed-by: Theo Gaige --- src/animations/Matrix.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/animations/Matrix.zig b/src/animations/Matrix.zig index 5def466..9d01464 100644 --- a/src/animations/Matrix.zig +++ b/src/animations/Matrix.zig @@ -86,17 +86,17 @@ fn draw(self: *Matrix) void { self.count = 0; var x: usize = 0; - while (x < self.terminal_buffer.width) : (x += 2) { + while (x < buf_width) : (x += 2) { var tail: usize = 0; var line = &self.lines[x]; if (self.frame <= line.update) continue; - if (self.dots[x].value == null and self.dots[self.terminal_buffer.width + x].value == ' ') { + if (self.dots[x].value == null and self.dots[buf_width + x].value == ' ') { if (line.space > 0) { line.space -= 1; } else { const randint = self.terminal_buffer.random.int(u16); - const h = self.terminal_buffer.height; + const h = buf_height; line.length = @mod(randint, h - 3) + 3; self.dots[x].value = @mod(randint, self.max_codepoint) + self.min_codepoint; line.space = @mod(randint, h + 1); @@ -153,7 +153,7 @@ fn draw(self: *Matrix) void { var x: usize = 0; while (x < buf_width) : (x += 2) { var y: usize = 1; - while (y <= self.terminal_buffer.height) : (y += 1) { + while (y <= buf_height) : (y += 1) { const dot = self.dots[buf_width * y + x]; const cell = if (dot.value == null or dot.value == ' ') self.default_cell else Cell{ .ch = @intCast(dot.value.?),