diff options
| -rw-r--r-- | libui/widget/list/list.ha | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libui/widget/list/list.ha b/libui/widget/list/list.ha index efed759..6506ce1 100644 --- a/libui/widget/list/list.ha +++ b/libui/widget/list/list.ha @@ -96,6 +96,10 @@ export fn setitems(list: *listwidget, items: str...) void = { //append(list.listeners, l); //}; +const SELECTED: str = "\x1B[104;1m\x1B[30m"; +const MARKED: str = "\x1B[46;1m\x1B[30m"; +const RESET: str = "\x1B[0m"; + // Print the list's items while truncating the items to not be wider than the // list.sz.cols. export fn print(list: *widget::widget) (void | widget::error) = { @@ -114,17 +118,13 @@ export fn print(list: *widget::widget) (void | widget::error) = { let st = strio::dynamic(); strio::concat(&st, "\r")?; for (let i = list.frame.start; i < list.frame.end: u16; i += 1) { - let item = list.items[i]; - let truncitem = wcwidth::truncate(item, list.sz.cols); + const item = list.items[i]; + const truncitem = wcwidth::truncate(item, list.sz.cols); if (list.cursor == i) { - strio::concat(&st, "\x1B[104;1m\x1B[30m")?; - strio::concat(&st, truncitem)?; - strio::concat(&st, "\x1B[0m")?; + strio::concat(&st, SELECTED, truncitem, RESET)?; //libui::print(list.ui, strings::concat("\x1B[31;1m> ", list.items[i], "\x1B[0m")); } else if (set::contains(list.marked, i) is size){ - strio::concat(&st, "\x1B[46;1m\x1B[30m")?; - strio::concat(&st, truncitem)?; - strio::concat(&st, "\x1B[0m")?; + strio::concat(&st, MARKED, truncitem, RESET)?; //libui::print(list.ui, list.items[i]); } else { strio::concat(&st, truncitem)?; |
