I need to make it so that when I press a key, the cursor remains in its place (column) and just updates the symbol (doesn't move to the next column automatically). Is it possible to do this using ANSI escape code? I want to move the cursor only when I need it (for example, via printf("\e[1C");)
The terminal is in raw mode.
Put the terminal in non echo mode. Hence, your program controls what you want to display back on the screen.
Here is an example in shell which sets the terminal in raw and non echo mode, displays all the input chars at the same place (moving the cursor 1 step backward with "ESC[1D"), move the cursor 1 step forward if it is a space (with "ESC[1C") and exit if it is "Q":
Doing the same in C is straightforward. Don't forget to call
fflush(stdout)after the calls toprintf()if they don't display\n