aboutsummaryrefslogtreecommitdiff
path: root/handlers.ha
diff options
context:
space:
mode:
Diffstat (limited to 'handlers.ha')
-rw-r--r--handlers.ha26
1 files changed, 26 insertions, 0 deletions
diff --git a/handlers.ha b/handlers.ha
index 2e7609f..e5140bb 100644
--- a/handlers.ha
+++ b/handlers.ha
@@ -114,6 +114,32 @@ fn runehandler(l: *widget::widget, r: libtui::key) bool = {
let c = l.cursor;
list::search(l, searchterm);
libtui::resume(&l.widget.ui);
+ case 'f' =>
+ //filter
+ libtui::suspend(&l.widget.ui);
+ fmt::fprint(l.widget.ui.f, "f: ")!;
+ let line = match (bufio::scanline(l.widget.ui.f)) {
+ case let s: []u8 =>
+ yield s;
+ case io::EOF =>
+ fmt::fprintln(os::stderr, "EOF")!;
+ return true;
+ case let e: io::error =>
+ fmt::fprintln(os::stderr, io::strerror(e))!;
+ return true;
+ };
+ defer free(line);
+ strings::freeall(itemscopy);
+ itemscopy = strings::dupall(l.items);
+ let newitems: []str = [];
+ defer strings::freeall(newitems);
+ for (let i = 0z; i < len(l.items); i += 1) {
+ if (strings::contains(l.items[i], strings::fromutf8(line))) {
+ append(newitems, l.items[i]);
+ };
+ };
+ list::setitems(l, newitems...);
+ libtui::resume(&l.widget.ui);
case 'o' =>
// order
sort::strings(l.items);