bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Starange behavior of bkgd when called after bkgdset


From: Thomas Dickey
Subject: Re: Starange behavior of bkgd when called after bkgdset
Date: Sat, 25 Jun 2022 17:41:27 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, Jun 25, 2022 at 05:06:54PM -0400, Thomas Dickey wrote:
> On Sat, Jun 25, 2022 at 04:27:58PM -0400, Thomas Dickey wrote:
> > On Sat, Jun 25, 2022 at 07:18:58PM +0200, Anton Vidovic wrote:
> ...
> > > Compare that to the second situation:
> > > 
> > > Calling bkgdset('+') sets only the bg char of the single line (because
> > > of the "\n" subsequent call to addstr):
> > > 
> > > call+1+++++++++
> > > 
> > > and the subsequent call to bkgd('-') only affects that line and the
> > > second line and leaves the rest of the screen without any background
> > > char:
> > > 
> > > call-1---------
> > > call-2---------
> 
> Interestingly enough, Solaris (SVr4) curses does this.
> The colors may differ (no bce), but the +'s and -'s match up.
> 
> > sure - if I conclude that it's correct.
> 
> yes... more documentation is needed, to explain this.

Actually it's there, in the second bullet:

   bkgd
       The bkgd and wbkgd functions set the background property of the current
       or  specified window and then apply this setting to every character po‐
       sition 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'll add a few sentences to explain this special case.

> What's happening is due to this check:
> https://github.com/ThomasDickey/ncurses-snapshots/blob/6bf016303929e7f49758b7ed27e3b255310b959f/ncurses/base/lib_bkgd.c#L222
> 
>               if (CharEq(*cp, old_bkgd)) {
> #if USE_WIDEC_SUPPORT
>                   if (!narrow) {
>                       if (Charable(new_bkgd)) {
>                           SetChar2(*cp, CharOf(new_char));
>                       } else {
>                           SetChar(*cp, L' ', AttrOf(new_char));
>                       }
>                       memcpy(cp->chars,
>                              new_char.chars,
>                              CCHARW_MAX * sizeof(cp->chars[0]));
>                   } else
> #endif
>                       SetChar2(*cp, CharOf(new_char));
>               }
> 
> In the logic which I adapted from Solaris, that comparison against
> old_bkgd is checking each cell to determine if the cell used the
> same background-character as the old value for the background-character.
> If it did not, it leaves that untouched.
> 
> Setting the background character to "+" without filling the screen with +'s
> produces this special case.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]