bug-ncurses
[Top][All Lists]
Advanced

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

Starange behavior of bkgd when called after bkgdset


From: Anton Vidovic
Subject: Starange behavior of bkgd when called after bkgdset
Date: Sat, 25 Jun 2022 19:18:58 +0200

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.

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.

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?

Thanks and kind regards,
Anton Vidovic



reply via email to

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