Struct termimad::CropWriter
source · pub struct CropWriter<'w, W>where
W: Write,{
pub w: &'w mut W,
pub allowed: usize,
pub tab_replacement: &'static str,
}
Expand description
wrap a writer to ensure that at most allowed
columns are
written.
Fields§
§w: &'w mut W
§allowed: usize
number of screen columns which may be covered
tab_replacement: &'static str
the string replacing a tabulation
Implementations§
source§impl<'w, W> CropWriter<'w, W>where
W: Write,
impl<'w, W> CropWriter<'w, W>where
W: Write,
pub fn new(w: &'w mut W, limit: usize) -> Self
pub const fn is_full(&self) -> bool
sourcepub fn cropped_str<'a>(&self, s: &'a str) -> (Cow<'a, str>, usize)
pub fn cropped_str<'a>(&self, s: &'a str) -> (Cow<'a, str>, usize)
return a tuple containing a string containing either the given &str or the part fitting the remaining width, and the width of this string)
pub fn queue_unstyled_str(&mut self, s: &str) -> Result<(), Error>
pub fn queue_str(&mut self, cs: &CompoundStyle, s: &str) -> Result<(), Error>
pub fn queue_char(&mut self, cs: &CompoundStyle, c: char) -> Result<(), Error>
pub fn queue_unstyled_char(&mut self, c: char) -> Result<(), Error>
sourcepub fn queue_unstyled_g_string(&mut self, s: String) -> Result<(), Error>
pub fn queue_unstyled_g_string(&mut self, s: String) -> Result<(), Error>
a “g_string” is a “gentle” one: each char takes one column on screen. This function must thus not be used for unknown strings.
sourcepub fn queue_g_string(
&mut self,
cs: &CompoundStyle,
s: String
) -> Result<(), Error>
pub fn queue_g_string(
&mut self,
cs: &CompoundStyle,
s: String
) -> Result<(), Error>
a “g_string” is a “gentle” one: each char takes one column on screen. This function must thus not be used for unknown strings.