diff --git a/src/Grid.zig b/src/Grid.zig index aa75c78ac..6dbc53302 100644 --- a/src/Grid.zig +++ b/src/Grid.zig @@ -231,6 +231,9 @@ pub fn updateCells(self: *Grid, term: Terminal) !void { for (term.screen.items) |line, y| { for (line.items) |cell, x| { + // It can be zero if the cell is empty + if (cell.empty()) continue; + // Get our glyph const glyph = try self.font_atlas.addGlyph(self.alloc, cell.char); diff --git a/src/Window.zig b/src/Window.zig index 66a328cdd..3c8c856b3 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -89,7 +89,7 @@ pub fn create(alloc: Allocator) !*Window { // Create our terminal var term = Terminal.init(grid.size.columns, grid.size.rows); errdefer term.deinit(alloc); - try term.append(alloc, "hello!"); + try term.append(alloc, "hello!\r\nworld!"); self.* = .{ .window = window, diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 608d4cb58..77fe678ca 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -32,6 +32,11 @@ const Cell = struct { char: u32, // TODO(mitchellh): this is where we'll track fg/bg and other attrs. + + /// True if the cell should be skipped for drawing + pub fn empty(self: Cell) bool { + return self.char == 0; + } }; /// Cursor represents the cursor state.