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 16:27:58 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Sat, Jun 25, 2022 at 07:18:58PM +0200, Anton Vidovic wrote:
> Hello Thomas,
> 
> The man page for bkgd states:
> 
> "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_."
> 
> Calling bkgd after bkgdset does not apply the character to all cells
> in the terminal, just where it happens to be placed by a previous call
> to bkgdset.
> 
> For example:
> 
> int main()
> {
>     initscr();
>     noecho();
>     cbreak();
>     start_color();
> 
>     init_pair(1, COLOR_YELLOW, COLOR_RED);
>     init_pair(2, COLOR_WHITE, COLOR_BLUE);
> 
>     printw("%s\n", NCURSES_VERSION);
> 
>     bkgdset('+' | COLOR_PAIR(1));
>     // bkgd('+' | COLOR_PAIR(1));
>     addstr("call 1\n");
>     getch();
> 
>     bkgd('-' | COLOR_PAIR(2));
>     addstr("call 2\n");
> 
>     refresh();
>     getch();
>     endwin();
>     return 0;
> }
> 
> 
> Calling bkgd('+') sets the bg char of the whole screen to '+':
> 
> call+1+++++++++
> +++++++++++++++
> +++++++++++++++
> +++++++++++++++
> 
> Calling bkgd('-') after that changes the bg char of the whole screen
> to -.
> 
> call-1---------
> call-2---------
> ---------------
> ---------------
> 
> 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---------
> 
> 
> It explicitely does not "apply this setting to every character
> position in that window" as stated in the man page.
> 
> Is this the intended behavior? As far as I can tell, the behavior
> changed between ncurses 6.1 and 6.2.

I don't think so :-(

offhand, it looks like a problem with bkgdset
 
> It is briefly mentioned in the release notes, but without mentioning
> that a call to bkgd is now essentially invalidated by a previous call to
> bkgdset.

There was a flaw in the changes that I noted here:

https://invisible-island.net/ncurses/NEWS.html#t20190817
        + amend 20181208 changes for wbkgd() and wbkgrnd(), fixing a few
          details where it still differed from SVr4.
https://invisible-island.net/ncurses/NEWS.html#t20181208
        + modify wbkgd() and wbkgrnd() to improve compatibility with SVr4
          curses, changing the way the window rendition is updated when the
          background character is modified (report by Valery Ushakov).

It didn't fill in a "character" for the background, e.g., if
only attributes/color were specified.  You reported that here:

https://lists.gnu.org/archive/html/bug-ncurses/2021-02/msg00003.html

This might be another problem arising from the SVr4-compatibility change
in which I introduced that error.

I'll see what I can do - it should be fast to identify when it changed...

(I've been working on a memory-leak in tic, which isn't quick to fix,
but isn't as noticeable as this).
 
> If possible, could you please clarify? If the behavior is intended,
> could you please emphasize in the man page, that the part "apply
> this setting to every character position in that window" is conditional
> and does not apply to every call of that function?

sure - if I conclude that it's correct.

-- 
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]