multiline_term_input/
lib.rs

1/// Reads string where if shift is pressed while new line then keeps reading.
2/// Returns the length of string read in
3#[cfg(target_os = "windows")]
4pub fn read_string(stdin: &mut std::io::Stdin, buf: &mut String) -> usize {
5    use std::io;
6    use winconsole::input::{is_key_down, KeyCode};
7
8    let mut total_count = 0;
9    while let Ok(count) = stdin.read_line(buf) {
10        total_count += count;
11        if is_key_down(KeyCode::Shift) {
12            print!("... ");
13            io::Write::flush(&mut io::stdout()).unwrap();
14        } else {
15            break;
16        }
17    }
18    total_count
19}