Do command line applications like emacs use regular stdin / stdout?

Almost all the applications that I ever wrote were graphical interfaces of one form or another - HTML / Flex / Swing - and most of the applications from the command line were extremely simple, without much interaction. The most I have ever done is a simple ascii game that just does a print / input cycle, prints the playing field again and again.

I was thinking about making something more complex, and I was very curious about how some of the more advanced command line applications, such as emacs, work. In particular, I have no idea how they seem to have an interactive command line that responds to keystrokes, and apparently just works with a buffer in the terminal, and does not constantly go through the print cycle β†’ read β†’. Is it all just stdin / stdout kung fu, I don’t know or is it something completely different?

Update . I want to be clear that I will not ask a wide question here, maybe it’s just hard for me to find the right words. Basically, I don't know how I will do emacs using stdin / stdout. Am I using some kind of mechanism that I don’t know about, and if so, then what?

+4
source share
1 answer

You are right that this is not just stdin / stdout for such a program. This is usually a terminal management library such as curses .

Some other optional libraries include:

See also Textual user interface on Wikipedia.

I am not very familiar with any of these libraries, but the current version of terminfo.c in the emacs source has the following comment suggesting that they use curses:

/* Interface to curses/terminfo library. Turns out that all of the terminfo-level routines look like their termcap counterparts except for tparm, which replaces tgoto. Not only is the calling sequence different, but the string format is different too. */ 
+2
source

All Articles