text new fn

This commit is contained in:
2025-08-28 22:51:58 -04:00
parent 55bee4b25e
commit 4b1ee21e94

View File

@@ -26,6 +26,14 @@ impl Text {
self.attrs.line_height = height; self.attrs.line_height = height;
self self
} }
pub fn new(content: impl Into<String>) -> 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 { impl Widget for Text {
@@ -49,11 +57,6 @@ impl Widget for Text {
} }
} }
pub fn text(text: impl Into<String>) -> Text { pub fn text(content: impl Into<String>) -> Text {
let attrs = TextAttrs::default(); Text::new(content)
Text {
content: text.into(),
buf: TextBuffer::new_empty(Metrics::new(attrs.font_size, attrs.line_height)),
attrs,
}
} }