aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtui/widget/list/list.ha14
1 files changed, 8 insertions, 6 deletions
diff --git a/libtui/widget/list/list.ha b/libtui/widget/list/list.ha
index 3bfd499..b255889 100644
--- a/libtui/widget/list/list.ha
+++ b/libtui/widget/list/list.ha
@@ -13,11 +13,12 @@ use regex;
use fnmatch;
use wcwidth;
use set;
+use set::sset;
export type listwidget = struct {
widget: widget::widget,
items: []str,
- marked: set::set,
+ marked: sset::sset,
cursor: size,
//listeners: []listener,
frame: frame,
@@ -59,7 +60,7 @@ export fn newlist(ui: libtui::ttyui, items: str...) listwidget = {
...
},
items = strings::dupall(items),
- marked = set::set {...},
+ marked = sset::new(),
cursor = 0z,
//listeners = [],
frame = frame {
@@ -138,7 +139,7 @@ export fn print(list: *widget::widget) (void | widget::error) = {
if (list.cursor == i) {
strio::concat(&st, SELECTED, truncitem, RESET)?;
//libtui::print(list.ui, strings::concat("\x1B[31;1m> ", list.items[i], "\x1B[0m"));
- } else if (set::contains(list.marked, i) is size){
+ } else if (set::contains(&list.marked, i)) {
strio::concat(&st, MARKED, truncitem, RESET)?;
//libtui::print(list.ui, list.items[i]);
} else {
@@ -344,10 +345,11 @@ export fn regexmark(l: *listwidget, re: *regex::regex) void = {
// value is borrowed from the list's items. If []str is returned, the slice must
// be freed.
export fn selected(l: listwidget) (str | []str) = {
- if (len(l.marked.items) > 0) {
+ if (set::length(&l.marked) > 0) {
let result: []str = [];
- for (let i = 0z; i < len(l.marked.items); i += 1) {
- append(result, l.items[l.marked.items[i]]);
+ let its = set::items(&l.marked);
+ for (let i = 0z; i < len(its); i += 1) {
+ append(result, l.items[its[i]]);
};
return result;
} else {