diff options
Diffstat (limited to 'tui/widget/text/text.ha')
| -rw-r--r-- | tui/widget/text/text.ha | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tui/widget/text/text.ha b/tui/widget/text/text.ha index 5cd8da7..ecb5c2c 100644 --- a/tui/widget/text/text.ha +++ b/tui/widget/text/text.ha @@ -1,20 +1,23 @@ use io; use unix::tty; use tui::widget; +use strings; export type text = struct { widget: widget::widget, txt: str, }; -export fn newtext(out: io::file, txt: str, pos: widget::coords) text = { +export fn newtext(out: io::file, txt: str, pos: widget::coords, style: (*widget::style | void)) text = { return text { widget = widget::widget { out = out, print = &printtext, resize = &resizetext, pos = pos, - sz = widget::nosize, + sz = void, + style = style, + ... }, txt = txt, }; @@ -22,7 +25,9 @@ export fn newtext(out: io::file, txt: str, pos: widget::coords) text = { fn printtext(widget: *widget::widget) void = { const widget = widget: *text; - widget::print(widget.widget.out, widget.txt, widget.widget.pos); + widget.widget.buf = strings::dup(widget.txt); + defer free(widget.widget.buf); + widget::print(widget); }; fn resizetext(widget: *widget::widget, ttysize: tty::ttysize) void = { |
