First off, there are no standard termcap capabilities for setting
foreground and background colour. The nearest I've seen to a standard,
which is used by MicroEmacs 3.12 and later is to use the capabilities c0
to c7 for the foreground colours and d0 to d7 for background colours:
Foreground Background Colour
c0 d0 black
c1 d1 red
c2 d2 green
c3 d3 yellow
c4 d4 blue
c5 d5 magenta
c6 d6 cyan
c7 d7 white
These are string capabilities. The values are the escape codes used to
set the terminal to the required foreground or background colour. Once
you've set them up you may well find that other programs use them too.
less may be one of these.
Once you know how your terminal works and what capabilities to use, you
need to do the following two steps:
1) Make sure that the termcap entry for your terminal defines all the
colour setting capabilities you intend to use and the escape codes
are correct for your terminal. Add any that are missing.
2) Write a small C program that uses the termcap library. It should
accept a termcap capability name from
the command line and write the capability values to stdout.
This program can be used to debug termcap entries and in shell
scripts to control the colour and other attributes of its terminal
output.
I wrote such a program years ago, called initvdu. It defaults to using
the 'is' capability which usually initialises the terminal, moves the
cursor to 0,0 and issues a clear-to-EOP - the effect it to clear the
screen and leave the cursor in the top left corner. In addition an -r
option outputs the 'rs' (reset) capability string and -a xx outputs the
xx capability string, so:
echo -n xxxx
initvdu -a so
echo -n ZZZZ
initvdu -a se
echo xxxx
outputs
xxxxZZZZxxxx
with ZZZZ highlighted ('so' is the standout capability and 'se' ends
standout mode.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |