And here are the function enter name and flush_sdin
fn enter_name(duration: Res<TextDuration>, main_terminal: NonSendMut<terminal::SystemTerminal>){
print_text(&duration, Speeds::Default, String::from("Please enter your name: "));
flush_stdin();
terminal::Terminal::set_cooked_mode(main_terminal.into_inner());
let mut name = String::new();
io::stdin().read_line(&mut name);
print_text(&duration, Speeds::Default, String::from(format!("Hello, {}!\n", name.trim().green())));
}
fn flush_stdin(){
let mut clean_buffer = [0; 4];
let _ =io::stdin().read(&mut clean_buffer[..]);
}
When I use flush_stdin, I have to press a key before submitting the actual input
Edit: I forgot to mention, the print_text function is just something I used to make print_typed! use different speeds and stuff. I haven't finished the different speeds for now, but that's not important
Took me a while to get it to work because of bevy stuff, but it works a lot better! Is there a way to flush stdin without requiring the user to press a key?
Thanks! So far it kinda works, but since I'm using print_typewriter, the characters that I'm printing are printed one by one, and user input can slip in between them. I'm not sure how to prevent them from showing up in the first place, and not make them appear in stdin.
Or maybe in this case I shouldn't use the terminal, right?
metaphysics, branch of philosophy whose topics in antiquity and the Middle Ages were the first causes of things and the nature of being. In postmedieval philosophy, however, many other topics came to be included under the heading “metaphysics.” (The reasons for this development will be discussed in the body of the article.)
No but like stuff like Santa and money ins't part of metaphysics. It's like an attempt to answer stuff because we don't have the tools to know certain stuff. God would be metaphysics, but not Santa because we know we made Santa up, but the existence of some supreme being (while not exactly how we portray him) is unable to be unproven or proven
Metaphysics isn't looking for a black cat that isn't there. It's assuming that there is a black cat even though there might not be one, because flashlights don't exist yet.
Yes, I am looking for a syntax highlighter for the terminal. The one I use is called Kitty.