For context, I am using the libraries bevy and print_typewriter.

I noticed that before the program even starts, I am able to type in characters. This is bad, since when I ask for the user’s input, the previous characters are included inside of it.

How do I make sure that only the user’s input after the program starts, and after I print a question gets in?

  • Vector@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    4 months ago

    I’m sure there are ways to suppress output from stdin presenting in the terminal but I couldn’t tell you how to do it without looking it up myself.

    The easiest entry point to this problem that I can think of off the top of my head is password input masking (e.g., when you run sudo and type your password, it prevents character output even though the characters are read by the application).

    There is almost certainly a much better and more appropriate mechanism to prevent stdin characters from printing directly to the terminal (perhaps some kind of special character? A TTY control option?) but I don’t know it off-hand.