aboutsummaryrefslogtreecommitdiff
path: root/scripts/kconfig/libcurses/bkgd.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--scripts/kconfig/libcurses/bkgd.c228
1 files changed, 228 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/bkgd.c b/scripts/kconfig/libcurses/bkgd.c
new file mode 100644
index 000000000..c92df28be
--- /dev/null
+++ b/scripts/kconfig/libcurses/bkgd.c
@@ -0,0 +1,228 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7bkgd
8----
9
10### Synopsis
11
12 int bkgd(chtype ch);
13 void bkgdset(chtype ch);
14 chtype getbkgd(WINDOW *win);
15 int wbkgd(WINDOW *win, chtype ch);
16 void wbkgdset(WINDOW *win, chtype ch);
17
18 int bkgrnd(const cchar_t *wch);
19 void bkgrndset(const cchar_t *wch);
20 int getbkgrnd(cchar_t *wch);
21 int wbkgrnd(WINDOW *win, const cchar_t *wch);
22 void wbkgrndset(WINDOW *win, const cchar_t *wch);
23 int wgetbkgrnd(WINDOW *win, cchar_t *wch);
24
25### Description
26
27 bkgdset() and wbkgdset() manipulate the background of a window. The
28 background is a chtype consisting of any combination of attributes
29 and a character; it is combined with each chtype added or inserted to
30 the window by waddch() or winsch(). Only the attribute part is used
31 to set the background of non-blank characters, while both character
32 and attributes are used for blank positions.
33
34 bkgd() and wbkgd() not only change the background, but apply it
35 immediately to every cell in the window.
36
37 wbkgrnd(), wbkgrndset() and wgetbkgrnd() are the "wide-character"
38 versions of these functions, taking a pointer to a cchar_t instead of
39 a chtype. However, in PDCurses, cchar_t and chtype are the same.
40
41 The attributes that are defined with the attrset()/attron() set of
42 functions take precedence over the background attributes if there is
43 a conflict (e.g., different color pairs).
44
45### Return Value
46
47 bkgd() and wbkgd() return OK, unless the window is NULL, in which
48 case they return ERR.
49
50### Portability
51
52 Function | X/Open | ncurses | NetBSD
53 :---------------------|:------:|:-------:|:------:
54 bkgd | Y | Y | Y
55 bkgdset | Y | Y | Y
56 getbkgd | Y | Y | Y
57 wbkgd | Y | Y | Y
58 wbkgdset | Y | Y | Y
59 bkgrnd | Y | Y | Y
60 bkgrndset | Y | Y | Y
61 getbkgrnd | Y | Y | Y
62 wbkgrnd | Y | Y | Y
63 wbkgrndset | Y | Y | Y
64 wgetbkgrnd | Y | Y | Y
65
66**man-end****************************************************************/
67
68int wbkgd(WINDOW *win, chtype ch)
69{
70 int x, y;
71 chtype oldcolr, oldch, newcolr, newch, colr, attr;
72 chtype oldattr = 0, newattr = 0;
73 chtype *winptr;
74
75 PDC_LOG(("wbkgd() - called\n"));
76
77 if (!win)
78 return ERR;
79
80 if (win->_bkgd == ch)
81 return OK;
82
83 oldcolr = win->_bkgd & A_COLOR;
84 if (oldcolr)
85 oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
86
87 oldch = win->_bkgd & A_CHARTEXT;
88
89 wbkgdset(win, ch);
90
91 newcolr = win->_bkgd & A_COLOR;
92 if (newcolr)
93 newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
94
95 newch = win->_bkgd & A_CHARTEXT;
96
97 /* what follows is what seems to occur in the System V
98 implementation of this routine */
99
100 for (y = 0; y < win->_maxy; y++)
101 {
102 for (x = 0; x < win->_maxx; x++)
103 {
104 winptr = win->_y[y] + x;
105
106 ch = *winptr;
107
108 /* determine the colors and attributes of the character read
109 from the window */
110
111 colr = ch & A_COLOR;
112 attr = ch & (A_ATTRIBUTES ^ A_COLOR);
113
114 /* if the color is the same as the old background color,
115 then make it the new background color, otherwise leave it */
116
117 if (colr == oldcolr)
118 colr = newcolr;
119
120 /* remove any attributes (non color) from the character that
121 were part of the old background, then combine the
122 remaining ones with the new background */
123
124 attr ^= oldattr;
125 attr |= newattr;
126
127 /* change character if it is there because it was the old
128 background character */
129
130 ch &= A_CHARTEXT;
131 if (ch == oldch)
132 ch = newch;
133
134 ch |= (attr | colr);
135
136 *winptr = ch;
137
138 }
139 }
140
141 touchwin(win);
142 PDC_sync(win);
143 return OK;
144}
145
146int bkgd(chtype ch)
147{
148 PDC_LOG(("bkgd() - called\n"));
149
150 return wbkgd(stdscr, ch);
151}
152
153void wbkgdset(WINDOW *win, chtype ch)
154{
155 PDC_LOG(("wbkgdset() - called\n"));
156
157 if (win)
158 {
159 if (!(ch & A_CHARTEXT))
160 ch |= ' ';
161
162 win->_bkgd = ch;
163 }
164}
165
166void bkgdset(chtype ch)
167{
168 PDC_LOG(("bkgdset() - called\n"));
169
170 wbkgdset(stdscr, ch);
171}
172
173chtype getbkgd(WINDOW *win)
174{
175 PDC_LOG(("getbkgd() - called\n"));
176
177 return win ? win->_bkgd : (chtype)ERR;
178}
179
180#ifdef PDC_WIDE
181int wbkgrnd(WINDOW *win, const cchar_t *wch)
182{
183 PDC_LOG(("wbkgrnd() - called\n"));
184
185 return wch ? wbkgd(win, *wch) : ERR;
186}
187
188int bkgrnd(const cchar_t *wch)
189{
190 PDC_LOG(("bkgrnd() - called\n"));
191
192 return wbkgrnd(stdscr, wch);
193}
194
195void wbkgrndset(WINDOW *win, const cchar_t *wch)
196{
197 PDC_LOG(("wbkgdset() - called\n"));
198
199 if (wch)
200 wbkgdset(win, *wch);
201}
202
203void bkgrndset(const cchar_t *wch)
204{
205 PDC_LOG(("bkgrndset() - called\n"));
206
207 wbkgrndset(stdscr, wch);
208}
209
210int wgetbkgrnd(WINDOW *win, cchar_t *wch)
211{
212 PDC_LOG(("wgetbkgrnd() - called\n"));
213
214 if (!win || !wch)
215 return ERR;
216
217 *wch = win->_bkgd;
218
219 return OK;
220}
221
222int getbkgrnd(cchar_t *wch)
223{
224 PDC_LOG(("getbkgrnd() - called\n"));
225
226 return wgetbkgrnd(stdscr, wch);
227}
228#endif