I have recently been assigned to port an old COBOL program. I am used to GUIs, and I can't understand how a TUI works. I searched a lot through Google but couldn't find something.I knew that console applications could output line by line, but how are colors etc. drawn to the terminal screen? How all this stuff is being drawn?Do terminals support it somehow? Is there a standard? I am really confused.
How do Text User Interfaces (TUI) work?
interfaces;command line
Pretty sure your answer is going to vary based on platform here.  There are many different types of terminal/console and for many more than one standard for writing to it.  Most of them I have seen use some sort of escape sequence (ex: ANSI char escapes for dos, YMMV) where you send a special escape char to interrupt the writing to the screen then you can move the cursor, change colors, etc.If you are writing something literally for dumb terminals then probably going to be using something like https://secure.wikimedia.org/wikipedia/en/wiki/Ncurses