doc: update testing, examples and roadmap documentation

2025-05-21 18:45:26 +02:00
parent c4ada05339
commit 6a342ba26b
3 changed files with 54 additions and 26 deletions

@@ -6,14 +6,20 @@ You can build the every example through the example option. For example:
zig build --release=safe -Dexample=demo run zig build --release=safe -Dexample=demo run
``` ```
> [!NOTE]
> In debug build mode log messages will be written to stderr. You can pipe the output of stderr to a file when running in debug mode to not disturb the tui rendering. e.g. `zig build run 2> log`
For all available examples run `zig build --help`
> [!TIP] > [!TIP]
> Every example application can be quit using `ctrl+c`. > Every example application can be quit using `ctrl+c`.
You can also build all examples by providing no argument for the example option, as the default builds all examples.
```sh
zig build
```
> [!NOTE]
> In debug build mode log messages will be written to stderr. You can pipe the output of stderr to a file when running in debug mode to not disturb the tui rendering. e.g. `./zig-out/bin/demo run 2> log`
For all available examples run `zig build --help`
The examples are structured in four categories: The examples are structured in four categories:
- Overall examples: - Overall examples:

@@ -2,6 +2,12 @@
The following list contains goals for certain features the library supports or is planned on supporting. The following list contains goals for certain features the library supports or is planned on supporting.
- [ ] Input handling
- [x] basic input handling
- [ ] support modifiers with other control characters (i.e. `SHIFT + TAB`, `SHIFT + ENTER`)
- [ ] support input's (i.e. `Esc x`, `Esc 0 x` or SS3, `Esc [ ..` or Csi, Osc, Dcs) see [src/vt.rs:156] and [src/input.rs:324] for the actual parsing implementation
- [ ] Clipboard support (reading and writing)
- [ ] Container rendering - [ ] Container rendering
- [x] Layout - [x] Layout
- [x] direction - [x] direction
@@ -24,14 +30,14 @@ The following list contains goals for certain features the library supports or i
- [x] mouse support - [x] mouse support
- [x] user content - [x] user content
- [ ] Default `Element` implementations - [ ] Default `Element` implementations
- [ ] Scrollable - [x] Scrollable
- [x] user input handling - [x] user input handling
- [x] vertical - [x] vertical
- [x] horizontal - [x] horizontal
- [x] mouse input - [x] mouse input
- [ ] scroll bar(s) rendering - [x] scroll bar(s) rendering
- [ ] vertical - [x] vertical
- [ ] horizontal - [x] horizontal
- [ ] Content alignment (i.e. standard calculations done with the provided `Size`) - [ ] Content alignment (i.e. standard calculations done with the provided `Size`)
- [ ] horizontal center (i.e. calculate the corresponding anchor) - [ ] horizontal center (i.e. calculate the corresponding anchor)
- [ ] vertical center (i.e. calculate the corresponding anchor) - [ ] vertical center (i.e. calculate the corresponding anchor)
@@ -49,10 +55,12 @@ The following list contains goals for certain features the library supports or i
- [ ] Elements - [ ] Elements
- [x] Button - [x] Button
- [x] Text Input field - [x] Text Input field
- [ ] overflow handling, i.e. where to draw the elipse `..` - left, center or right (**later**)
- [ ] Popup-menu - [ ] Popup-menu
- [x] Scrollable Content (i.e. show long text of an except of something and other smaller `Container`) - [x] Scrollable Content (i.e. show long text of an except of something and other smaller `Container`)
- [x] min size - [x] min size
- [x] mouse scrolling aware of mouse position (i.e. through multiple different scrollable `Container`) - [x] mouse scrolling aware of mouse position (i.e. through multiple different scrollable `Container`)
- [ ] scrollable contents through other inputs except mouse?
- [ ] Styles - [ ] Styles
- [ ] Text styles - [ ] Text styles
- [ ] Colors - [ ] Colors
@@ -73,10 +81,9 @@ The following list contains goals for certain features the library supports or i
- [x] Color palette - [x] Color palette
- [x] Error Handling - [x] Error Handling
- log and show error's without crashing the application - log and show error's without crashing the application
- [ ] Demo - [x] Demo
- [x] use another tui application to launch and come back to (showcase the interrupt behavior) - [x] use another tui application to launch and come back to (showcase the interrupt behavior)
- [x] Launch sub-applications (not inside of a `Container` but during the application workflow, like an editor) - [x] Launch sub-applications (not inside of a `Container` but during the application workflow, like an editor)
- [ ] implement some functionality to have it be more like a working demo application
- [x] Testability - [x] Testability
- [x] snapshot ability to safe current screen (from `Renderer`) to test against - [x] snapshot ability to safe current screen (from `Renderer`) to test against
- See [Testing](Testing.md) for details on how to create the `.zon` files containing the expected screen data - See [Testing](Testing.md) for details on how to create the `.zon` files containing the expected screen data
@@ -90,3 +97,11 @@ The following list contains goals for certain features the library supports or i
- *padding* of `Container` - *padding* of `Container`
- *gap* of `Container` - *gap* of `Container`
- *separator* of `Container` - *separator* of `Container`
- [ ] `Element` extensions:
- provide a reference to the parent `Container` of a given `Element`
-> allow changing the parent's *properties* through an `Element` implementation (i.e. change the color of the border, add a new child element, etc.) if necessary! otherwise I would rather have this be very independent of its parent (and where it is used or rendered!)
- [ ] Capabilities
- [ ] support setting terminal title
- [ ] SIMD support - evaluation necessary (**later**)

