crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.28k stars 281 forks source link

Add API for the terminal bell sound #806

Open Piturnah opened 1 year ago

Piturnah commented 1 year ago

Adds a command that allows for ringing the terminal bell by printing the bell character.

Technically it's not an ansi code, so it felt slightly strange to put it under Command::write_ansi, but I don't think it makes sense to implement this separately from the Command API.

I think it's somewhat justified if you reinterpret write_ansi as "write to the terminal potentially including ansi codes", but then is_ansi_code_supported doesn't make a lot of sense.

But, this is one edge case so I think it's fairly reasonable. What do you think? I think this functionality - even though it's really as simple as printing a char - has a place in the Crossterm library

This should close #730

TimonPost commented 1 year ago

I think its not appropriate to fitt it in the command api. We use command strictly for writing ansi sequences to the writer. For things that do not fit into that structure, we expose custom functions e.g terminal_size, cursor_pos, etc....

Piturnah commented 1 year ago

Is this API more appropriate? Or would you rather a function like terminal::bell()?

TimonPost commented 6 months ago

Sorry for late response. A function is better I think, that works similar to the other api's we have that do not fit the box