diff options
| author | Julian Hurst <ark@mansus.space> | 2022-12-16 11:31:21 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2022-12-16 11:31:21 +0100 |
| commit | 341e258208647cacca59c324fc658ac9c068c7c5 (patch) | |
| tree | 8e3ad7872117191d824ba328a72db82475bac98c | |
| parent | b9cf4251f8dcd843bba3a984ac87950fc78eb7f3 (diff) | |
| download | ilhare-341e258208647cacca59c324fc658ac9c068c7c5.tar.gz | |
Add -m flag
| -rw-r--r-- | handlers.ha | 7 | ||||
| -rw-r--r-- | main.ha | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/handlers.ha b/handlers.ha index c4f28db..fb6837e 100644 --- a/handlers.ha +++ b/handlers.ha @@ -43,6 +43,13 @@ fn runehandler(l: *widget::widget, r: libtui::key) bool = { list::pagedown(l); case 'u' => list::pageup(l); + case 'h' => + if (msg != "") { + libtui::suspend(&l.widget.ui); + fmt::println(msg)!; + libtui::resume(&l.widget.ui); + return true; + }; case 'l' => // to print properly suspend the ui, print, then resume libtui::suspend(&l.widget.ui); @@ -19,6 +19,7 @@ let searchterm: str = ""; let searchforward: bool = true; let nulterm: bool = false; +let msg: str = ""; type mainUI = struct { list: *list::listwidget, @@ -77,7 +78,8 @@ fn resize(list: *list::listwidget) void = { export fn main() void = { const cmd = getopt::parse(os::args, "interactive list", - ('0', "NUL terminated output") + ('0', "NUL terminated output"), + ('m', "msg", "string to print when 'h' is pressed (this can be used for custom help messages or building basic extra external features)"), ); defer getopt::finish(&cmd); @@ -86,6 +88,8 @@ export fn main() void = { switch (opt.0) { case '0' => nulterm = true; + case 'm' => + msg = opt.1; }; }; |
