From 4b1ee21e949fe329f365ef65aa953f94a6c01309 Mon Sep 17 00:00:00 2001 From: Shadow Cat Date: Thu, 28 Aug 2025 22:51:58 -0400 Subject: [PATCH] text new fn --- src/core/text.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/text.rs b/src/core/text.rs index cadd31a..a785014 100644 --- a/src/core/text.rs +++ b/src/core/text.rs @@ -26,6 +26,14 @@ impl Text { self.attrs.line_height = height; self } + pub fn new(content: impl Into) -> Self { + let attrs = TextAttrs::default(); + Self { + content: content.into(), + buf: TextBuffer::new_empty(Metrics::new(attrs.font_size, attrs.line_height)), + attrs, + } + } } impl Widget for Text { @@ -49,11 +57,6 @@ impl Widget for Text { } } -pub fn text(text: impl Into) -> Text { - let attrs = TextAttrs::default(); - Text { - content: text.into(), - buf: TextBuffer::new_empty(Metrics::new(attrs.font_size, attrs.line_height)), - attrs, - } +pub fn text(content: impl Into) -> Text { + Text::new(content) }