crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.27k stars 280 forks source link

Misleading documentation of Command::write_ansi #781

Open stepancheg opened 1 year ago

stepancheg commented 1 year ago

Documentation says:

https://github.com/crossterm-rs/crossterm/blob/769b18151c6c177d43c752cc964d2b3d058bcf14/src/command.rs#L12-L18

However, PrintStyledContent::write_ansi emits WinAPI calls, not just ANSI sequences.

https://github.com/crossterm-rs/crossterm/blob/769b18151c6c177d43c752cc964d2b3d058bcf14/src/style.rs#L387-L396

sigmaSd commented 1 year ago

execute_fmt only executes winapi call if winapi is not supported, but since we're already inside write_ansi I think its called from queue/execute which do check for winapi before using it

Either way I think changing execute_fmt(f, SetBackgroundColor(bg)) to SetBackgroundColor(bg).write_ansi(f) is more correct , if I didn't miss anything