How Do ncurses et. al. Work?

后端 未结 2 1403
广开言路
广开言路 2020-12-09 16:41

There are several libraries like ncurses that assist in making command-line GUIs.

Simply put, how do they work?

My first thought was that ncurses intercepts

2条回答
  •  忘掉有多难
    2020-12-09 17:34

    Text terminals have command sequences that do things like move the cursor to a particular position on the screen, insert characters, delete lines etc.

    Each terminal type is different and has its own set of command sequences. ncurses has a databse (see terminfo for details)

    Internally ncurses maintains 2 views of the screen: the current contents and what the screen should look like after the current pending changes are applied. Once the program requests a screen redraw, ncurses calculates an efficient way to update the screen to look like the desired view. The exact characters/command sequences output depend on what terminal type is in use.

提交回复
热议问题