Add ability to set global buffer attributes

This commit is contained in:
Jeremy Soller 2022-10-25 16:29:33 -06:00
parent 59a4f8a4c1
commit 525c4efaa5
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
4 changed files with 65 additions and 5 deletions

View file

@ -516,6 +516,24 @@ impl<'a> TextBuffer<'a> {
self.height / self.metrics.line_height
}
pub fn attrs(&self) -> &Attrs<'a> {
&self.attrs
}
/// Set attributes
pub fn set_attrs(&mut self, font_system: &'a FontSystem<'a>, attrs: Attrs<'a>) {
if attrs != self.attrs {
self.font_matches = font_system.matches_attrs(&attrs);
self.attrs = attrs;
for line in self.lines.iter_mut() {
line.reset();
}
self.shape_until_scroll();
}
}
/// Set text of buffer
pub fn set_text(&mut self, text: &str) {
self.lines.clear();