diff --git a/TODO.md b/TODO.md index 69fd928a6fd1b4b8675e6ea346a8e9d5bb1f126e..aad9ad6024717c11fc6e7a6985df4dd60788a9e6 100644 --- a/TODO.md +++ b/TODO.md @@ -29,7 +29,7 @@ Grapheme - [ ] grapheme & input auto-wrap are buggy Hints Callback -- [ ] Not implemented on windows +- [x] Not implemented on windows History - [ ] Move to the history line n diff --git a/examples/example.rs b/examples/example.rs index a3c0a666aaee6755fc2d636dff268e6b13126487..39e8f04562becf722ded120d360a64e8ef293718 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -22,7 +22,11 @@ struct Hints {} impl Hinter for Hints { fn hint(&self, line: &str, _pos: usize) -> Option<String> { if line == "hello" { - Some(" \x1b[1mWorld\x1b[m".to_owned()) + if cfg!(target_os = "windows") { + Some(" World".to_owned()) + } else { + Some(" \x1b[1mWorld\x1b[m".to_owned()) + } } else { None } diff --git a/src/tty/windows.rs b/src/tty/windows.rs index 4faed8fe4647cd5bbc5604527f62429459829c13..92fe2c41777e40d0890acfad5f67ffa7ad4716b7 100644 --- a/src/tty/windows.rs +++ b/src/tty/windows.rs @@ -308,6 +308,10 @@ impl Renderer for ConsoleRenderer { ab.push_str(prompt); // display the input line ab.push_str(&line); + // display hint + if let Some(hint) = hint { + ab.push_str(truncate(&hint, end_pos.col, self.cols)); + } try!(self.write_and_flush(ab.as_bytes())); // position the cursor