A Terminal Control Code, AKA terminal escape sequence, AKA terminal control sequecence, is an in-band sequence of bytes that may be interpreted by a character imaging device such as a terminal.
The most common set of control codes, known as ANSI escape sequences, and standardized in control set is
AM 2014-05-06: The other day someone asked about controlling the output on screen, so that the last line would be rewritten with new results. Here is a simple solution which works with these ANSI escape codes. Unfortunately you only get the proper effect on Linux terminals and other ANSI-enabled terminals. The code is, however, dead simple:
# showcomp.tcl -- # Small program to illustrate the use of ANSI sequences # while 1 { puts -nonewline "\x1b\[10;1f\x1b\[J" puts "Result: [clock seconds] - [expr {rand()}]" puts "Computing ..." after 1000 }
AMG: For single-line displays, e.g. progress meters, I use \r which rewinds to the start of the line. Then \x1b[K clears to end of line.
while {1} { puts -nonewline "\r[clock format [clock seconds]]\x1b\[K" flush stdout after 900 }