From 977f80f4b60983d03d069e11032e9cd15339b6d8 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Wed, 12 Mar 2025 04:24:30 +0100 Subject: Use nosize in list example and add docs to newlist --- cmd/list.ha | 5 ++--- tui/widget/list/list.ha | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/list.ha b/cmd/list.ha index 8c93e1a..9a86d23 100644 --- a/cmd/list.ha +++ b/cmd/list.ha @@ -1,7 +1,7 @@ use tui; use tui::layout; +use tui::widget; use tui::widget::list; -use unix::tty; use io; use fmt; use time; @@ -9,8 +9,7 @@ use time; export fn main() void = { const out = tui::init()!; defer io::close(out)!; - const sz = tty::winsize(out)!; - let li = list::newlist(out, (1, 1), sz, "hello", "world")!; + let li = list::newlist(out, (1, 1), widget::nosize, "hello", "world")!; let l = layout::newvlayout(&li); l.layout.print(&l); }; diff --git a/tui/widget/list/list.ha b/tui/widget/list/list.ha index 4da52d5..a4ec77e 100644 --- a/tui/widget/list/list.ha +++ b/tui/widget/list/list.ha @@ -15,6 +15,9 @@ export type list = struct { frame: frame, }; +// Return an instance of list. out is the tty file, pos the starting position, +// sz is the size of the widget (if [[widget::nosize]] is used, the maximum possible +// size is used), items is the slice of items of the list. export fn newlist(out: io::file, pos: widget::coords, sz: widget::widgetsize, items: str...) (list | tty::error) = { const tsz = tty::winsize(out)?; -- cgit v1.2.3