white text, black background

white text, black background

Post by Terenc » Mon, 12 May 2003 14:38:14



Hi,

In Shell script, how to print a white text with blackground?

Or hints to man will helps to.

Thanks and regards

 
 
 

white text, black background

Post by Charles Dem » Mon, 12 May 2003 17:36:45




>Hi,

>In Shell script, how to print a white text with blackground?

>Or hints to man will helps to.

my guess to get you there,

man -k color

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,

  Die Anyway         |    v    | That no one could find fault with it.


 
 
 

white text, black background

Post by Meinolf Sande » Mon, 12 May 2003 18:16:23



> In Shell script, how to print a white text with blackground?

You could try it with ?setterm -foreground white -background black?.
I believe that $TERM has to be defined in this case.
--
Your lucky number has been disconnected.
 
 
 

white text, black background

Post by Meinolf Sande » Mon, 12 May 2003 18:38:00



> In Shell script, how to print a white text with blackground?

You could try it with ?setterm -foreground white -background black?.
I believe that $TERM has to be defined in this case. The command
is available at least in Linux.

Meinolf
--
Your lucky number has been disconnected.

 
 
 

white text, black background

Post by Stephane CHAZELA » Tue, 13 May 2003 05:21:27



> In Shell script, how to print a white text with blackground?

"Black background", you mean ?

You can use the "standout" terminal capability. In most
terminals, it reverses background and foreground colours:

SMSO=`tput smso`
RMSO=`tput rmso`

printf '%s\n' "normal${SMSO}reverse${RMSO}normal"

Or, to explicitely tell the terminal you want a black background
and a white foreground, it's much terminal dependent, because
color are specified as numbers and codes depend on the number of
colors your terminal support.

For terminals that support ANSI 8 colors, the following should
work:

blackbg=`tput setab 0`
whitefg=`tput setaf 7`
normal=`tput sgr0`

printf '%s\n' "${blackbg}${whitefg}white over black${normal}"

Note that if your terminal is XFree86 xterm, it's likely to have
at least 16 colors (it can be compiled to up to 256 color
support). Unfortunately, most terminfo entries for "xterm" claim
it has only 8 colors, but you may try:

whitefg=`TERM=xterm-16color tput setaf 15`

The point is that 7 is generally a "dark" white (or a light
grey) and 15 a true white. Some terminals fake 16 color mode by
using a different color when in bold mode, you can try:

whitefg=`tput bold; tput setaf 7`

--
Stphane

 
 
 

white text, black background

Post by Chris F.A. Johnso » Wed, 14 May 2003 02:38:28




>> In Shell script, how to print a white text with blackground?

> "Black background", you mean ?

> You can use the "standout" terminal capability. In most
> terminals, it reverses background and foreground colours:

> SMSO=`tput smso`
> RMSO=`tput rmso`

   Unfortunately, tput is not universally available (SunOS 4.1.x, for
   instance doesn;t have it), and its attributes differ from system to
   system. The attributes are not the same on FreeBSD as on Linux.

   Examples for FreeBSD:

        BOLD=`tput md 2>/dev/null`
        REVERSE=`tput mr 2>/dev/null`

   Examples for Linux:

        BOLD=`tput bold 2>/dev/null`
        REVERSE=`tput rev 2>/dev/null`

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

white text, black background

Post by Stephane CHAZELA » Wed, 14 May 2003 03:44:38


[...]

Quote:>    Examples for FreeBSD:

>         BOLD=`tput md 2>/dev/null`
>         REVERSE=`tput mr 2>/dev/null`

>    Examples for Linux:

>         BOLD=`tput bold 2>/dev/null`
>         REVERSE=`tput rev 2>/dev/null`

Yes that's the usual SysV vs BSD, terminfo vs termcap thing.

Note that termcap (BSD) predates terminfo (SysV), but "tput" was
initially a terminfo command. It was introduced late in BSD
(4.4). I wonder why they didn't pick another name as it's
clearly not the same syntax.

Linux curses library is ncurses. It can be compiled with both
terminfo and termcap support (so "tput md" may be made to work
under Linux).

Do all the BSDs still use termcap or is it just FreeBSD?

POSIX defines a tput command but the only standardized arguments
are "clear", "init" and "reset".

tcsh has "echotc".

Zsh has a zsh/termcap and a zsh/terminfo modules that provide
two builtins: echotc and echoti and two associative arrays
(termcap and terminfo). However, it's not finalized yet.

--
Stphane

 
 
 

white text, black background

Post by Thomas Dicke » Wed, 14 May 2003 19:18:43




> [...]
>>    Examples for FreeBSD:

>>         BOLD=`tput md 2>/dev/null`
>>         REVERSE=`tput mr 2>/dev/null`

>>    Examples for Linux:

>>         BOLD=`tput bold 2>/dev/null`
>>         REVERSE=`tput rev 2>/dev/null`
> Yes that's the usual SysV vs BSD, terminfo vs termcap thing.
> Note that termcap (BSD) predates terminfo (SysV), but "tput" was
> initially a terminfo command. It was introduced late in BSD
> (4.4). I wonder why they didn't pick another name as it's
> clearly not the same syntax.

probably because they didn't anticipate running the two versions.  (Back
in the mid-90's it was not uncommon to encounter BSD-developers who were
proud that their code was still K&R, for instance - that's changed a little).

Quote:> Linux curses library is ncurses. It can be compiled with both
> terminfo and termcap support (so "tput md" may be made to work
> under Linux).
> Do all the BSDs still use termcap or is it just FreeBSD?

no (OpenBSD has upgraded; FreeBSD uses ncurses terminfo with a facade to make
it look as if it's termcap).  Occasionally I see someone proposing "termcap"
entries that are terminfo.

Quote:> POSIX defines a tput command but the only standardized arguments
> are "clear", "init" and "reset".

I hadn't noticed that before, since the SVr4-based implementations all
allow a terminfo capability name (but much of POSIX in this area is poorly
edited).

--

http://dickey.his.com
ftp://dickey.his.com