These are the most essential terminal control sequences that you will need for your train program.
Code | Effect |
"\033[2J" | Clear the screen. |
"\033[H" | Move the cursor to the upper-left corner of the screen. |
"\033[r;cH" | Move the cursor to row r, column c. Note that both the rows and columns are indexed starting at 1. |
"\033[?25l" | Hide the cursor. |
"\033[K" | Delete everything from the cursor to the end of the line. |
These control sequences can help make your program's display more lively.
Code | Effect |
"\033[0m" | Reset special formatting (such as colour). |
"\033[30m" | Black text. |
"\033[31m" | Red text. |
"\033[32m" | Green text. |
"\033[33m" | Yellow text. |
"\033[34m" | Blue text. |
"\033[35m" | Magenta text. |
"\033[36m" | Cyan text. |
"\033[37m" | White text. |