How do advanced command line applications like emacs work?
Almost all of the applications I've ever written have been GUIs of one form or another - HTML/Flex/Swing - and the bulk of my command line apps have been extremely simple, without much interaction. The most I've ever done is make a simple ascii game that just does a print/input loop, printing the game board over and over again.

I was thinking about doing something a little more complex, and I was really curious how some of the more advanced command line apps like emacs even work. Specifically, I have no idea how they seem to be able to have an interactive command line that responds to key presses and appears to just operate on a buffer in the terminal instead of constantly going through the print->read->print loop. Is it all just stdin/stdout kung fu I'm not aware of or is it something completely different?
How do advanced command line applications like emacs work?
===

Almost all of the applications I've ever written have been GUIs of one form or another - HTML/Flex/Swing - and the bulk of my command line apps have been extremely simple, without much interaction. The most I've ever done is make a simple ascii game that just does a print/input loop, printing the game board over and over again.

I was thinking about doing something a little more complex, and I was really curious how some of the more advanced command line apps like emacs even work. Specifically, I have no idea how they seem to be able to have an interactive command line that responds to key presses and appears to just operate on a buffer in the terminal instead of constantly going through the print->read->print loop. Is it all just stdin/stdout kung fu I'm not aware of or is it something completely different?