fix: memory leak; add: keybindings J and K for file navigation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user