[−][src]Struct crossterm::StyledObject
Struct that contains both the style and the content wits can be styled.
Fields
object_style: ObjectStyle
content: D
Methods
impl<'a, D> StyledObject<D> where
D: 'a + Display,
[src]
D: 'a + Display,
pub fn with(self, foreground_color: Color) -> StyledObject<D>
[src]
Set the foreground of the styled object to the passed Color
.
Remarks
This methods consumes 'self', and works like a builder.
By having this functionality you can do: with().on().attr()
pub fn on(self, background_color: Color) -> StyledObject<D>
[src]
Set the background of the styled object to the passed Color
.
Remarks
This methods consumes 'self', and works like a builder.
By having this functionality you can do: with().on().attr()
pub fn attr(self, attr: Attribute) -> StyledObject<D>
[src]
Set the attribute of an styled object to the passed Attribute
.
Remarks
This methods consumes 'self', and works like a builder.
By having this functionality you can do: with().on().attr()
pub fn into_displayable(
self,
stdout: &'a Arc<TerminalOutput>
) -> DisplayableObject<'a, D>
[src]
self,
stdout: &'a Arc<TerminalOutput>
) -> DisplayableObject<'a, D>
This converts an styled object into an DisplayableObject
witch implements: Display
and could be used inside the write function of the standard library.
StyledObject already implements Display
right?
This is true, however there are some complex issues why this won't work on alternate screen.
That is the reason why this functions exists.
You could just pass in the 'screen' from your alternate screen to this method and your StyledObject
will be printed to the alternate screen just fine.
let screen = Screen::default(); /* represents the alternate screen */ let styled_object = style("test").with(Color::Yellow); let display_object = styled_object.into_displayable(&screen); println!("Colored text: {}. Default color", display_object);
pub fn paint(&self, stdout: &Arc<TerminalOutput>) -> Result<(), ErrorKind>
[src]
This could be used to paint the styled object onto the given screen. You have to pass a reference to the screen whereon you want to perform the painting.
style("Some colored text") .with(Color::Blue) .on(Color::Black) .paint(&screen);
You should take not that StyledObject
implements Display
. You don't need to call paint unless you are on alternate screen.
Checkout into_displayable()
for more information about this.
Trait Implementations
impl<D> Styler<D> for StyledObject<D> where
D: Display,
[src]
D: Display,
fn reset(self) -> StyledObject<D>
[src]
fn bold(self) -> StyledObject<D>
[src]
fn underlined(self) -> StyledObject<D>
[src]
fn reverse(self) -> StyledObject<D>
[src]
fn dim(self) -> StyledObject<D>
[src]
fn italic(self) -> StyledObject<D>
[src]
fn negative(self) -> StyledObject<D>
[src]
fn slow_blink(self) -> StyledObject<D>
[src]
fn rapid_blink(self) -> StyledObject<D>
[src]
[src]
fn crossed_out(self) -> StyledObject<D>
[src]
impl<D> Display for StyledObject<D> where
D: Display,
[src]
D: Display,
impl<D> Colorize<D> for StyledObject<D> where
D: Display,
[src]
D: Display,
fn black(self) -> StyledObject<D>
[src]
fn red(self) -> StyledObject<D>
[src]
fn dark_red(self) -> StyledObject<D>
[src]
fn green(self) -> StyledObject<D>
[src]
fn dark_green(self) -> StyledObject<D>
[src]
fn yellow(self) -> StyledObject<D>
[src]
fn dark_yellow(self) -> StyledObject<D>
[src]
fn blue(self) -> StyledObject<D>
[src]
fn dark_blue(self) -> StyledObject<D>
[src]
fn magenta(self) -> StyledObject<D>
[src]
fn dark_magenta(self) -> StyledObject<D>
[src]
fn cyan(self) -> StyledObject<D>
[src]
fn dark_cyan(self) -> StyledObject<D>
[src]
fn white(self) -> StyledObject<D>
[src]
fn grey(self) -> StyledObject<D>
[src]
fn on_black(self) -> StyledObject<D>
[src]
fn on_red(self) -> StyledObject<D>
[src]
fn on_dark_red(self) -> StyledObject<D>
[src]
fn on_green(self) -> StyledObject<D>
[src]
fn on_dark_green(self) -> StyledObject<D>
[src]
fn on_yellow(self) -> StyledObject<D>
[src]
fn on_dark_yellow(self) -> StyledObject<D>
[src]
fn on_blue(self) -> StyledObject<D>
[src]
fn on_dark_blue(self) -> StyledObject<D>
[src]
fn on_magenta(self) -> StyledObject<D>
[src]
fn on_dark_magenta(self) -> StyledObject<D>
[src]
fn on_cyan(self) -> StyledObject<D>
[src]
fn on_dark_cyan(self) -> StyledObject<D>
[src]
fn on_white(self) -> StyledObject<D>
[src]
fn on_grey(self) -> StyledObject<D>
[src]
Auto Trait Implementations
impl<D> Send for StyledObject<D> where
D: Send,
D: Send,
impl<D> Sync for StyledObject<D> where
D: Sync,
D: Sync,
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,