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

source

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.
source

pub fn get_bg_color(&self) -> Color

Gets the background color of the text area

source

pub fn reset_cache(&mut self)

Clear the cache of the text displayable.

source

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).

source

pub fn get_index(&self, column: usize, line: usize) -> usize

Translate the location of a character to its index in the text.

source

pub fn get_dimensions(&self) -> (usize, usize)

Gets the size of a text displayable in number of characters.

source

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.

source

pub fn set_text(&mut self, text: &str)

Sets the text of the text displayable

Trait Implementations§

source§

impl Debug for TextDisplay

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Displayable for TextDisplay

source§

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 more
source§

fn set_size(&mut self, width: usize, height: usize)

Resizes the displayable area, but does not automatically refresh its display.
source§

fn get_size(&self) -> (usize, usize)

Gets the size of the area occupied by the displayable.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.