Skip to main content

Command

Trait Command 

pub trait Command {
    // Required methods
    fn write_ansi(&self, f: &mut impl Write) -> Result<(), Error>;
    fn execute_winapi(&self) -> Result<(), Error>;

    // Provided method
    fn is_ansi_code_supported(&self) -> bool { ... }
}
Available on crate feature term only.
Expand description

An interface for a command that performs an action on the terminal.

Crossterm provides a set of commands, and there is no immediate reason to implement a command yourself. In order to understand how to use and execute commands, it is recommended that you take a look at Command API chapter.

Required Methods§

fn write_ansi(&self, f: &mut impl Write) -> Result<(), Error>

Write an ANSI representation of this command to the given writer. An ANSI code can manipulate the terminal by writing it to the terminal buffer. However, only Windows 10 and UNIX systems support this.

This method does not need to be accessed manually, as it is used by the crossterm’s Command API

fn execute_winapi(&self) -> Result<(), Error>

Available on Windows only.

Execute this command.

Windows versions lower than windows 10 do not support ANSI escape codes, therefore a direct WinAPI call is made.

This method does not need to be accessed manually, as it is used by the crossterm’s Command API

Provided Methods§

fn is_ansi_code_supported(&self) -> bool

Available on Windows only.

Returns whether the ANSI code representation of this command is supported by windows.

A list of supported ANSI escape codes can be found here.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<T> Command for &T
where T: Command + ?Sized,

§

fn write_ansi(&self, f: &mut impl Write) -> Result<(), Error>

§

fn execute_winapi(&self) -> Result<(), Error>

Available on Windows only.
§

fn is_ansi_code_supported(&self) -> bool

Available on Windows only.

Implementors§

§

impl Command for BeginSynchronizedUpdate

§

impl Command for Clear

§

impl Command for DisableBlinking

§

impl Command for DisableBracketedPaste

Available on crate feature bracketed-paste only.
§

impl Command for DisableFocusChange

§

impl Command for DisableLineWrap

§

impl Command for DisableMouseCapture

§

impl Command for EnableBlinking

§

impl Command for EnableBracketedPaste

Available on crate feature bracketed-paste only.
§

impl Command for EnableFocusChange

§

impl Command for EnableLineWrap

§

impl Command for EnableMouseCapture

Available on crate feature events only.
§

impl Command for EndSynchronizedUpdate

§

impl Command for EnterAlternateScreen

§

impl Command for Hide

§

impl Command for LeaveAlternateScreen

§

impl Command for MoveDown

§

impl Command for MoveLeft

§

impl Command for MoveRight

§

impl Command for MoveTo

§

impl Command for MoveToColumn

§

impl Command for MoveToNextLine

§

impl Command for MoveToPreviousLine

§

impl Command for MoveToRow

§

impl Command for MoveUp

§

impl Command for PopKeyboardEnhancementFlags

§

impl Command for PushKeyboardEnhancementFlags

§

impl Command for ResetColor

§

impl Command for RestorePosition

§

impl Command for SavePosition

§

impl Command for ScrollDown

§

impl Command for ScrollUp

§

impl Command for SetAttribute

§

impl Command for SetAttributes

§

impl Command for SetBackgroundColor

§

impl Command for SetColors

§

impl Command for SetCursorStyle

§

impl Command for SetForegroundColor

§

impl Command for SetSize

§

impl Command for SetStyle

§

impl Command for SetUnderlineColor

§

impl Command for Show

§

impl<D> Command for PrintStyledContent<D>
where D: Display,

§

impl<T> Command for Print<T>
where T: Display,

§

impl<T> Command for SetTitle<T>
where T: Display,