[−][src]Trait crossterm::ExecutableCommand
An interface for commands that are directly executed.
Required methods
fn execute(&mut self, command: impl Command<AnsiType = T>) -> Result<&mut Self>
Executes the given command directly.
Implementors
impl<T, A> ExecutableCommand<A> for T where
A: Display,
T: Write,
[src]
A: Display,
T: Write,
fn execute(&mut self, command: impl Command<AnsiType = A>) -> Result<&mut Self>
[src]
Executes the given command directly.
The given command its ANSI escape code will be written and flushed onto Self
.
Arguments
-
The command that you want to execute directly.
Example
use std::io::{Write, stdout}; use crossterm::{Result, ExecutableCommand, style::Print}; fn main() -> Result<()> { // will be executed directly stdout() .execute(Print("sum:\n".to_string()))? .execute(Print(format!("1 + 1= {} ", 1 + 1)))?; Ok(()) // ==== Output ==== // sum: // 1 + 1 = 2 }
Have a look over at the Command API for more details.
Notes
- In the case of UNIX and Windows 10, ANSI codes are written to the given 'writer'.
- In case of Windows versions lower than 10, a direct WinApi call will be made.
The reason for this is that Windows versions lower than 10 do not support ANSI codes,
and can therefore not be written to the given
writer
. Therefore, there is no difference between execute and queue for those old Windows versions.