Struct text_display::TextDisplay
source · pub struct TextDisplay { /* private fields */ }
Expand description
A text displayable profiles the size and color of a block of text. It can display in a framebuffer.
Implementations§
source§impl TextDisplay
impl TextDisplay
sourcepub fn new(
width: usize,
height: usize,
fg_color: Color,
bg_color: Color
) -> Result<TextDisplay, &'static str>
pub fn new( width: usize, height: usize, fg_color: Color, bg_color: Color ) -> Result<TextDisplay, &'static str>
Creates a new text displayable.
Arguments
width
,height
: the dimensions of the text area, in number of characters.fg_color
,bg_color
: the color of the text and the background behind the text, respectively.
sourcepub fn get_bg_color(&self) -> Color
pub fn get_bg_color(&self) -> Color
Gets the background color of the text area
sourcepub fn reset_cache(&mut self)
pub fn reset_cache(&mut self)
Clear the cache of the text displayable.
sourcepub fn get_location(&self, index: usize) -> (usize, usize)
pub fn get_location(&self, index: usize) -> (usize, usize)
Translate the index of a character in the text to the location of the text displayable. Return (column, line).
sourcepub fn get_index(&self, column: usize, line: usize) -> usize
pub fn get_index(&self, column: usize, line: usize) -> usize
Translate the location of a character to its index in the text.
sourcepub fn get_dimensions(&self) -> (usize, usize)
pub fn get_dimensions(&self) -> (usize, usize)
Gets the size of a text displayable in number of characters.
sourcepub fn get_next_index(&self) -> usize
pub fn get_next_index(&self) -> usize
Gets the index of next character to be displayabled. It is the position next to existing printed characters in the text displayable.
Trait Implementations§
source§impl Debug for TextDisplay
impl Debug for TextDisplay
source§impl Displayable for TextDisplay
impl Displayable for TextDisplay
source§fn display<P: Pixel + From<Color>>(
&mut self,
coordinate: Coord,
framebuffer: &mut Framebuffer<P>
) -> Result<Rectangle, &'static str>
fn display<P: Pixel + From<Color>>( &mut self, coordinate: Coord, framebuffer: &mut Framebuffer<P> ) -> Result<Rectangle, &'static str>
Displays this
Displayable
’s content in the given framebuffer. Read moreAuto Trait Implementations§
impl RefUnwindSafe for TextDisplay
impl Send for TextDisplay
impl Sync for TextDisplay
impl Unpin for TextDisplay
impl UnwindSafe for TextDisplay
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more