kkawakam / rustyline

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

confusing example on helper - color for prompt only needed - no matching brackets, completions etc. #628

Closed RustyJoeM closed 2 years ago

RustyJoeM commented 2 years ago

Hello,

I have seen the example file but i find it quite confusing.

I do not need bracket matching, file completions or hinting, just plain colored prompt with some ANSI string (i got e.g. from colored crate, or manually written).

Can I add highlight_prompt functionality, without all the "underlated" traits (completion, hints, validations, ...)?

There are some references to colored_prompt in the example code, but helper has extra methods & traits that seem completely unrelated to the prompt higlighting, and it's not clear whether they can/should be replaced with some placeholder code to keep other functionality intact.

gwenn commented 2 years ago

There is also an example with only an highlighter: https://github.com/kkawakam/rustyline/blob/master/examples/read_password.rs#L30-L32 And all Highlighter trait methods have a default implementation that does nothing (no highlighting) so you just have to overwrite highlight_prompt impl.

RustyJoeM commented 2 years ago

perfect, thank you for direction! :)