terminal/new: detect empty rows

This commit is contained in:
Mitchell Hashimoto
2024-02-19 21:30:31 -08:00
parent b5d7b0a87a
commit 94c6573e54
2 changed files with 13 additions and 0 deletions

View File

@ -87,6 +87,10 @@ pub fn dumpString(
break :cells cells[0..self.pages.cols];
};
if (!pagepkg.Cell.hasText(cells)) {
blank_rows += 1;
continue;
}
if (blank_rows > 0) {
for (0..blank_rows) |_| try writer.writeByte('\n');
blank_rows = 0;

View File

@ -198,6 +198,15 @@ pub const Row = packed struct(u18) {
pub const Cell = packed struct(u32) {
codepoint: u21 = 0,
_padding: u11 = 0,
/// Returns true if the set of cells has text in it.
pub fn hasText(cells: []const Cell) bool {
for (cells) |cell| {
if (cell.codepoint != 0) return true;
}
return false;
}
};
// Uncomment this when you want to do some math.