text new fn
This commit is contained in:
@@ -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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user