Linux/Unix Console Graphics/Control
I would like to know how to create console applications with better control of input and output using C. For example, how does the text-editor 开发者_StackOverflow社区nano display the file contents in a certain portion of the screen and then keep a list of commands stationary on the bottom. I know you can use the win32 api to do this in Windows, but what is the Unix/Linux equivalent?
More than likely there's a ncurses interface that controls the screen drawing and placement of items on the screen in a certain position. The api is standard across the linux systems and on unix also, some may be implementation defined depending on the variant of curses used under the commercial variants of unix but otherwise some standard ncurses functionality are compatible.
Besides ncurses and depending on the task at hands you may find newt, a library for color text mode, widget-based user interfaces, a suitable alternative also. Sometimes visual results are better with newt.
If you just want to do the low level stuff, you probably want to use the termcap or terminfo library.
If you want to do it the way nano and just about every other interactive terminal app does it, you probably want to use ncurses. That way you will spend less time implementing terminal control logic, and more time on the actual app you are developing.
精彩评论