macro_rules! execute { ($writer:expr $(, $command:expr)* $(,)? ) => { ... }; }
Expand description
Executes one or more command(s).
§Arguments
-
ANSI escape codes are written on the given ‘writer’, after which they are flushed.
-
One or more commands
§Examples
use std::io::{Write, stdout};
use crossterm::{execute, style::Print};
// will be executed directly
execute!(stdout(), Print("sum:\n".to_string()));
// will be executed directly
execute!(stdout(), Print("1 + 1= ".to_string()), Print((1+1).to_string()));
// ==== 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.