Version 0 of terminal control sequence

Updated 2014-05-06 18:52:49 by pooryorick

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.

See Also

Terminal

Reference

ECMA -48: Control Functions for Coded Character Sets:
   [http://en.wikipedia.org/wiki/ANSI_escape_code%|%ANSI escape code], [http://wikipedia.org%|%Wikipedia]:
ANSI/VT100 Terminal Control Escape Sequences
XTerm Control Sequences , by Edward Moy, Stephen Gildea, and Thomas Dickey
ANSI Standard (X3.64) Control Sequences for Video Terminals and Peripherals in alphabetic order , by mnemonic

Description

The most common set of control codes, known as ANSI escape sequences, and standardized in control set is

Example: ANSI Sequences

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:

  • Move the cursor to the right position (\escape[10;0f)
  • Clear everything at this position and below (\escape[J)
  • Write the new output
# 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
}