diff --git a/README.md b/README.md index e2e9686..af5a037 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,3 @@ It contains information about me and my projects as well as blog entries about s ## zterm This tui application also serves as an example implementation of the [zterm](https://gitea.yves-biener.de/yves-biener/zterm) library. - ---- - -## Open tasks - -- [ ] Improve navigation -- [ ] Have clickable/navigatable links inside of the tui application -- [ ] Launch simple http server alongside tui application diff --git a/doc/about.md b/doc/about.md new file mode 100644 index 0000000..0bc3b2c --- /dev/null +++ b/doc/about.md @@ -0,0 +1,3 @@ +# About + +Hi, I'm Yves. I'm a developer who <3 the terminal and everything around text interfaces. diff --git a/doc/blog.md b/doc/blog.md new file mode 100644 index 0000000..0b3cb8f --- /dev/null +++ b/doc/blog.md @@ -0,0 +1,5 @@ +# Blog + +This is the main entry page for my blog. I plan on writing on things I feel like worth sharing, mentioning for other developers, tinkers like me. + +The blog is currently a work in progress and will be updated once a first version of the tui website supports more dynamic contents. diff --git a/src/content.zig b/src/content.zig new file mode 100644 index 0000000..a18c92c --- /dev/null +++ b/src/content.zig @@ -0,0 +1,59 @@ +pub fn Content(App: type) type { + return struct { + pub fn init(allocator: Allocator) @This() { + _ = allocator; + return .{}; + } + + pub fn element(this: *@This()) App.Element { + return .{ + .ptr = this, + .vtable = &.{ + .handle = handle, + .content = content, + }, + }; + } + + fn handle(ctx: *anyopaque, model: *App.Model, event: App.Event) !void { + _ = ctx; + switch (event) { + .about => model.page = .about, + .blog => model.page = .blog, + else => {}, + } + } + + fn content(ctx: *anyopaque, model: *const App.Model, cells: []zterm.Cell, size: zterm.Point) !void { + _ = ctx; + assert(cells.len == @as(usize, size.x) * @as(usize, size.y)); + + const text = switch (model.page) { + .about => @embedFile("about"), + .blog => @embedFile("blog"), + }; + var index: usize = 0; + + for (0..size.y) |row| { + for (0..size.x) |col| { + const cell = row * size.x + col; + assert(cell < cells.len); + + if (index == text.len) return; + const cp = text[index]; + index += 1; + + cells[cell].cp = switch (cp) { + '\n' => break, + else => cp, + }; + } + } + } + }; +} + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const assert = std.debug.assert; +const zterm = @import("zterm"); diff --git a/src/model.zig b/src/model.zig new file mode 100644 index 0000000..23608a0 --- /dev/null +++ b/src/model.zig @@ -0,0 +1,6 @@ +page: Pages = .blog, + +const Pages = enum { + about, + blog, +};