text new fn
This commit is contained in:
@@ -26,6 +26,14 @@ impl Text {
|
||||
self.attrs.line_height = height;
|
||||
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 {
|
||||
@@ -49,11 +57,6 @@ impl Widget for Text {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(text: impl Into<String>) -> 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<String>) -> Text {
|
||||
Text::new(content)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user