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.


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

  • 3
    IBM servers tend to use 3270 and 5250 protocol on top of telnet. Page oriented updates. – user1249 Nov 30 '10 at 19:29
  • 1
    If he is porting a COBOL/CICS program to a midrange platform then curses is a good suggestion. Question doesn't really tell us enough. – Jeremy Nov 30 '10 at 20:04
  • A lot of other platforms offer or use a VT-100 or VT-200-compatible protocol, so they'll use the common "ANSI" codes. – greyfade Nov 30 '10 at 22:09
  • @Thorbjørn Ravn Andersen - Yup. And if you see something called "Novell Virtual Terminal" on top of that, run .. run like hell – Tim Post Dec 1 '10 at 10:43
  • @Tim, bah, face the challenges instead of cowardly running away! – user1249 Dec 1 '10 at 17:01

The generic term for that sort of interface is "command line". You'll probably do better googling for that than for "text user interface".

  • 4
    No, a command line utility just gets stdin and arguments and can just output stdout and stderr and a return code. A TUI on the other hand can update every position on the screen and intercepts all terminal input one key at a time. en.wikipedia.org/wiki/Text_user_interface – Jeremy Nov 30 '10 at 19:59

Don't worry, there are hundreds of standards to choose from :)

I am sadly more comfortable with text- and console-based applications than their older graphical window brethren. Too many days on FidoNet I fear.

The very first thing I would do is learn a few VT100 codes from the old Digital company. You may never write applications in VT100 codes (likely advise against it), but it is a very good and simple introduction to controlling the console matrix.

Libraries such as curses wrap these control codes (and many other style terminal codes) and abstract them so that users can login via their own terminals. Things like VT100 can even do remote (local) printing with which we still struggle today in RDP.

To make things worse for you, IBM systems use not line- or character-based control, but screen- and block-based protocols. Examples are the 3270 and 5250 terminal protocols which for the lack of a better comparison act in the request|response architecture think HTTP. As capable as these are, they are a true PITA IMNSHO with which to work and should be their own separate question.

Worse than that would be writing a console application in a DOS/Windows world. Do reply with your target development platform.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.