Find a way to clear a virtual line on a terminal
Some pieces of code (like #2121) tries to clear a line on a terminal. The problem is that simple solutions (using escape code sequence to erase a line, manipulating cursor positions) do not work as soon as the terminal wraps the line. In that case, we only erase a part of a line because ANSI escape code sequences manipulate physical coordinates of the displayed characters. For example, if we printn("123456789foo") on a 10-columns terminal, we will get the two following physical lines:
123456789f
oo
Then, if we printn("\r42") (for example), the terminal will display this:
123456789f
42
Note: The SCP (Save Cursor Position) code may seems to work when your terminal is clean. But, when you begin to write pass the screen height, then the recorded position seems to follow the end of your terminal’s screen.
Yeah. I'm note sure what is the state of the art when handling simple pseudo-graphical effects.
I searched a way in 2014 (because neo_doxygen has the aforementioned problem with the SCP trick), but I only found a bunch of “use ncurses” answers.