From aa288b25a00385e8b034735838f3d5cc512df93f Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Tue, 31 May 2022 00:00:04 +0200 Subject: Make frame equal to winsize --- libui/widget/list/list.ha | 18 ++++++++++++------ 1 file 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) { -- cgit v1.2.3