From fba8984cf84e4b8d3563e7d4624cd56ce35d1fec Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 24 May 2024 09:02:42 -0500 Subject: [PATCH] window(print): check for col after loop and at very beginning --- src/Window.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Window.zig b/src/Window.zig index f8c2c44..0a02098 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -289,6 +289,10 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print const overflow: bool = blk: for (segments) |segment| { var iter = self.screen.unicode.graphemeIterator(segment.text); while (iter.next()) |grapheme| { + if (col >= self.width) { + row += 1; + col = 0; + } if (row >= self.height) break :blk true; const s = grapheme.bytes(segment.text); if (std.mem.eql(u8, s, "\n")) { @@ -296,10 +300,6 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print col = 0; continue; } - if (col >= self.width) { - row += 1; - col = 0; - } const w = self.gwidth(s); if (w == 0) continue; if (opts.commit) self.writeCell(col, row, .{ @@ -313,7 +313,10 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print col += w; } } else false; - + if (col >= self.width) { + row += 1; + col = 0; + } return .{ .row = row, .col = col,