Can't Seem To Fix This Wonky Console Output

So, the project I've been working on is a little cli tool to play a game like wordle right in the terminal.

I am using a Text input from the inquire crate to accept input from the user.

I'm also using the console crate to print out the remaining letters of the "keyboard" and highlight them to show if they have been guessed already and if they are in the word, correct position, etc.

I am also using some other crates for the generation of secret word and validation of guesses, but I don't think they are relevant to the console output wonkiness...

So, everything technically works right now, but the weird part is that when I start typing my whole prompt shifts up one line in my terminal. It's super weird and I'm not sure if the bug is caused by inquire, or console, or the two of them together, or the fact that I'm using all these things in the "help message" of my text input, or if it's just a unix thing...

It's hard to explain so I made this gif to try what I mean:


This project lives in the "wip_wordle_game" directory within this repo. Feel free to take a look at the code and / or run it yourself with cargo run.

I'm looking for any advice on what I should try and / or insight into why this wonkiness is happening.

In the inquire docs it says, "You can choose your terminal backend between crossterm (default), termion or console".

I can try to reimplement the coloring using crossterm or termion, but I am very curious what's going on here with the console crate...


I'm not familiar with inquire myself, but I would not be surprised if printing text from inside the validation function is interfering with inquire's intended operation.

1 Like

True, that could be where my issue is stemming from, but if I actually want to print stuff when validation succeeds or fails… what would be the right way to do this? :thinking:

You'd put your message only in the Validation::Invalid.

A fundamental fact about terminal UI is that your program, as a whole, has to produce coherent output that, after being interpreted by the terminal, will produce something the user understands. Sometimes that is as simple as “always print whole lines”, and a mixture of lines will be readable (e.g. for logging), but as soon as you start doing things involving cursor movement, you have to plan out how things will go. inquire evidently has a plan, and so you need to either cooperate with its plan (by only providing strings to it and not printing anything yourself) or not use it.

1 Like

Seems like that's not it though.

Even when I remove the printing from the help message, the cursor wonkiness still occurs.

I think it is definitely some kind of issue with using "console" in the help message.

When I replace the help message text with some hardcoded string the wonkiness is gone... :thinking: