I know this is not the exact answer to your question but the [curses](http://en.wikipedia.org/wiki/Curses_%28programming_library%29) library is the stuff you need to do some tui dev. If you're a programmer, looking at its source (available in all open-source unix distributions) will show you how it's done.