@@ -31,7 +31,8 @@ test "create container zon file" {
defer renderer.deinit(); defer renderer.deinit();
try renderer.resize(size); try renderer.resize(size);
container.resize(.{}, size); container.resize(size);
container.reposition(.{});
try renderer.render(Container(event.SystemEvent), &container); try renderer.render(Container(event.SystemEvent), &container);
// NOTE: this is dependent on the working directory the test will be executed in // NOTE: this is dependent on the working directory the test will be executed in
@@ -78,10 +79,12 @@ pub fn expectContainerScreen(size: Size, container: *Container(event.SystemEvent
var renderer: Renderer = .init(allocator, size); var renderer: Renderer = .init(allocator, size);
defer renderer.deinit(); defer renderer.deinit();
try container.handle(.{ .resize = size }); try renderer.resize(size);
container.resize(size);
container.reposition(.{});
try renderer.render(Container(event.SystemEvent), container); try renderer.render(Container(event.SystemEvent), container);
try expectEqualCells(renderer.size, expected, renderer.screen); try expectEqualCells(.{}, renderer.size, expected, renderer.screen);
} }
``` ```
@@ -96,9 +99,9 @@ test "scrollable vertical" {
const testing = @import("testing.zig"); const testing = @import("testing.zig");
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const size: Size = .{ const size: Point = .{
.rows = 20, .x = 30,
.cols = 30, .y = 20,
}; };
var box: Container(event.SystemEvent) = try .init(allocator, .{ var box: Container(event.SystemEvent) = try .init(allocator, .{
@@ -114,6 +117,9 @@ test "scrollable vertical" {
.direction = .vertical, .direction = .vertical,
.padding = .all(1), .padding = .all(1),
}, },
.size = .{
.dim = .{ .y = size.y + 15 },
},
}, .{}); }, .{});
try box.append(try .init(allocator, .{ try box.append(try .init(allocator, .{
.rectangle = .{ .fill = .grey }, .rectangle = .{ .fill = .grey },
@@ -123,7 +129,7 @@ test "scrollable vertical" {
}, .{})); }, .{}));
defer box.deinit(); defer box.deinit();
var scrollable: Scrollable(event.SystemEvent) = .init(box, .{ .rows = size.rows + 15 }); var scrollable: Scrollable(event.SystemEvent) = .init(box, .disabled);
var container: Container(event.SystemEvent) = try .init(allocator, .{ var container: Container(event.SystemEvent) = try .init(allocator, .{
.border = .{ .border = .{
@@ -136,32 +142,33 @@ test "scrollable vertical" {
var renderer: testing.Renderer = .init(allocator, size); var renderer: testing.Renderer = .init(allocator, size);
defer renderer.deinit(); defer renderer.deinit();
try container.handle(.{ .resize = size }); container.resize(size);
container.reposition(.{});
try renderer.render(Container(event.SystemEvent), &container); try renderer.render(Container(event.SystemEvent), &container);
try testing.expectEqualCells(renderer.size, @import("test/element/scrollable.vertical.top.zon"), renderer.screen); try testing.expectEqualCells(.{}, renderer.size, @import("test/element/scrollable.vertical.top.zon"), renderer.screen);
// scroll down 15 times (exactly to the end) // scroll down 15 times (exactly to the end)
for (0..15) |_| try container.handle(.{ for (0..15) |_| try container.handle(.{
.mouse = .{ .mouse = .{
.button = .wheel_down, .button = .wheel_down,
.kind = .press, .kind = .press,
.col = 5, .x = 5,
.row = 5, .y = 5,
}, },
}); });
try renderer.render(Container(event.SystemEvent), &container); try renderer.render(Container(event.SystemEvent), &container);
try testing.expectEqualCells(renderer.size, @import("test/element/scrollable.vertical.bottom.zon"), renderer.screen); try testing.expectEqualCells(.{}, renderer.size, @import("test/element/scrollable.vertical.bottom.zon"), renderer.screen);
// further scrolling down will not change anything // further scrolling down will not change anything
try container.handle(.{ try container.handle(.{
.mouse = .{ .mouse = .{
.button = .wheel_down, .button = .wheel_down,
.kind = .press, .kind = .press,
.col = 5, .x = 5,
.row = 5, .y = 5,
}, },
}); });
try renderer.render(Container(event.SystemEvent), &container); try renderer.render(Container(event.SystemEvent), &container);
try testing.expectEqualCells(renderer.size, @import("test/element/scrollable.vertical.bottom.zon"), renderer.screen); try testing.expectEqualCells(.{}, renderer.size, @import("test/element/scrollable.vertical.bottom.zon"), renderer.screen);
} }
``` ```