Directly using terminal capabilities

Anybody can use functions terminfo

such as tputs()

, tparm()

, tigetstr()

, tigetnum()

right?

I cannot find practical examples online with these low level terminal functions.

Is everyone using a library ncurses

for terminal control and not worrying about this low-level code?

This low-level code is very hard to read I think.

Should I be worried about this low-level code, or just find out ncurses

which is much less overpowered with the higher-level ncurses supported code?

If anyone knows any practical information about such low-level features, please share with me.

+3


source to share


2 answers


Anyone using the ncurses library for terminal control and don't bother with this low-level code?

This is very easy to check.

First, prepare a list of functions in the ncurses library. On my system, this would be:



nm -D /lib64/libncurses.so.5.9 | fgrep ' T ' \
  | sed 's/^[0-9A-Fa-f ]*T //' > /tmp/ncurses-functions-list

      

See how many of them are used in different programs.

for f in /usr/bin/* ; do 
    nm -D $f 2>/dev/null | fgrep ' U ' \
      | sed 's/^ *U //' \
      | fgrep -x -f - /tmp/ncurses-functions-list && echo ==== $f; 
done

      

+2


source


The script is a starting point but needs improvement. First, to say what it does:

  • "nm -D" lists dynamic symbols, that is, those that belong to an external library.
  • the first step gets the list of symbols from the ncurses library and
  • filters it by looking for the pattern "T" that is defined where the function name is defined.
  • after saving the result to file / tmp / ncurses -functions-list, the second script checks each of the programs in / usr / bin
  • the filter pattern in the second script is for undefined characters, i.e. those that come from another library
  • filtering results in a list of function (or data) names, which are then matched against the list made in the first step.


An improvement would be to show (as originally requested) which programs are using the low-level interface and which are using the high-level ncurses interface. As noted in the ncurses FAQ, the library's user types , to distinguish them, is to see which programs call initscr or newterm (you need to initialize the high-level interface) and which don't. A simple "ldd" will show which programs are associated with ncurses (to give the total), and reducing the list of functions to these two would mean - with the second script - that used a high level interface.

0


source







All Articles