Handle termbox2 errors

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2026-05-17 13:26:46 +02:00
parent 05c1d4bece
commit 4c066ce564
17 changed files with 114 additions and 90 deletions

View File

@@ -71,14 +71,14 @@ fn draw(self: *Cascade) void {
if ((self.buffer.random.int(u16) % 10) > 7) continue;
cell.?.put(x, y);
cell.?.put(x, y) catch {};
var space = Cell.init(
' ',
cell_under.?.fg,
cell_under.?.bg,
);
space.put(x, y - 1);
space.put(x, y - 1) catch {};
}
}
@@ -87,6 +87,6 @@ fn draw(self: *Cascade) void {
self.current_auth_fails.* = 0;
}
TerminalBuffer.presentBuffer();
TerminalBuffer.presentBuffer() catch {};
}
}

View File

@@ -114,7 +114,7 @@ fn draw(self: *ColorMix) void {
}
const cell = self.palette[@as(usize, @trunc(math.floor(length(uv) * 5.0))) % palette_len];
cell.put(x, y);
cell.put(x, y) catch {};
}
}
}

View File

@@ -129,13 +129,13 @@ fn draw(self: *Doom) void {
// Send known fire levels to terminal buffer
const from_cell = self.fire[level_buf_from];
const to_cell = self.fire[level_buf_to];
from_cell.put(x, y);
to_cell.put(to_x, to_y);
from_cell.put(x, y) catch {};
to_cell.put(to_x, to_y) catch {};
}
// Draw bottom line (fire source)
const src_cell = self.fire[STEPS];
src_cell.put(x, self.terminal_buffer.height - 1);
src_cell.put(x, self.terminal_buffer.height - 1) catch {};
}
}

View File

@@ -535,7 +535,7 @@ fn draw(self: *DurFile) void {
const cell = Cell{ .ch = @intCast(codepoint), .fg = fg_color, .bg = bg_color };
self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell);
self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell) catch {};
}
}

View File

@@ -146,7 +146,7 @@ fn draw(self: *GameOfLife) void {
const row_offset = y * self.width;
for (0..self.width) |x| {
const cell = if (self.current_grid[row_offset + x]) alive_cell else self.dead_cell;
cell.put(x, y);
cell.put(x, y) catch {};
}
}
}

View File

@@ -200,9 +200,9 @@ fn draw(self: *Matrix) void {
.bg = self.terminal_buffer.bg,
};
cell.put(x, y - 1);
cell.put(x, y - 1) catch {};
// Fill background in between columns
self.default_cell.put(x + 1, y - 1);
self.default_cell.put(x + 1, y - 1) catch {};
}
}
}