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: Bill Gray
Subject: Re: Starange behavior of bkgd when called after bkgdset
Date: Sat, 25 Jun 2022 23:19:56 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

On 6/25/22 17:41, Thomas Dickey wrote:
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.

Apologies in advance if I'm being a bit thick here. I think I grasp what the background _character_ ought to do, but am unclear about how the background _colors_ should behave in this case where you've used bkgdset() and then bkgd().

I made minor modifications to run this in ncurses 6.2, PDCurses, and PDCursesMod, and to first show 'call 0 ++++', for reasons that will become clear :

https://www.projectpluto.com/temp/bkgd_t.c

   With ncurses 6.2,  running Anton's test program got me

6.2
call 0    ++++
call+1+++++++++++++++++++

with only the 'call 1' line with a red background. Hit a key, and that becomes

6.2
call 0    ++++
call-1-------------------
call-2-------------------
(no dashes except on those two lines)

   and the entire screen now has a blue background.  Screenshots at

https://projectpluto.com/temp/before.png
https://projectpluto.com/temp/after.png

Are you saying that the intended behavior (demonstrated in 6.3) is that only the call-1 and call-2 lines should have a blue background, with the rest of the screen left white on black?

Trying it with PDCurses and PDCursesMod got the same 'before', but the 'after' becomes :

https://projectpluto.com/temp/after_pdcm.png

Similar to ncurses 6.2, except only the call 1 and 2 lines change color, and the '++++' for call 0 becomes '----'. I _think_ that second bullet point means it should change just like that. But it seems a little strange.

Thanks!          -- Bill

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.




reply via email to

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