Replace vaxis with zterm #1
11
README.md
11
README.md
@@ -4,6 +4,17 @@ This is my terminal based website. It is served as a tui application via ssh and
|
|||||||
|
|
||||||
It contains information about me and my projects as well as blog entries about something I feel like writing something about.
|
It contains information about me and my projects as well as blog entries about something I feel like writing something about.
|
||||||
|
|
||||||
|
## Terminal User Interface
|
||||||
|
|
||||||
|
### Benchmark
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zig build -Dbenchmark run 2> log
|
||||||
|
```
|
||||||
|
|
||||||
|
_Press any button_ at the end of the benchmark (when you are back to the original screen). `log` now contains the frame
|
||||||
|
delay for each frame in each line of the output.
|
||||||
|
|
||||||
## Open tasks
|
## Open tasks
|
||||||
|
|
||||||
- [ ] Improve navigation
|
- [ ] Improve navigation
|
||||||
|
|||||||
@@ -31,20 +31,34 @@ pub fn Layout(comptime Event: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle(this: *@This(), event: Event) !*Events {
|
pub fn handle(this: *@This(), event: Event) !*Events {
|
||||||
switch (event) {
|
|
||||||
else => {},
|
|
||||||
}
|
|
||||||
this.events.clearRetainingCapacity();
|
this.events.clearRetainingCapacity();
|
||||||
|
switch (event) {
|
||||||
|
.resize => |size| {
|
||||||
|
const widget_event: Event = .{
|
||||||
|
.resize = .{
|
||||||
|
.cols = size.cols,
|
||||||
|
.rows = size.rows -| 2, // remove top and bottom rows
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (this.widget.handle(widget_event)) |e| {
|
||||||
|
try this.events.append(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
else => {
|
||||||
if (this.widget.handle(event)) |e| {
|
if (this.widget.handle(event)) |e| {
|
||||||
try this.events.append(e);
|
try this.events.append(e);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
return &this.events;
|
return &this.events;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content(this: *@This()) !*std.ArrayList(u8) {
|
pub fn content(this: *@This()) !*std.ArrayList(u8) {
|
||||||
const widget_content = try this.widget.content();
|
const widget_content = try this.widget.content();
|
||||||
this.c.clearRetainingCapacity();
|
this.c.clearRetainingCapacity();
|
||||||
|
try this.c.appendSlice("\n");
|
||||||
try this.c.appendSlice(widget_content);
|
try this.c.appendSlice(widget_content);
|
||||||
|
try this.c.appendSlice("\n");
|
||||||
return &this.c;
|
return &this.c;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ pub fn main() !void {
|
|||||||
var instants: std.ArrayList(u64) = undefined;
|
var instants: std.ArrayList(u64) = undefined;
|
||||||
var benchmark_thread: std.Thread = undefined;
|
var benchmark_thread: std.Thread = undefined;
|
||||||
if (comptime build_options.benchmark) {
|
if (comptime build_options.benchmark) {
|
||||||
instants = try std.ArrayList(u64).initCapacity(allocator, 512);
|
instants = try std.ArrayList(u64).initCapacity(allocator, 1024);
|
||||||
benchmark_thread = try std.Thread.spawn(.{}, benchmark, .{&app});
|
benchmark_thread = try std.Thread.spawn(.{}, benchmark, .{&app});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ pub fn main() !void {
|
|||||||
|
|
||||||
fn benchmark(app: *App) void {
|
fn benchmark(app: *App) void {
|
||||||
std.time.sleep(1 * std.time.ns_per_s);
|
std.time.sleep(1 * std.time.ns_per_s);
|
||||||
for (0..511) |_| {
|
for (0..512) |_| {
|
||||||
app.postEvent(.{ .key = .{ .cp = 'j' } });
|
app.postEvent(.{ .key = .{ .cp = 'j' } });
|
||||||
app.postEvent(.{ .key = .{ .cp = 'k' } });
|
app.postEvent(.{ .key = .{ .cp = 'k' } });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user