Struct termit::Painter

source ·
pub struct Painter { /* private fields */ }
Expand description

The TUI Painter :)

It has a style and scope and it paints text on the screen or fills it with background. It can also copy symbols from one screen to another.

Implementations§

source§

impl Painter

source

pub fn new(style: impl Into<Style>, scope: Window) -> Self

source

pub fn with_scope(&self, scope: Window) -> Painter

Set new scope

source

pub fn with_new_style(&self, style: Style) -> Painter

Ignore the current style and use the given one

source

pub fn scope(&self) -> Window

source

pub fn copy<'a>( &self, symbols: impl Iterator<Item = (Point, &'a ScreenStyle, &'a str)>, screen: &mut Screen )

Copy symbols to the screen respecting scope

source

pub fn paint( &self, text: &str, screen: &mut Screen, offset: u16, explicit_carriage_return: bool ) -> Window

Render the given text to the screen with a column offset.

The offset allows to continue a line where the previous painting stopped. The offest is zero-based relative to the painter scope.

With the explicit_carriage_return set to true, new line (\n) will not imply carriage return (\r). Set it to true if you fave pre-formatted text where \n should not return carriage. False suitable for most texts in the nix world and no harm in \r\n world. Set it to false if you want text to continue at the beginning after new line.

It handles the text in a special way:

  • it works with symbols-graphemes rather than chars
  • each grapheme will occupy it’s own spot on the screen (emoji welcome)
  • \r moves the cursor to the start of the scope line
  • \n moves the cursor to the next line in scope
  • if end of scope is reached, wraps around to next line
  • it skips symbols that are out of scope
  • it returns the actual window scope the text was rendered to which allows the next thing to lay next by
source

pub fn fill(&self, screen: &mut Screen)

Fill the scope in the screen with background color

Trait Implementations§

source§

impl Clone for Painter

source§

fn clone(&self) -> Painter

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Painter

source§

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

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

impl Default for Painter

source§

fn default() -> Self

Default style, unlimited scope

source§

impl Styled for &Painter

§

type Cute = Painter

source§

fn pretty(self) -> Self::Cute

source§

impl Styled for &mut Painter

§

type Cute = &mut Painter

source§

fn pretty(self) -> Self::Cute

source§

impl Styled for Painter

§

type Cute = Painter

source§

fn pretty(self) -> Self::Cute

source§

impl Stylish for &mut Painter

source§

fn style(&self) -> &Style

source§

fn style_mut(&mut self) -> &mut Style

source§

impl Stylish for Painter

source§

fn style(&self) -> &Style

source§

fn style_mut(&mut self) -> &mut Style

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> Stylist for Twhere T: Styled,

§

type Cute = <T as Styled>::Cute

source§

fn front(self, color: impl Into<Option<Color>>) -> <T as Stylist>::Cute

source§

fn back(self, color: impl Into<Option<Color>>) -> <T as Stylist>::Cute

source§

fn underlined(self, underlined: impl Into<Option<bool>>) -> <T as Stylist>::Cute

source§

fn frame(self, color: impl Into<Option<Color>>) -> <T as Stylist>::Cute

source§

fn crossed_out(self, crossed: bool) -> <T as Stylist>::Cute

source§

fn bold(self, bold: impl Into<Option<bool>>) -> <T as Stylist>::Cute

source§

fn italic(self, italic: impl Into<Option<bool>>) -> <T as Stylist>::Cute

source§

fn apply(self, additional: impl AsRef<Style>) -> <T as Stylist>::Cute

source§

fn with_style(self, what: impl FnOnce(&mut Style)) -> <T as Stylist>::Cute

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.