diff options
| author | Julian Hurst <ark@mansus.space> | 2022-12-16 11:12:47 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2022-12-16 11:12:47 +0100 |
| commit | b9cf4251f8dcd843bba3a984ac87950fc78eb7f3 (patch) | |
| tree | 99fbedda7158211b496c0b54313e55837b523126 /handlers.ha | |
| parent | 1edfb56af19905fb30961ee8162afe8e1719b400 (diff) | |
| download | ilhare-b9cf4251f8dcd843bba3a984ac87950fc78eb7f3.tar.gz | |
Add support for nul terminated output
Diffstat (limited to 'handlers.ha')
| -rw-r--r-- | handlers.ha | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/handlers.ha b/handlers.ha index dda5c51..c4f28db 100644 --- a/handlers.ha +++ b/handlers.ha @@ -47,14 +47,19 @@ fn runehandler(l: *widget::widget, r: libtui::key) bool = { // to print properly suspend the ui, print, then resume libtui::suspend(&l.widget.ui); //fmt::println(l.items[l.cursor])!; + const termchar = if (nulterm) { + yield "\0"; + } else { + yield "\n"; + }; match (list::selected(*l)) { case let s: str => - fmt::println(s)!; + fmt::printf("{}{}", s, termchar)!; case let s: []str => defer free(s); - const out = strings::join("\n", s...); + const out = strings::join(termchar, s...); defer free(out); - fmt::println(out)!; + fmt::printf("{}{}", out, termchar)!; }; libtui::resume(&l.widget.ui); return true; @@ -222,14 +227,19 @@ fn runehandler(l: *widget::widget, r: libtui::key) bool = { // to print properly suspend the ui, print, then resume libtui::suspend(&l.widget.ui); //fmt::println(l.items[l.cursor])!; + const termchar = if (nulterm) { + yield "\0"; + } else { + yield "\n"; + }; match (list::selected(*l)) { case let s: str => - fmt::println(s)!; + fmt::printf("{}{}", s, termchar)!; case let s: []str => defer free(s); - const out = strings::join("\n", s...); + const out = strings::join(termchar, s...); defer free(out); - fmt::println(out)!; + fmt::printf("{}{}", out, termchar)!; }; libtui::resume(&l.widget.ui); return true; |
