[][src]Struct crossterm::Crossterm

pub struct Crossterm;

This type offers a easy way to use functionalities like cursor, terminal, color, input, styling.

To get a cursor instance to perform cursor related actions, you can do the following:

let crossterm = Crossterm::new();
let cursor = crossterm.cursor();

Remark

  • depending on the feature flags you've enabled you are able to call methods of this type.
  • checkout the crossterm book for more information about feature flags or alternate screen.

Methods

impl Crossterm[src]

pub fn new() -> Crossterm[src]

Create a new instance of Crossterm

pub fn cursor(&self) -> TerminalCursor[src]

Get a TerminalCursor implementation whereon cursor related actions can be performed.

let crossterm = Crossterm::new();
let cursor = crossterm.cursor();

pub fn input(&self) -> TerminalInput[src]

Get a TerminalInput implementation whereon terminal related actions can be performed.

let crossterm = Crossterm::new();
let input = crossterm.input();

pub fn terminal(&self) -> Terminal[src]

Get a Terminal implementation whereon terminal related actions can be performed.

let crossterm = Crossterm::new();
let mut terminal = crossterm.terminal();

pub fn color(&self) -> TerminalColor[src]

Get a TerminalColor implementation whereon color related actions can be performed.

let crossterm = Crossterm::new();
let mut terminal = crossterm.color();

pub fn style<D>(&self, val: D) -> StyledObject<D> where
    D: Display
[src]

This could be used to style any type implementing Display with colors and attributes.

Example

let crossterm = Crossterm::new();

// get an styled object which could be painted to the terminal.
let styled_object = crossterm.style("Some Blue colored text on black background")
    .with(Color::Blue)
    .on(Color::Black);

// print the styled font * times to the current screen.
for i in 1..10
{
    println!("{}", styled_object);
}

Remark

val: any type implementing Display e.g. string.

Auto Trait Implementations

impl Send for Crossterm

impl Sync for Crossterm

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]