문제

I want to understand how programs like vim or man work in a shell. How do they let the user scroll, refresh the display and such?

They seem to interact with some console library and hence manipulate what we see. What's really happening?

도움이 되었습니까?

해결책

The terminal has what is called a terminal driver. This isn't a driver in the sense of an interface to hardware, but rather it interprets certain character sequences that cause it to perform operations such as scrolling, text attributes, and so on.

The character sequences are stored in the terminfo database. A library called curses (or its modern equivalent, ncurses) reads the terminfo database and emits the various character sequences based on the functions called.

Separating out the terminfo database from the terminal driver itself allows programs to support a number of terminals such as xterm, the text console, network clients, even remote dumb terminals connected via a serial line.

다른 팁

Here's a great how-to:

You probably want to take a look at chapter 17 - Using the Terminal.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top