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

@@ -207,7 +207,7 @@ fn alphaBlit(x: usize, y: usize, tb_width: usize, tb_height: usize, cells: [CHAR
for (0..CHAR_HEIGHT) |yy| {
for (0..CHAR_WIDTH) |xx| {
const cell = cells[yy * CHAR_WIDTH + xx];
cell.put(x + xx, y + yy);
cell.put(x + xx, y + yy) catch {};
}
}
}

View File

@@ -129,29 +129,29 @@ fn draw(self: *Box) void {
self.bg,
);
left_up.put(self.left_pos.x - 1, self.left_pos.y - 1);
right_up.put(self.right_pos.x, self.left_pos.y - 1);
left_down.put(self.left_pos.x - 1, self.right_pos.y);
right_down.put(self.right_pos.x, self.right_pos.y);
left_up.put(self.left_pos.x - 1, self.left_pos.y - 1) catch {};
right_up.put(self.right_pos.x, self.left_pos.y - 1) catch {};
left_down.put(self.left_pos.x - 1, self.right_pos.y) catch {};
right_down.put(self.right_pos.x, self.right_pos.y) catch {};
for (0..self.width) |i| {
top.put(self.left_pos.x + i, self.left_pos.y - 1);
bottom.put(self.left_pos.x + i, self.right_pos.y);
top.put(self.left_pos.x + i, self.left_pos.y - 1) catch {};
bottom.put(self.left_pos.x + i, self.right_pos.y) catch {};
}
top.ch = self.buffer.box_chars.left;
bottom.ch = self.buffer.box_chars.right;
for (0..self.height) |i| {
top.put(self.left_pos.x - 1, self.left_pos.y + i);
bottom.put(self.right_pos.x, self.left_pos.y + i);
top.put(self.left_pos.x - 1, self.left_pos.y + i) catch {};
bottom.put(self.right_pos.x, self.left_pos.y + i) catch {};
}
}
if (self.blank_box) {
for (0..self.height) |y| {
for (0..self.width) |x| {
self.buffer.blank_cell.put(self.left_pos.x + x, self.left_pos.y + y);
self.buffer.blank_cell.put(self.left_pos.x + x, self.left_pos.y + y) catch {};
}
}
}
@@ -164,7 +164,7 @@ fn draw(self: *Box) void {
self.width,
self.title_fg,
self.bg,
);
) catch {};
}
if (self.bottom_title) |title| {
@@ -175,7 +175,7 @@ fn draw(self: *Box) void {
self.width,
self.title_fg,
self.bg,
);
) catch {};
}
}

View File

@@ -117,7 +117,7 @@ fn draw(self: *Label) void {
width,
self.fg,
self.bg,
);
) catch {};
return;
}
@@ -127,7 +127,7 @@ fn draw(self: *Label) void {
self.component_pos.y,
self.fg,
self.bg,
);
) catch {};
}
fn update(self: *Label, ctx: *anyopaque) !void {

View File

@@ -131,14 +131,14 @@ pub fn handle(self: *Text, maybe_key: ?keyboard.Key) !void {
}
if (self.masked and self.maybe_mask == null) {
TerminalBuffer.setCursor(
try TerminalBuffer.setCursor(
self.component_pos.x,
self.component_pos.y,
);
return;
}
TerminalBuffer.setCursor(
try TerminalBuffer.setCursor(
self.component_pos.x + (self.cursor - self.visible_start),
self.component_pos.y,
);
@@ -159,7 +159,7 @@ fn draw(self: *Text) void {
length,
self.fg,
self.bg,
);
) catch {};
}
return;
}
@@ -182,7 +182,7 @@ fn draw(self: *Text) void {
self.component_pos.y,
self.fg,
self.bg,
);
) catch {};
}
fn goLeft(ptr: *anyopaque) !bool {

View File

@@ -105,8 +105,8 @@ pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) typ
self.current = self.list.items.len - 1;
}
pub fn handle(self: *Self, _: ?keyboard.Key) void {
TerminalBuffer.setCursor(
pub fn handle(self: *Self, _: ?keyboard.Key) !void {
try TerminalBuffer.setCursor(
self.component_pos.x + self.cursor + 2,
self.component_pos.y,
);
@@ -119,11 +119,11 @@ pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) typ
var left_arrow = Cell.init('<', self.fg, self.bg);
var right_arrow = Cell.init('>', self.fg, self.bg);
left_arrow.put(self.component_pos.x, self.component_pos.y);
left_arrow.put(self.component_pos.x, self.component_pos.y) catch {};
right_arrow.put(
self.component_pos.x + self.width - 1,
self.component_pos.y,
);
) catch {};
const current_item = self.list.items[self.current];
const x = self.component_pos.x + 2;