vaxis: conditionally rely on terminal wrap to reposition cursor
If the text was printed with a wrap, and we can determine this from the `print` method in Window, then we rely on the terminal for wrapping. This can help with primary screen text reflowing on resize
This commit is contained in:
parent
1a52178c1f
commit
2605613019
3 changed files with 7 additions and 1 deletions
|
@ -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 {
|
||||
|
|
|
@ -366,6 +366,8 @@ pub fn render(self: *Vaxis, tty: AnyWriter) !void {
|
|||
if (col >= self.screen.width) {
|
||||
row += 1;
|
||||
col = 0;
|
||||
// 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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue