fix: memory leak; add: keybindings J and K for file navigation

This commit is contained in:
2026-01-08 23:20:33 +01:00
parent 8d98d3226a
commit 3e9fc4ce9b
2 changed files with 21 additions and 1 deletions

View File

@@ -92,7 +92,17 @@ pub fn Tree(App: type) type {
this.scrollback = 0;
this.idx = 0;
},
// TODO also support key inputs to change the current file?
.key => |key| {
if (key.eql(.{ .cp = 'J' }) and this.idx < this.len - 1) {
this.idx += 1;
this.queue.push(.{ .file = this.idx });
}
if (key.eql(.{ .cp = 'K' }) and this.idx > 0) {
this.idx -= 1;
this.queue.push(.{ .file = this.idx });
}
},
.mouse => |mouse| if (this.len > 0) switch (mouse.button) {
.left => if (mouse.y + this.scrollback < this.len) {
this.idx = mouse.y + this.scrollback;