我在编程上相当新,但我想知道诸如vim,emacs,nano等shell文本编辑器如何能够控制命令行窗口.我主要是Windows程序员,所以也许在*nix上有所不同.据我所知,只能将文本打印到控制台,并要求输入.文本编辑器如何在命令行环境中创建可导航,可编辑的窗口?
通过使用诸如以下的库,这些库反过来使用转义字符序列
NAME ncurses - CRT screen handling and optimization package SYNOPSIS #include DESCRIPTION The ncurses library routines give the user a terminal-independent method of updating character screens with reasonable optimization. This implementation is ‘‘new curses’’ (ncurses) and is the approved replacement for 4.4BSD classic curses, which has been discontinued. [...snip....] The ncurses package supports: overall screen, window and pad manipulation; output to windows and pads; reading terminal input; control over terminal and curses input and output options; environment query routines; color manipulation; use of soft label keys; terminfo capabilities; and access to low-level terminal-manipulation routines.
简短的回答:有它的库(如诅咒,俚语).
更长的答案:通过打印特殊字符序列(称为转义 - 序列,因为它们以ESC字符开头)来完成诸如使用光标跳转或更改颜色等操作.