diff options
| author | Julian Hurst <ark@mansus.space> | 2025-03-12 04:24:30 +0100 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2025-03-12 04:24:30 +0100 |
| commit | 977f80f4b60983d03d069e11032e9cd15339b6d8 (patch) | |
| tree | a1fb4a6433fcc0699f6895c616ab8f3cf216976c | |
| parent | f5ebe6b7f42ca673c3fcd82207b3ef68e16ea21b (diff) | |
| download | hare-tui-977f80f4b60983d03d069e11032e9cd15339b6d8.tar.gz | |
Use nosize in list example and add docs to newlist
| -rw-r--r-- | cmd/list.ha | 5 | ||||
| -rw-r--r-- | 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)?; |
