fix: allow wrapping in putstr calls on scrollable vaxis planes

This commit is contained in:
CJ van den Berg 2024-05-20 11:06:27 +02:00
parent b3543f520c
commit 26232c3af3
2 changed files with 7 additions and 5 deletions

View file

@ -142,8 +142,6 @@ pub fn putstr(self: *Plane, text: []const u8) !usize {
const width = self.window.width;
var iter = self.window.screen.unicode.graphemeIterator(text);
while (iter.next()) |grapheme| {
if (self.col >= width)
return result;
const s = grapheme.bytes(text);
if (std.mem.eql(u8, s, "\n")) {
if (self.scrolling and self.row == height - 1)
@ -154,6 +152,12 @@ pub fn putstr(self: *Plane, text: []const u8) !usize {
result += 1;
continue;
}
if (self.col >= width) {
if (self.scrolling) {
self.row += 1;
self.col = 0;
} else return result;
}
self.write_cell(@intCast(self.col), @intCast(self.row), s);
result += 1;
}