mod(structure): update project structure

Remove examples, add description for design goals in README.md and
apply re-names and naming changes accordingly for the project structure.
Implement a flat hierachry, as the library shall remain pretty simple.
This commit is contained in:
2025-01-30 23:02:34 +01:00
parent 3decc541a9
commit bdbe05c996
41 changed files with 204 additions and 3474 deletions

View File

@@ -3,26 +3,31 @@
const std = @import("std");
const terminal = @import("terminal.zig");
const Size = terminal.Size;
const Key = terminal.Key;
pub const Error = struct {
err: anyerror,
msg: []const u8,
};
const Size = @import("size.zig");
const Key = @import("key.zig");
// System events available to every application.
// TODO: should this also already include the .view enum option?
pub const SystemEvent = union(enum) {
/// Initialize event, which is send once at the beginning of the event loop and before the first render loop
init,
/// Quit event to signify the end of the event loop (rendering should stop afterwards)
quit,
err: Error,
/// Error event to notify other containers about a recoverable error
err: struct {
err: anyerror,
/// associated error message
msg: []const u8,
},
/// Resize event emitted by the terminal to derive the `Size` of the current terminal the application is rendered in
resize: Size,
/// Input key event received from the user
key: Key,
/// Focus event for mouse interaction
/// TODO: this should instead be a union with a `Size` to derive which container / element the focus meant for
focus: bool,
};
pub fn mergeTaggedUnions(comptime A: type, comptime B: type) type {
// TODO: should this expect one of the unions to contain the .view value option with its corresponding associated type?
if (!isTaggedUnion(A) or !isTaggedUnion(B)) {
@compileError("Both types for merging tagged unions need to be of type `union(enum)`.");
}