Meanings of terminal codes \033[E and \033[07, which appear in printf() statements?

3.2k views Asked by At

In the C implementation for the Game of Life program, as shown here the codes I mentioned appear in the show() function. I can't find any information at all about what 033[E means and as for \033[07 this is usually a color code in linux bash terminal, where with \033[07m we begin the color coding and with \033[m we end the predefined color coding. However, according to this website it means "reverse". I'm not sure what that means.

I'm more interested though in \033[E code, for which I can find no information. From testing and debugging the program with gcc on Linux bash, I see that without this command, the output is not displayed as intended. If anyone can share knowledge on this, I would appreciate it. Thanks in advance.

1

There are 1 answers

7
Jongware On BEST ANSWER

The sequence ESC [ E is an error – or possibly, a hypercorrect version – in that source. The code is ESC E, and it serves to move the cursor to the next line. The [ indicates it can take an optional numerical parameter (zero or more), and in this case there are none, so it can be omitted. (A numerical parameter would indicate how many lines to skip; 0 or 1 shows a regular newline, and higher values makes it skip lines.)

The definition is hard to find because it's more usual to just use \n – the regular newline code – to move the cursor to the start of the next line in a terminal program.

The sequence ESC [07m also contains a redundant code, ESC [7m is enough to put the terminal into Reverse mode. You are probably used to adding this to the start of a color sequence so you can set the foreground color of the text (numbers from 30..37) instead of background (40..47), and use spaces to draw a colored block.