diff --git a/src/Cell.zig b/src/Cell.zig index 15d5484..e8a2197 100644 --- a/src/Cell.zig +++ b/src/Cell.zig @@ -6,6 +6,9 @@ style: Style = .{}, link: Hyperlink = .{}, image: ?Image.Placement = null, default: bool = false, +/// Set to true if this cell is the last cell printed in a row before wrap. Vaxis will determine if +/// it should rely on the terminal's autowrap feature which can help with primary screen resizes +wrapped: bool = false, /// Segment is a contiguous run of text that has a constant style pub const Segment = struct { diff --git a/src/Vaxis.zig b/src/Vaxis.zig index 18924a3..fc25ebe 100644 --- a/src/Vaxis.zig +++ b/src/Vaxis.zig @@ -366,7 +366,9 @@ pub fn render(self: *Vaxis, tty: AnyWriter) !void { if (col >= self.screen.width) { row += 1; col = 0; - reposition = true; + // Rely on terminal wrapping to reposition into next row instead of forcing it + if (!cell.wrapped) + reposition = true; } // If cell is the same as our last frame, we don't need to do // anything diff --git a/src/Window.zig b/src/Window.zig index 74b9eff..4181670 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -309,6 +309,7 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print }, .style = segment.style, .link = segment.link, + .wrapped = col + w >= self.width, }); col += w; }