pub struct StyledBuffer<T>{ /* private fields */ }
Expand description
An acceptable custom XXXStyle
for StyledBuffer
must implement trait Clone
, PartialEq
, Eq
and Style
.
Implementations§
Source§impl<T> StyledBuffer<T>
impl<T> StyledBuffer<T>
pub fn new() -> StyledBuffer<T>
Sourcepub fn render(&self) -> Vec<Vec<StyledString<T>>>
pub fn render(&self) -> Vec<Vec<StyledString<T>>>
Returns content of StyledBuffer
split by lines and line styles
Sourcepub fn putc(&mut self, line: usize, col: usize, chr: char, style: Option<T>)
pub fn putc(&mut self, line: usize, col: usize, chr: char, style: Option<T>)
Sets chr
with style
for given line
, col
.
If line
does not exist in our buffer, adds empty lines up to the given
and fills the last line with unstyled whitespace.
Sourcepub fn puts(&mut self, line: usize, col: usize, string: &str, style: Option<T>)
pub fn puts(&mut self, line: usize, col: usize, string: &str, style: Option<T>)
Sets string
with style
for given line
, starting from col
.
If line
does not exist in our buffer, adds empty lines up to the given
and fills the last line with unstyled whitespace.
Sourcepub fn pushs(&mut self, string: &str, style: Option<T>)
pub fn pushs(&mut self, string: &str, style: Option<T>)
Sets string
with style
for a new line, starting from col 0.
It will add an new empty line after all the buffer lines for the string
.
Sourcepub fn appendl(&mut self, string: &str, style: Option<T>)
pub fn appendl(&mut self, string: &str, style: Option<T>)
For the last line inserts string
with style
after old content of that line,
adding a new line if the StyledBuffer
has no line.
Sourcepub fn prepend(&mut self, line: usize, string: &str, style: Option<T>)
pub fn prepend(&mut self, line: usize, string: &str, style: Option<T>)
For given line
inserts string
with style
before old content of that line,
adding lines if needed
Sourcepub fn append(&mut self, line: usize, string: &str, style: Option<T>)
pub fn append(&mut self, line: usize, string: &str, style: Option<T>)
For given line
inserts string
with style
after old content of that line,
adding lines if needed