summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses/ncurses/base/lib_bkgd.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/base/lib_bkgd.c')
-rw-r--r--contrib/ncurses/ncurses/base/lib_bkgd.c94
1 files changed, 72 insertions, 22 deletions
diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c
index 071924c..a3d7c30 100644
--- a/contrib/ncurses/ncurses/base/lib_bkgd.c
+++ b/contrib/ncurses/ncurses/base/lib_bkgd.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,51 +33,93 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_bkgd.c,v 1.14 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.26 2001/12/19 01:36:58 tom Exp $")
+/*
+ * Set the window's background information.
+ */
+#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(void)
-wbkgdset(WINDOW *win, chtype ch)
+#else
+static inline void
+#endif
+wbkgrndset(WINDOW *win, const ARG_CH_T ch)
{
- T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch)));
+ T((T_CALLED("wbkgdset(%p,%s)"), win, _tracech_t(ch)));
if (win) {
- chtype off = AttrOf(win->_bkgd);
- chtype on = AttrOf(ch);
+ attr_t off = AttrOf(win->_nc_bkgd);
+ attr_t on = AttrOf(CHDEREF(ch));
toggle_attr_off(win->_attrs, off);
toggle_attr_on(win->_attrs, on);
- if (TextOf(ch) == 0)
- ch |= BLANK;
- win->_bkgd = ch;
+ if (CharOf(CHDEREF(ch)) == L('\0'))
+ SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
+ else
+ win->_nc_bkgd = CHDEREF(ch);
+#if USE_WIDEC_SUPPORT
+ /*
+ * If we're compiled for wide-character support, _bkgrnd is the
+ * preferred location for the background information since it stores
+ * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the
+ * macro getbkgd() will work.
+ */
+ {
+ cchar_t wch;
+ int tmp;
+
+ wgetbkgrnd(win, &wch);
+ tmp = wctob(CharOf(wch));
+
+ win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
+ }
+#endif
}
returnVoid;
}
+NCURSES_EXPORT(void)
+wbkgdset(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wbkgrndset(win, CHREF(wch));
+}
+
+/*
+ * Set the window's background information and apply it to each cell.
+ */
+#if USE_WIDEC_SUPPORT
NCURSES_EXPORT(int)
-wbkgd(WINDOW *win, const chtype ch)
+#else
+static inline int
+#undef wbkgrnd
+#endif
+wbkgrnd(WINDOW *win, const ARG_CH_T ch)
{
int code = ERR;
int x, y;
- chtype new_bkgd = ch;
+ NCURSES_CH_T new_bkgd = CHDEREF(ch);
- T((T_CALLED("wbkgd(%p,%s)"), win, _tracechtype(new_bkgd)));
+ T((T_CALLED("wbkgd(%p,%s)"), win, _tracech_t(ch)));
if (win) {
- chtype old_bkgd = getbkgd(win);
+ NCURSES_CH_T old_bkgrnd;
+ wgetbkgrnd(win, &old_bkgrnd);
- wbkgdset(win, new_bkgd);
- wattrset(win, AttrOf(win->_bkgd));
+ wbkgrndset(win, CHREF(new_bkgd));
+ wattrset(win, AttrOf(win->_nc_bkgd));
for (y = 0; y <= win->_maxy; y++) {
for (x = 0; x <= win->_maxx; x++) {
- if (win->_line[y].text[x] == old_bkgd)
- win->_line[y].text[x] = win->_bkgd;
- else
- win->_line[y].text[x] =
- _nc_render(win, (A_ALTCHARSET &
- AttrOf(win->_line[y].text[x]))
- | TextOf(win->_line[y].text[x]));
+ if (CharEq(win->_line[y].text[x], old_bkgrnd))
+ win->_line[y].text[x] = win->_nc_bkgd;
+ else {
+ NCURSES_CH_T wch = win->_line[y].text[x];
+ RemAttr(wch, ~A_ALTCHARSET);
+ win->_line[y].text[x] = _nc_render(win, wch);
+ }
}
}
touchwin(win);
@@ -86,3 +128,11 @@ wbkgd(WINDOW *win, const chtype ch)
}
returnCode(code);
}
+
+NCURSES_EXPORT(int)
+wbkgd(WINDOW *win, const chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ return wbkgrnd(win, CHREF(wch));
+}
OpenPOWER on IntegriCloud