kkawakam / rustyline

Readline Implementation in Rust
https://crates.io/crates/rustyline/
MIT License
1.52k stars 175 forks source link

Generic Prompt Type #696

Open hoseinzadeh opened 1 year ago

hoseinzadeh commented 1 year ago

Sometimes we want to asynchronously update the prompt. For example, if we are using rustyline as a remote terminal, we want to display the connection info in the prompt. When disconnected, it is nicer to show a message and change the prompt to a ready state. With a Generic prompt type, it is possible to do that.

Performance overhead: in order to display the prompt, it should implement ToString trait. Therefore, it has a little performance overhead because it calls to_string every time it needs the prompt as a string (printing the prompt or calculating the cursor position). However, it is negligible as the whole system is a human interface that does not affect functionality.

gwenn commented 1 year ago

Prompt related stuff:

208

https://github.com/kkawakam/rustyline/pull/372 https://github.com/kkawakam/rustyline/pull/369

417

598

https://github.com/kkawakam/rustyline/commit/4ec26e824e0f94b7f8f763d201093052805770c6