aboutsummaryrefslogtreecommitdiff
path: root/handlers.ha
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2022-12-16 11:12:47 +0100
committerJulian Hurst <ark@mansus.space>2022-12-16 11:12:47 +0100
commitb9cf4251f8dcd843bba3a984ac87950fc78eb7f3 (patch)
tree99fbedda7158211b496c0b54313e55837b523126 /handlers.ha
parent1edfb56af19905fb30961ee8162afe8e1719b400 (diff)
downloadilhare-b9cf4251f8dcd843bba3a984ac87950fc78eb7f3.tar.gz
Add support for nul terminated output
Diffstat (limited to 'handlers.ha')
-rw-r--r--handlers.ha22
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;