add(error): introduce zterm.Error containing all zterm errors with their corresponding description
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 28s

This commit is contained in:
2025-03-01 15:19:42 +01:00
parent 91794a0197
commit ae9cd08b15
3 changed files with 12 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ const Cell = @import("cell.zig");
const Color = @import("color.zig").Color;
const Size = @import("size.zig").Size;
const Style = @import("style.zig");
const Error = @import("error.zig").Error;
const log = std.log.scoped(.container);
@@ -144,7 +145,7 @@ pub const Rectangle = packed struct {
/// children accordingly without removing the coloring of the `Rectangle`
fill: Color = .default,
// NOTE: caller owns `cells` slice and ensures that `cells.len == size.cols * size.rows`
// NOTE: caller owns `Cells` slice and ensures that `cells.len == size.cols * size.rows`
pub fn contents(this: @This(), cells: []Cell, size: Size) void {
std.debug.assert(cells.len == @as(usize, size.cols) * @as(usize, size.rows));
@@ -600,8 +601,8 @@ pub fn Container(comptime Event: type) type {
size.rows,
});
this.size = size;
if (this.properties.fixed_size.cols > 0 and size.cols < this.properties.fixed_size.cols) return error.TooSmall;
if (this.properties.fixed_size.rows > 0 and size.rows < this.properties.fixed_size.rows) return error.TooSmall;
if (this.properties.fixed_size.cols > 0 and size.cols < this.properties.fixed_size.cols) return Error.TooSmall;
if (this.properties.fixed_size.rows > 0 and size.rows < this.properties.fixed_size.rows) return Error.TooSmall;
try this.element.handle(event);
@@ -623,8 +624,8 @@ pub fn Container(comptime Event: type) type {
}
// check if the available screen is large enough
switch (layout.direction) {
.horizontal => if (fixed_size.cols > size.cols) return error.TooSmall,
.vertical => if (fixed_size.rows > size.rows) return error.TooSmall,
.horizontal => if (fixed_size.cols > size.cols) return Error.TooSmall,
.vertical => if (fixed_size.rows > size.rows) return Error.TooSmall,
}
const sides = this.properties.border.sides;
const padding = layout.padding;