diff options
author | ache <ache@FreeBSD.org> | 1997-07-30 17:21:39 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-07-30 17:21:39 +0000 |
commit | d6cf2089bc5887f137a83ede9767e5154e3b8186 (patch) | |
tree | 2eda095cc49ccd84c07771c2714cb72c8d3a931c /lib/libncurses/lib_addch.c | |
parent | 2d46d6b6b7899598c975cea266468603c9a442ba (diff) | |
download | FreeBSD-src-d6cf2089bc5887f137a83ede9767e5154e3b8186.zip FreeBSD-src-d6cf2089bc5887f137a83ede9767e5154e3b8186.tar.gz |
Fix logical background handling by merging it from ncurses 4.1
No new user-visible functions added
Diffstat (limited to 'lib/libncurses/lib_addch.c')
-rw-r--r-- | lib/libncurses/lib_addch.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/libncurses/lib_addch.c b/lib/libncurses/lib_addch.c index 00684ed..88c826c 100644 --- a/lib/libncurses/lib_addch.c +++ b/lib/libncurses/lib_addch.c @@ -13,6 +13,31 @@ #include "curses.priv.h" #include "unctrl.h" +static inline chtype render_char(WINDOW *win, chtype ch) +/* compute a rendition of the given char correct for the current context */ +{ + if (TextOf(ch) == ' ') + ch = ch_or_attr(ch, win->_bkgd); + else if (!(ch & A_ATTRIBUTES)) + ch = ch_or_attr(ch, (win->_bkgd & A_ATTRIBUTES)); + TR(TRACE_VIRTPUT, ("bkg = %#lx -> ch = %#lx", win->_bkgd, ch)); + + return(ch); +} + +chtype _nc_background(WINDOW *win) +/* make render_char() visible while still allowing us to inline it below */ +{ + return(render_char(win, BLANK)); +} + +chtype _nc_render(WINDOW *win, chtype ch) +/* make render_char() visible while still allowing us to inline it below */ +{ + chtype c = render_char(win,ch); + return (ch_or_attr(c,win->_attrs)); +} + static int wladdch(WINDOW *win, chtype c, bool literal) { @@ -54,13 +79,8 @@ chtype ch = c; /* FALL THROUGH */ noctrl: T(("win attr = %x", win->_attrs)); - ch |= win->_attrs; - - if (win->_line[y][x]&A_CHARTEXT == ' ') - ch |= win->_bkgd; - else - ch |= (win->_bkgd&A_ATTRIBUTES); - T(("bkg = %x -> ch = %x", win->_bkgd, ch)); + ch = render_char(win, ch); + ch = ch_or_attr(ch,win->_attrs); if (win->_line[y][x] != ch) { if (win->_firstchar[y] == _NOCHANGE) |