Exploring terminfo

Grant Edwards grant.b.edwards at gmail.com
Tue Jan 19 17:42:26 EST 2021


On 2021-01-19, Eli the Bearded <*@eli.users.panix.com> wrote:

> Putting my Unix hat on, curses is a "friendly" library around creating
> text-windowed applications. Programs like mutt use curses rather than
> raw terminal operations, programs like vi use raw terminal operations.
> Either curses or raw terminal operations will (should) consult a
> terminal capabilities database to figure out what can be done and how to
> do it. The two competing database formats for that are termcap and
> terminfo, where terminfo is the newer, better one.

Back in the day, weren't the termcap/terminfo libraries maintained and
installed seperately from curses?  I would have sworn that only a few
years ago terminfo and ncurses libraries were seperate -- though
recently both were provided by ncurses, IIRC.

[...]

> Okay, checking the source to the only vi I have lying around[*], it uses
> a few curses calls, apparently only these:
>
>     int tgetent(char *bp, const char *name);
>     int tgetflag(char *id);
>     int tgetnum(char *id);
>     char *tgetstr(char *id, char **area);
>     char *tgoto(const char *cap, int col, int row);
>     int tputs(const char *str, int affcnt, int (*putc)(int));

In my mind, those are curses library calls, they're termcap/terminfo
library calls. [I can't recall whether terminfo and termcap APIs were
compatible or not.]

> My local manpage calles this set the "direct curses interface to the
> terminfo capability database" whereas things I think of as "curses"
> programs use calls like:
>
>     WINDOW *initscr(void);
>     int cbreak(void);
>     int start_color(void);
>     int noecho(void);
>     int move(int y, int x);
>     int attr_set(attr_t attrs, short pair, void *opts);
>     int getch(void);
>     int addch(const chtype ch);
>     int printw(const char *fmt, ...);

Exactly. _Those_ are curses library calls.

--
Grant




More information about the Python-list mailing list