diff options
| author | Julian Hurst <ark@mansus.space> | 2022-09-12 11:51:04 +0200 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2022-09-12 11:51:04 +0200 |
| commit | 4fa5bdff20cfd1dcceae402377b0c38e058ff512 (patch) | |
| tree | 1e23c3151a52725529bc021d206b0262f20d9acf /handlers.ha | |
| parent | ddbbc9b20c4db3018ce460b0407f918b4c5bfedf (diff) | |
| download | ilhare-4fa5bdff20cfd1dcceae402377b0c38e058ff512.tar.gz | |
Print selected and quit on newline
Diffstat (limited to 'handlers.ha')
| -rw-r--r-- | handlers.ha | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/handlers.ha b/handlers.ha index 854aee7..2cf34e7 100644 --- a/handlers.ha +++ b/handlers.ha @@ -217,8 +217,22 @@ fn runehandler(l: *widget::widget, r: libtui::key) bool = { fmt::fprintln(os::stderr, "This is not detected")!; case => let us = utf8::encoderune(r); - if (len(us) > 0 && us[0] == 13u8) { - fmt::fprintln(os::stderr, "newline")!; + // 0x0d is carriage return in utf8 + if (len(us) > 0 && us[0] == 0x0du8) { + // to print properly suspend the ui, print, then resume + libtui::suspend(&l.widget.ui); + //fmt::println(l.items[l.cursor])!; + match (list::selected(*l)) { + case let s: str => + fmt::println(s)!; + case let s: []str => + defer free(s); + const out = strings::join("\n", s...); + defer free(out); + fmt::println(out)!; + }; + libtui::resume(&l.widget.ui); + return true; }; }; return false; |
