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| {
|
const overflow: bool = blk: for (segments) |segment| {
|
||||||
var iter = self.screen.unicode.graphemeIterator(segment.text);
|
var iter = self.screen.unicode.graphemeIterator(segment.text);
|
||||||
while (iter.next()) |grapheme| {
|
while (iter.next()) |grapheme| {
|
||||||
|
if (col >= self.width) {
|
||||||
|
row += 1;
|
||||||
|
col = 0;
|
||||||
|
}
|
||||||
if (row >= self.height) break :blk true;
|
if (row >= self.height) break :blk true;
|
||||||
const s = grapheme.bytes(segment.text);
|
const s = grapheme.bytes(segment.text);
|
||||||
if (std.mem.eql(u8, s, "\n")) {
|
if (std.mem.eql(u8, s, "\n")) {
|
||||||
|
@ -296,10 +300,6 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print
|
||||||
col = 0;
|
col = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (col >= self.width) {
|
|
||||||
row += 1;
|
|
||||||
col = 0;
|
|
||||||
}
|
|
||||||
const w = self.gwidth(s);
|
const w = self.gwidth(s);
|
||||||
if (w == 0) continue;
|
if (w == 0) continue;
|
||||||
if (opts.commit) self.writeCell(col, row, .{
|
if (opts.commit) self.writeCell(col, row, .{
|
||||||
|
@ -313,7 +313,10 @@ pub fn print(self: Window, segments: []const Segment, opts: PrintOptions) !Print
|
||||||
col += w;
|
col += w;
|
||||||
}
|
}
|
||||||
} else false;
|
} else false;
|
||||||
|
if (col >= self.width) {
|
||||||
|
row += 1;
|
||||||
|
col = 0;
|
||||||
|
}
|
||||||
return .{
|
return .{
|
||||||
.row = row,
|
.row = row,
|
||||||
.col = col,
|
.col = col,
|
||||||
|
|
Loading…
Reference in a new issue