What exactly is it you want to write? Is it a
shell (like bash, dash, csh,...) or a
terminal emulator (like konsole, Terminal, xterm, aterm,...)? Then, do you have a certain language in mind? C or C++ would be common choices, but you should be able to use an other language, if you so wish.
You could certainly have a look at the sources for any one of these, as they are all open source.
Greetings,
Nepomuk