aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <julian.hurst92@gmail.com>2022-05-31 00:00:04 +0200
committerJulian Hurst <julian.hurst92@gmail.com>2022-05-31 00:00:04 +0200
commitaa288b25a00385e8b034735838f3d5cc512df93f (patch)
treed69910297358f7a57456afcce4681d278f078fb6
parent042791ee8518b5b3f196ca198e184d5913341619 (diff)
downloadilhare-aa288b25a00385e8b034735838f3d5cc512df93f.tar.gz
Make frame equal to winsize
-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) {