diff options
Diffstat (limited to 'tui/widget/list/list.ha')
| -rw-r--r-- | tui/widget/list/list.ha | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/tui/widget/list/list.ha b/tui/widget/list/list.ha index 7e60299..50fb8df 100644 --- a/tui/widget/list/list.ha +++ b/tui/widget/list/list.ha @@ -16,15 +16,16 @@ export type list = struct { }; // 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 +// sz is the size of the widget (if void 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) = { +export fn newlist(out: io::file, pos: widget::coords, sz: widget::widgetsize, +style: (*widget::style | void), items: str...) (list | tty::error) = { const tsz = tty::winsize(out)?; let end = match (sz) { case let sz: tty::ttysize => yield if (tsz.rows < sz.rows) tsz.rows else sz.rows; - case widget::nosize => + case void => yield tsz.rows; }; @@ -39,6 +40,8 @@ export fn newlist(out: io::file, pos: widget::coords, sz: widget::widgetsize, it resize = &resizelist, pos = pos, sz = sz, + style = style, + ... }, items = items, frame = frame { @@ -53,18 +56,20 @@ export fn printlist(widget: *widget::widget) void = { let st = memio::dynamic(); defer io::close(&st)!; for (let i = list.frame.start; i < list.frame.end; i += 1) { - let item = match (list.widget.sz) { - case let sz: tty::ttysize => - yield strings::sub(list.items[i], 0z, sz.columns); - case widget::nosize => - yield list.items[i]; - }; - memio::concat(&st, item)!; + //let item = match (list.widget.sz) { + //case let sz: tty::ttysize => + // yield strings::sub(list.items[i], 0z, sz.columns); + //case widget::nosize => + // yield list.items[i]; + //}; + //memio::concat(&st, item)!; + memio::concat(&st, list.items[i])!; if (i != list.frame.end - 1) { memio::concat(&st, "\n")!; }; }; - widget::print(list.widget.out, memio::string(&st)!, (1, 1)); + list.widget.buf = memio::string(&st)!; + widget::print(list); }; export fn resizelist(widget: *widget::widget, ttysize: tty::ttysize) void = { |
