From 05794aae570fd3c2f6ed27937b785f3d086f57f4 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Wed, 19 Mar 2025 23:53:56 +0100 Subject: Replace widget buf string with linesbuf This allows the generic widget print code to iterate more easily on the lines and to apply widget-specific styles without breaking them by truncating the console codes. --- tui/widget/text/text.ha | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tui/widget/text') diff --git a/tui/widget/text/text.ha b/tui/widget/text/text.ha index 0a30eb0..40b3f58 100644 --- a/tui/widget/text/text.ha +++ b/tui/widget/text/text.ha @@ -2,7 +2,6 @@ use io; use unix::tty; use tui; use tui::widget; -use strings; export type text = struct { widget: widget::widget, @@ -19,7 +18,7 @@ export fn newtext(state: *tui::tui, txt: str, pos: widget::coords, style: (*widg pos = pos, sz = void, style = style, - damage = widget::all, + damage = widget::damageall, ... }, txt = txt, @@ -28,8 +27,10 @@ export fn newtext(state: *tui::tui, txt: str, pos: widget::coords, style: (*widg fn printtext(widget: *widget::widget) void = { const widget = widget: *text; - widget.widget.buf = strings::dup(widget.txt); - defer free(widget.widget.buf); + widget.widget.buf = widget::linesbuf { + lines = [widget.txt], + ... + }; widget::print(widget); }; -- cgit v1.2.3