diff --git a/Examples.md b/Examples.md index 8db3c8e..a55f6b7 100644 --- a/Examples.md +++ b/Examples.md @@ -6,14 +6,20 @@ You can build the every example through the example option. For example: 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] > 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: - Overall examples: diff --git a/Roadmap.md b/Roadmap.md index 57a2ad8..316153f 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -2,6 +2,12 @@ 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 - [x] Layout - [x] direction @@ -24,14 +30,14 @@ The following list contains goals for certain features the library supports or i - [x] mouse support - [x] user content - [ ] Default `Element` implementations - - [ ] Scrollable + - [x] Scrollable - [x] user input handling - [x] vertical - [x] horizontal - [x] mouse input - - [ ] scroll bar(s) rendering - - [ ] vertical - - [ ] horizontal + - [x] scroll bar(s) rendering + - [x] vertical + - [x] horizontal - [ ] Content alignment (i.e. standard calculations done with the provided `Size`) - [ ] horizontal 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 - [x] Button - [x] Text Input field + - [ ] overflow handling, i.e. where to draw the elipse `..` - left, center or right (**later**) - [ ] Popup-menu - [x] Scrollable Content (i.e. show long text of an except of something and other smaller `Container`) - [x] min size - [x] mouse scrolling aware of mouse position (i.e. through multiple different scrollable `Container`) + - [ ] scrollable contents through other inputs except mouse? - [ ] Styles - [ ] Text styles - [ ] Colors @@ -73,10 +81,9 @@ The following list contains goals for certain features the library supports or i - [x] Color palette - [x] Error Handling - 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] 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] 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 @@ -90,3 +97,11 @@ The following list contains goals for certain features the library supports or i - *padding* of `Container` - *gap* 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**) diff --git a/Testing.md b/Testing.md index 3eb7fa9..d7391e1 100644 --- a/Testing.md +++ b/Testing.md @@ -31,7 +31,8 @@ test "create container zon file" { defer renderer.deinit(); try renderer.resize(size); - container.resize(.{}, size); + container.resize(size); + container.reposition(.{}); try renderer.render(Container(event.SystemEvent), &container); // 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); 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 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 allocator = std.testing.allocator; - const size: Size = .{ - .rows = 20, - .cols = 30, + const size: Point = .{ + .x = 30, + .y = 20, }; var box: Container(event.SystemEvent) = try .init(allocator, .{ @@ -114,6 +117,9 @@ test "scrollable vertical" { .direction = .vertical, .padding = .all(1), }, + .size = .{ + .dim = .{ .y = size.y + 15 }, + }, }, .{}); try box.append(try .init(allocator, .{ .rectangle = .{ .fill = .grey }, @@ -123,7 +129,7 @@ test "scrollable vertical" { }, .{})); 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, .{ .border = .{ @@ -136,32 +142,33 @@ test "scrollable vertical" { var renderer: testing.Renderer = .init(allocator, size); defer renderer.deinit(); - try container.handle(.{ .resize = size }); + container.resize(size); + container.reposition(.{}); 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) for (0..15) |_| try container.handle(.{ .mouse = .{ .button = .wheel_down, .kind = .press, - .col = 5, - .row = 5, + .x = 5, + .y = 5, }, }); 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 try container.handle(.{ .mouse = .{ .button = .wheel_down, .kind = .press, - .col = 5, - .row = 5, + .x = 5, + .y = 5, }, }); 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); } ```