[Tutor] Is this the preferred way to change terminal screen color using curses?

boB Stepp robertvstepp at gmail.com
Sat Mar 2 23:32:08 EST 2019


On Sat, Mar 2, 2019 at 4:28 PM Cameron Simpson <cs at cskk.id.au> wrote:

> Is the painting of the screen with spaces actually required? I would
> have thought not (again, untested). The main window (stdscr) should
> start filled with spaces.

I had read this along the way, but had forgotten it.

> [Reads more closely...] probably you want to call bkgd() or wbkgd()
> instead.  "man curs_bkgd" says:
>
>    bkgd
>        The bkgd and wbkgd functions set the background property of the
>        current or  specified  window  and  then  apply this setting to every
>        character position in that window:
>        ·   The rendition of every character on the screen is  changed to
>            the new background rendition.
>        ·   Wherever  the former background character appears, it is changed
>            to the new background character.

I had seen this, but I have been giving way too much credence to the
names given to these methods.  This is the second time I have been
badly burned by the names used.  I had ASSumed that if there is a
bkgdset() method, that the window attributes need to be initialized
first if one is not satisfied with the default behavior.  And I *did*
try using bkgdset() by itself without manually populating spaces, but
it did not change the color of anything but the window border I had
used in my original trial code.

I tried your suggestion with bkgd() and it worked beautifully.

BTW, my Linux Mint installation did *not* have the man pages for
ncurses, even though it was installed.  I had to manually fetch the
man pages myself.

-- 
boB


More information about the Tutor mailing list