像emacs这样的命令行应用程序是否使用普通的stdin / stdout?

时间:2010-12-10 04:07:19

标签: command-line

我编写的几乎所有应用程序都是各种形式的GUI - HTML / Flex / Swing - 我的大部分命令行应用都非常简单,没有太多的交互。我做过的最多的是制作一个简单的ascii游戏,它只是打印/输入循环,一遍又一遍地打印游戏板。

我正在考虑做一些更复杂的事情,我真的很好奇一些像emacs这样的更高级的命令行应用程序是如何工作的。具体来说,我不知道他们似乎能够拥有一个响应按键的交互式命令行,并且似乎只是在终端中的缓冲区上操作而不是经常通过print-> read->打印循环。难道这只是stdin / stdout kung fu我不知道或者是完全不同的东西吗?

更新 - 我想清楚一点,我不是想在这里提出一个广泛的问题,也许我只是难以找到合适的词语。基本上,我不知道如何使用stdin / stdout使emacs工作。它是否使用了一些我不知道的机制,如果有的话,是什么?

1 个答案:

答案 0 :(得分:2)

对于像这样的程序来说,它不仅仅是stdin / stdout。通常它是终端控制库,例如curses

其他一些任意选择的库包括:

另请参阅维基百科上的Text user interface

我对使用这些库中的任何一个都不是很熟悉,但the current version of terminfo.c in the emacs source有以下注释,表明它们确实使用了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.
*/
相关问题