Calculate width of Styleds directly
This commit is contained in:
parent
d693712dab
commit
e4e1454e80
1 changed files with 9 additions and 0 deletions
|
|
@ -67,6 +67,15 @@ impl Frame {
|
|||
self.widthdb.width(s)
|
||||
}
|
||||
|
||||
/// Like [`Self::width`] for [`Styled`].
|
||||
pub fn width_styled(&mut self, s: &Styled) -> usize {
|
||||
let mut total: usize = 0;
|
||||
for grapheme in s.graphemes() {
|
||||
total += self.widthdb.grapheme_width(grapheme) as usize;
|
||||
}
|
||||
total
|
||||
}
|
||||
|
||||
pub fn tab_width_at_column(&self, col: usize) -> u8 {
|
||||
wrap::tab_width_at_column(self.tab_width, col)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue