Skip to main content

Brief History of Escape Codes

When installing Linux on a computer, I always install a program called sl. This program displays a train when you execute sl. It is not a practical program but rather a program that gives you time to think when you make a typo with the commonly used ls command in the terminal. Showing a train on the screen helps you calm down and not make other mistakes when you are in a hurry to type. That's why I install this program.

source: https://github.com/mtoyoda/sl

The terminal is a program that receives and displays two streams, stdout, and stderr, from a program. These outputs are sequential outputs and typically flow from the top left to the bottom right. However, to draw new characters on an already-used screen, a special method is needed. This special method is called escape codes.

Escape codes are a kind of promise defined in the terminal. Currently, these promises follow the standards defined in ISO 6429. However, in the past, there was no unified consensus, and each terminal had different rules. Understanding this may require knowledge of computer history.

Today, the term "terminal" means an application for the command-line interface(CLI). However, in the past, a terminal was literally the endpoint device of a computer. This terminal was connected to a mainframe computer and was responsible for its input/output. The reason that modern terminal apps are called "terminal emulators" is that they emulate these old-age terminal devices. Terminals were manufactured by various companies. For instance, ADM-3A, IBM's IBM 2260, and IBM 3270, and the VT series of DEC, which was later merged with HP. Each had its own standards for controlling terminals.

source: https://en.wikipedia.org/wiki/IBM_2260

Escape codes were not compatible across different terminals; efforts to standardize them began in the 1970s. The first standard was ECMA-48, which was first published in 1976. However, the biggest impact on modern escape codes was the VT100, produced by DEC in 1978. The VT100 introduced the Control Sequence Introducer(CSI) and various commands, including important functions such as cursor movement and scrolling, which are still used in modern terminal emulators. Based on the implementation of the VT100, ANSI released the ANSI X3.64 standard in 1979, and in 1983, ISO published ISO 6429 based on ECMA-48 and ANSI X3.64. In 1992, some codes are added. All modern terminal emulators implement escape codes based on ISO 6429.

Comments

Popular posts from this blog

[C++] Handling Exceptions in Constructors

When you use RAII idiom, there are often situations where constructors have to do complex tasks. These complex tasks can sometimes fail, resulting in throwing exceptions. This raises a concern: Is it okay to throw exceptions in constructors? The first concern is memory leaks. Fortunately, memory leaks do not occur. Variables created on the stack are released through stack unwinding, and if an exception occurs during heap allocation with the new operator, the new operator automatically deallocates the memory and returns nullptr . The next concern is whether the destructor of the member variables will be called correctly. However, this is also not a problem. When an exception occurs, member variables can be divided into three categories: fully initialized member variables, member variables being initialized, and uninitialized member variables. Fully initialized member variables have had their constructors called and memory allocations completed successfully. In the example code, t...

Iterator Adapters in Rust

An Iterator that takes another iterator and returns a new one is called an iterator adapter . The name "adapter" comes from one of the GoF's design patterns, the adapter pattern . However, in reality, it corresponds more to the decorator pattern , so if you pay too much attention to the name, you might get confused about its purpose. So it's better not to worry too much about the name. Enough complaining about the name, what does an iterator adapter do? An iterator adapter adds a task to be performed when the iterator iterates. This will be easier to understand when you see an example. The map function is one of the famous adapters. The iterator returned by the map function for those who have used functional languages iterates over new values transformed from the original values. Besides, various adapters are already implemented in the standard library. Among them, the most frequently used are those that are convenient to use with loops. Examples include the ...

What is the size of an empty object?

Consider a class like the one above. Commonly called an "empty class," this class has no internal variables. So, how big is this empty class? At first glance, the size should be 0 since there are no member variables. However, the size is never 0 in any language, whether Java, C#, C (in this case, a struct), or C++. This is to ensure that two different objects never have the same address. Empty classes typically have a size of 1 byte in a 32-bit environment and 2 bytes in a 64-bit environment. However, the exact size cannot be determined. According to the specification, the size just needs to be non-zero. The precise size depends on the implementation. This is a translation of my old Korean post written in 2015. Because the size can vary depending on the implementation, it is now possible to have different sizes (although still not 0). And Languages like Rust have even introduced zero-sized types . We will look at this topic in more detail at a future opportunity.