terminal

How do programs overwrite previous lines of output?

血红的双手。 提交于 2020-08-27 21:48:07
问题 Programs such as vim , top , or alsamixer output multiple lines of text and somehow manipulate lines of text that have already been written. I know about writing the \r character to stdout, which returns the cursor to the start of the line, allowing overwriting of the current line, but not any lines before that. What are these programs doing to have these more advanced UIs with fancy terminal manipulation? In my case I'm looking for a Python solution, but any general information would be