window(print): check for col after loop and at very beginning
This commit is contained in:
parent
409e17b883
commit
fba8984cf8
1 changed files with 8 additions and 5 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue