aboutsummaryrefslogtreecommitdiff
path: root/libui/widget/list/list.ha
diff options
context:
space:
mode:
Diffstat (limited to 'libui/widget/list/list.ha')
-rw-r--r--libui/widget/list/list.ha18
1 files changed, 12 insertions, 6 deletions
diff --git a/libui/widget/list/list.ha b/libui/widget/list/list.ha
index 6710915..d8906d3 100644
--- a/libui/widget/list/list.ha
+++ b/libui/widget/list/list.ha
@@ -41,11 +41,12 @@ export type listener = *fn(l: *listwidget, r: rune) bool;
// Create a new list with the given items.
export fn newlist(ui: libui::ttyui, items: str...) listwidget = {
let sz = libui::getwinsize(ui)!;
- let rows: (u16 | size) = if (sz.rows - 2 < len(items)) {
- yield sz.rows - 2;
- } else {
- yield len(items);
- };
+ let rows = sz.rows - 2;
+ //let rows: (u16 | size) = if (sz.rows - 2 < len(items)) {
+ //yield sz.rows - 2;
+ //} else {
+ //yield len(items);
+ //};
let w = listwidget {
widget = widget::widget {
print = &print,
@@ -121,7 +122,12 @@ 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 end = if (list.frame.end < len(list.items)) {
+ yield list.frame.end;
+ } else {
+ yield len(list.items);
+ };
+ for (let i = list.frame.start; i < end: u16; i += 1) {
const item = list.items[i];
const truncitem = wcwidth::truncate(item, list.sz.cols);
if (list.cursor == i) {