How do some programs edit whats being displayed on the terminal (to pick a random example, the program ‘sl’)? I’m thinking of the Linux terminal here, it may happen in other OS’s too, I don’t know. I’ve always thought once some text was displayed, it stayed there. How do you change it without redrawing the entire screen?
Share
Many applications make use of the curses library, or some language binding to it.
For rewriting on a single line, such as updating progress information, the special character ‘carriage return‘, often specified by the escape sequence ‘\r’, can return the cursor to the start of the current line allowing subsequent output to overwrite what was previously written there.