render multiple lines

This commit is contained in:
Mitchell Hashimoto
2022-04-19 08:42:37 -07:00
parent 81d8ca5b9c
commit e9661fa55e
3 changed files with 9 additions and 1 deletions

View File

@ -231,6 +231,9 @@ pub fn updateCells(self: *Grid, term: Terminal) !void {
for (term.screen.items) |line, y| { for (term.screen.items) |line, y| {
for (line.items) |cell, x| { for (line.items) |cell, x| {
// It can be zero if the cell is empty
if (cell.empty()) continue;
// Get our glyph // Get our glyph
const glyph = try self.font_atlas.addGlyph(self.alloc, cell.char); const glyph = try self.font_atlas.addGlyph(self.alloc, cell.char);

View File

@ -89,7 +89,7 @@ pub fn create(alloc: Allocator) !*Window {
// Create our terminal // Create our terminal
var term = Terminal.init(grid.size.columns, grid.size.rows); var term = Terminal.init(grid.size.columns, grid.size.rows);
errdefer term.deinit(alloc); errdefer term.deinit(alloc);
try term.append(alloc, "hello!"); try term.append(alloc, "hello!\r\nworld!");
self.* = .{ self.* = .{
.window = window, .window = window,

View File

@ -32,6 +32,11 @@ const Cell = struct {
char: u32, char: u32,
// TODO(mitchellh): this is where we'll track fg/bg and other attrs. // 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. /// Cursor represents the cursor state.