aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/Makefile3
-rw-r--r--scripts/kconfig/libcurses/Kbuild.src51
-rw-r--r--scripts/kconfig/libcurses/README.md20
-rw-r--r--scripts/kconfig/libcurses/acs437.h35
-rw-r--r--scripts/kconfig/libcurses/acsuni.h35
-rw-r--r--scripts/kconfig/libcurses/addch.c408
-rw-r--r--scripts/kconfig/libcurses/addstr.c239
-rw-r--r--scripts/kconfig/libcurses/attr.c409
-rw-r--r--scripts/kconfig/libcurses/beep.c74
-rw-r--r--scripts/kconfig/libcurses/bkgd.c226
-rw-r--r--scripts/kconfig/libcurses/border.c414
-rw-r--r--scripts/kconfig/libcurses/clear.c159
-rw-r--r--scripts/kconfig/libcurses/color.c298
-rw-r--r--scripts/kconfig/libcurses/curses.h1406
-rw-r--r--scripts/kconfig/libcurses/curspriv.h119
-rw-r--r--scripts/kconfig/libcurses/getch.c587
-rw-r--r--scripts/kconfig/libcurses/getyx.c142
-rw-r--r--scripts/kconfig/libcurses/inch.c126
-rw-r--r--scripts/kconfig/libcurses/initscr.c400
-rw-r--r--scripts/kconfig/libcurses/inopts.c368
-rw-r--r--scripts/kconfig/libcurses/kernel.c297
-rw-r--r--scripts/kconfig/libcurses/move.c77
-rw-r--r--scripts/kconfig/libcurses/outopts.c175
-rw-r--r--scripts/kconfig/libcurses/overlay.c214
-rw-r--r--scripts/kconfig/libcurses/pad.c278
-rw-r--r--scripts/kconfig/libcurses/pdcclip.c149
-rw-r--r--scripts/kconfig/libcurses/pdcdisp.c303
-rw-r--r--scripts/kconfig/libcurses/pdcgetsc.c42
-rw-r--r--scripts/kconfig/libcurses/pdckbd.c681
-rw-r--r--scripts/kconfig/libcurses/pdcscrn.c733
-rw-r--r--scripts/kconfig/libcurses/pdcsetsc.c130
-rw-r--r--scripts/kconfig/libcurses/pdcutil.c26
-rw-r--r--scripts/kconfig/libcurses/pdcwin.h27
-rw-r--r--scripts/kconfig/libcurses/printw.c129
-rw-r--r--scripts/kconfig/libcurses/refresh.c277
-rw-r--r--scripts/kconfig/libcurses/scroll.c101
-rw-r--r--scripts/kconfig/libcurses/slk.c671
-rw-r--r--scripts/kconfig/libcurses/touch.c199
-rw-r--r--scripts/kconfig/libcurses/window.c581
-rwxr-xr-xscripts/kconfig/lxdialog/check-lxdialog.sh6
40 files changed, 10615 insertions, 0 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 38bae809a..e0d7e2190 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -11,6 +11,9 @@ gconfig: $(obj)/gconf
11 $< Config.in 11 $< Config.in
12 12
13menuconfig: $(obj)/mconf 13menuconfig: $(obj)/mconf
14ifdef W64DEVKIT
15 $(Q)$(MAKE) $(build)=scripts/kconfig/libcurses
16endif
14 $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog 17 $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog
15 $< Config.in 18 $< Config.in
16 19
diff --git a/scripts/kconfig/libcurses/Kbuild.src b/scripts/kconfig/libcurses/Kbuild.src
new file mode 100644
index 000000000..d04da63bb
--- /dev/null
+++ b/scripts/kconfig/libcurses/Kbuild.src
@@ -0,0 +1,51 @@
1lib-y :=
2
3INSERT
4
5lib-y +=addch.o
6lib-n +=addchstr.o
7lib-y +=addstr.o
8lib-y +=attr.o
9lib-y +=beep.o
10lib-y +=bkgd.o
11lib-y +=border.o
12lib-y +=clear.o
13lib-y +=color.o
14lib-n +=debug.o
15lib-n +=delch.o
16lib-n +=deleteln.o
17lib-y +=getch.o
18lib-n +=getstr.o
19lib-y +=getyx.o
20lib-y +=inch.o
21lib-n +=inchstr.o
22lib-y +=initscr.o
23lib-y +=inopts.o
24lib-n +=insch.o
25lib-n +=insstr.o
26lib-n +=instr.o
27lib-y +=kernel.o
28lib-n +=keyname.o
29lib-n +=mouse.o
30lib-y +=move.o
31lib-y +=outopts.o
32lib-y +=overlay.o
33lib-y +=pad.o
34lib-n +=panel.o
35lib-y +=pdcclip.o
36lib-y +=pdcdisp.o
37lib-y +=pdcgetsc.o
38lib-y +=pdckbd.o
39lib-y +=pdcscrn.o
40lib-y +=pdcsetsc.o
41lib-y +=pdcutil.o
42lib-y +=printw.o
43lib-y +=refresh.o
44lib-n +=scanw.o
45lib-n +=scr_dump.o
46lib-y +=scroll.o
47lib-y +=slk.o
48lib-n +=termattr.o
49lib-y +=touch.o
50lib-n +=util.o
51lib-y +=window.o
diff --git a/scripts/kconfig/libcurses/README.md b/scripts/kconfig/libcurses/README.md
new file mode 100644
index 000000000..97ad342fe
--- /dev/null
+++ b/scripts/kconfig/libcurses/README.md
@@ -0,0 +1,20 @@
1PDCurses for Windows console
2============================
3
4This directory contains PDCurses source code files specific to the
5Microsoft Windows console. Although historically called "Win32", this
6port can just as easily be built for 64-bit systems. Windows 95 through
7Windows 10 are covered. (Some features require later versions.)
8
9
10Distribution Status
11-------------------
12
13The files in this directory are released to the public domain.
14
15
16Acknowledgements
17----------------
18
19Windows console port was originally provided by Chris Szurgot
20<szurgot@itribe.net>
diff --git a/scripts/kconfig/libcurses/acs437.h b/scripts/kconfig/libcurses/acs437.h
new file mode 100644
index 000000000..24cbd7854
--- /dev/null
+++ b/scripts/kconfig/libcurses/acs437.h
@@ -0,0 +1,35 @@
1/* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
2 match code page 437 and compatible pages (CP850, CP852, etc.) */
3
4chtype acs_map[128] =
5{
6 PDC_ACS(0), PDC_ACS(1), PDC_ACS(2), PDC_ACS(3), PDC_ACS(4),
7 PDC_ACS(5), PDC_ACS(6), PDC_ACS(7), PDC_ACS(8), PDC_ACS(9),
8 PDC_ACS(10), PDC_ACS(11), PDC_ACS(12), PDC_ACS(13), PDC_ACS(14),
9 PDC_ACS(15), PDC_ACS(16), PDC_ACS(17), PDC_ACS(18), PDC_ACS(19),
10 PDC_ACS(20), PDC_ACS(21), PDC_ACS(22), PDC_ACS(23), PDC_ACS(24),
11 PDC_ACS(25), PDC_ACS(26), PDC_ACS(27), PDC_ACS(28), PDC_ACS(29),
12 PDC_ACS(30), PDC_ACS(31), ' ', '!', '"', '#', '$', '%', '&', '\'',
13 '(', ')', '*',
14
15 PDC_ACS(0x1a), PDC_ACS(0x1b), PDC_ACS(0x18), PDC_ACS(0x19),
16
17 '/',
18
19 0xdb,
20
21 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
22 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
23 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
24 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
25
26 PDC_ACS(0x04), 0xb1,
27
28 'b', 'c', 'd', 'e',
29
30 0xf8, 0xf1, 0xb0, PDC_ACS(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
31 0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2,
32 0xe3, 0xd8, 0x9c, 0xf9,
33
34 PDC_ACS(127)
35};
diff --git a/scripts/kconfig/libcurses/acsuni.h b/scripts/kconfig/libcurses/acsuni.h
new file mode 100644
index 000000000..2fdad8a1c
--- /dev/null
+++ b/scripts/kconfig/libcurses/acsuni.h
@@ -0,0 +1,35 @@
1/* ACS Unicode mapping */
2
3chtype acs_map[128] =
4{
5 PDC_ACS(0), PDC_ACS(1), PDC_ACS(2), PDC_ACS(3), PDC_ACS(4),
6 PDC_ACS(5), PDC_ACS(6), PDC_ACS(7), PDC_ACS(8), PDC_ACS(9),
7 PDC_ACS(10), PDC_ACS(11), PDC_ACS(12), PDC_ACS(13), PDC_ACS(14),
8 PDC_ACS(15), PDC_ACS(16), PDC_ACS(17), PDC_ACS(18), PDC_ACS(19),
9 PDC_ACS(20), PDC_ACS(21), PDC_ACS(22), PDC_ACS(23), PDC_ACS(24),
10 PDC_ACS(25), PDC_ACS(26), PDC_ACS(27), PDC_ACS(28), PDC_ACS(29),
11 PDC_ACS(30), PDC_ACS(31), ' ', '!', '"', '#', '$', '%', '&', '\'',
12 '(', ')', '*',
13
14 0x2192, 0x2190, 0x2191, 0x2193,
15
16 '/',
17
18 0x2588,
19
20 '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
21 '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
22 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
23 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
24
25 0x2666, 0x2592,
26
27 'b', 'c', 'd', 'e',
28
29 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
30 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
31 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
32 0x00b7,
33
34 PDC_ACS(127)
35};
diff --git a/scripts/kconfig/libcurses/addch.c b/scripts/kconfig/libcurses/addch.c
new file mode 100644
index 000000000..f3c25d389
--- /dev/null
+++ b/scripts/kconfig/libcurses/addch.c
@@ -0,0 +1,408 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7addch
8-----
9
10### Synopsis
11
12 int addch(const chtype ch);
13 int waddch(WINDOW *win, const chtype ch);
14 int mvaddch(int y, int x, const chtype ch);
15 int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
16 int echochar(const chtype ch);
17 int wechochar(WINDOW *win, const chtype ch);
18
19 int addrawch(chtype ch);
20 int waddrawch(WINDOW *win, chtype ch);
21 int mvaddrawch(int y, int x, chtype ch);
22 int mvwaddrawch(WINDOW *win, int y, int x, chtype ch);
23
24 int add_wch(const cchar_t *wch);
25 int wadd_wch(WINDOW *win, const cchar_t *wch);
26 int mvadd_wch(int y, int x, const cchar_t *wch);
27 int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch);
28 int echo_wchar(const cchar_t *wch);
29 int wecho_wchar(WINDOW *win, const cchar_t *wch);
30
31### Description
32
33 addch() adds the chtype ch to the default window (stdscr) at the
34 current cursor position, and advances the cursor. Note that chtypes
35 can convey both text (a single character) and attributes, including a
36 color pair. add_wch() is the wide-character version of this function,
37 taking a pointer to a cchar_t instead of a chtype.
38
39 waddch() is like addch(), but also lets you specify the window. (This
40 is in fact the core output routine.) wadd_wch() is the wide version.
41
42 mvaddch() moves the cursor to the specified (y, x) position, and adds
43 ch to stdscr. mvadd_wch() is the wide version.
44
45 mvwaddch() moves the cursor to the specified position and adds ch to
46 the specified window. mvwadd_wch() is the wide version.
47
48 echochar() adds ch to stdscr at the current cursor position and calls
49 refresh(). echo_wchar() is the wide version.
50
51 wechochar() adds ch to the specified window and calls wrefresh().
52 wecho_wchar() is the wide version.
53
54 addrawch(), waddrawch(), mvaddrawch() and mvwaddrawch() are PDCurses-
55 specific wrappers for addch() etc. that disable the translation of
56 control characters.
57
58 The following applies to all these functions:
59
60 If the cursor moves on to the right margin, an automatic newline is
61 performed. If scrollok is enabled, and a character is added to the
62 bottom right corner of the window, the scrolling region will be
63 scrolled up one line. If scrolling is not allowed, ERR will be
64 returned.
65
66 If ch is a tab, newline, or backspace, the cursor will be moved
67 appropriately within the window. If ch is a newline, the clrtoeol
68 routine is called before the cursor is moved to the beginning of the
69 next line. If newline mapping is off, the cursor will be moved to
70 the next line, but the x coordinate will be unchanged. If ch is a
71 tab the cursor is moved to the next tab position within the window.
72 If ch is another control character, it will be drawn in the ^X
73 notation. Calling the inch() routine after adding a control
74 character returns the representation of the control character, not
75 the control character.
76
77 Video attributes can be combined with a character by ORing them into
78 the parameter. Text, including attributes, can be copied from one
79 place to another by using inch() and addch().
80
81 Note that in PDCurses, for now, a cchar_t and a chtype are the same.
82 The text field is 16 bits wide, and is treated as Unicode (UCS-2)
83 when PDCurses is built with wide-character support (define PDC_WIDE).
84 So, in functions that take a chtype, like addch(), both the wide and
85 narrow versions will handle Unicode. But for portability, you should
86 use the wide functions.
87
88### Return Value
89
90 All functions return OK on success and ERR on error.
91
92### Portability
93 X/Open ncurses NetBSD
94 addch Y Y Y
95 waddch Y Y Y
96 mvaddch Y Y Y
97 mvwaddch Y Y Y
98 echochar Y Y Y
99 wechochar Y Y Y
100 add_wch Y Y Y
101 wadd_wch Y Y Y
102 mvadd_wch Y Y Y
103 mvwadd_wch Y Y Y
104 echo_wchar Y Y Y
105 wecho_wchar Y Y Y
106 addrawch - - -
107 waddrawch - - -
108 mvaddrawch - - -
109 mvwaddrawch - - -
110
111**man-end****************************************************************/
112
113int waddch(WINDOW *win, const chtype ch)
114{
115 int x, y;
116 chtype text, attr;
117 bool xlat;
118
119 PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
120 win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
121
122 if (!win || !SP)
123 return ERR;
124
125 x = win->_curx;
126 y = win->_cury;
127
128 if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
129 return ERR;
130
131 xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
132 text = ch & A_CHARTEXT;
133 attr = ch & A_ATTRIBUTES;
134
135 if (xlat && (text < ' ' || text == 0x7f))
136 {
137 int x2;
138
139 switch (text)
140 {
141 case '\t':
142 for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
143 {
144 if (waddch(win, attr | ' ') == ERR)
145 return ERR;
146
147 /* if tab to next line, exit the loop */
148
149 if (!win->_curx)
150 break;
151 }
152 return OK;
153
154 case '\n':
155 /* if lf -> crlf */
156
157 if (!SP->raw_out)
158 x = 0;
159
160 wclrtoeol(win);
161
162 if (++y > win->_bmarg)
163 {
164 y--;
165
166 if (wscrl(win, 1) == ERR)
167 return ERR;
168 }
169
170 break;
171
172 case '\b':
173 /* don't back over left margin */
174
175 if (--x < 0)
176 case '\r':
177 x = 0;
178
179 break;
180
181 case 0x7f:
182 if (waddch(win, attr | '^') == ERR)
183 return ERR;
184
185 return waddch(win, attr | '?');
186
187 default:
188 /* handle control chars */
189
190 if (waddch(win, attr | '^') == ERR)
191 return ERR;
192
193 return waddch(win, ch + '@');
194 }
195 }
196 else
197 {
198 /* If the incoming character doesn't have its own attribute,
199 then use the current attributes for the window. If it has
200 attributes but not a color component, OR the attributes to
201 the current attributes for the window. If it has a color
202 component, use the attributes solely from the incoming
203 character. */
204
205 if (!(attr & A_COLOR))
206 attr |= win->_attrs;
207
208 /* wrs (4/10/93): Apply the same sort of logic for the window
209 background, in that it only takes precedence if other color
210 attributes are not there and that the background character
211 will only print if the printing character is blank. */
212
213 if (!(attr & A_COLOR))
214 attr |= win->_bkgd & A_ATTRIBUTES;
215 else
216 attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
217
218 if (text == ' ')
219 text = win->_bkgd & A_CHARTEXT;
220
221 /* Add the attribute back into the character. */
222
223 text |= attr;
224
225 /* Only change _firstch/_lastch if the character to be added is
226 different from the character/attribute that is already in
227 that position in the window. */
228
229 if (win->_y[y][x] != text)
230 {
231 if (win->_firstch[y] == _NO_CHANGE)
232 win->_firstch[y] = win->_lastch[y] = x;
233 else
234 if (x < win->_firstch[y])
235 win->_firstch[y] = x;
236 else
237 if (x > win->_lastch[y])
238 win->_lastch[y] = x;
239
240 win->_y[y][x] = text;
241 }
242
243 if (++x >= win->_maxx)
244 {
245 /* wrap around test */
246
247 x = 0;
248
249 if (++y > win->_bmarg)
250 {
251 y--;
252
253 if (wscrl(win, 1) == ERR)
254 {
255 PDC_sync(win);
256 return ERR;
257 }
258 }
259 }
260 }
261
262 win->_curx = x;
263 win->_cury = y;
264
265 if (win->_immed)
266 wrefresh(win);
267 if (win->_sync)
268 wsyncup(win);
269
270 return OK;
271}
272
273int addch(const chtype ch)
274{
275 PDC_LOG(("addch() - called: ch=%x\n", ch));
276
277 return waddch(stdscr, ch);
278}
279
280int mvaddch(int y, int x, const chtype ch)
281{
282 PDC_LOG(("mvaddch() - called: y=%d x=%d ch=%x\n", y, x, ch));
283
284 if (move(y,x) == ERR)
285 return ERR;
286
287 return waddch(stdscr, ch);
288}
289
290int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
291{
292 PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch));
293
294 if (wmove(win, y, x) == ERR)
295 return ERR;
296
297 return waddch(win, ch);
298}
299
300int echochar(const chtype ch)
301{
302 PDC_LOG(("echochar() - called: ch=%x\n", ch));
303
304 return wechochar(stdscr, ch);
305}
306
307int wechochar(WINDOW *win, const chtype ch)
308{
309 PDC_LOG(("wechochar() - called: win=%p ch=%x\n", win, ch));
310
311 if (waddch(win, ch) == ERR)
312 return ERR;
313
314 return wrefresh(win);
315}
316
317int waddrawch(WINDOW *win, chtype ch)
318{
319 PDC_LOG(("waddrawch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
320 win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
321
322 if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
323 ch |= A_ALTCHARSET;
324
325 return waddch(win, ch);
326}
327
328int addrawch(chtype ch)
329{
330 PDC_LOG(("addrawch() - called: ch=%x\n", ch));
331
332 return waddrawch(stdscr, ch);
333}
334
335int mvaddrawch(int y, int x, chtype ch)
336{
337 PDC_LOG(("mvaddrawch() - called: y=%d x=%d ch=%d\n", y, x, ch));
338
339 if (move(y, x) == ERR)
340 return ERR;
341
342 return waddrawch(stdscr, ch);
343}
344
345int mvwaddrawch(WINDOW *win, int y, int x, chtype ch)
346{
347 PDC_LOG(("mvwaddrawch() - called: win=%p y=%d x=%d ch=%d\n",
348 win, y, x, ch));
349
350 if (wmove(win, y, x) == ERR)
351 return ERR;
352
353 return waddrawch(win, ch);
354}
355
356#ifdef PDC_WIDE
357int wadd_wch(WINDOW *win, const cchar_t *wch)
358{
359 PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch));
360
361 return wch ? waddch(win, *wch) : ERR;
362}
363
364int add_wch(const cchar_t *wch)
365{
366 PDC_LOG(("add_wch() - called: wch=%x\n", *wch));
367
368 return wadd_wch(stdscr, wch);
369}
370
371int mvadd_wch(int y, int x, const cchar_t *wch)
372{
373 PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch));
374
375 if (move(y,x) == ERR)
376 return ERR;
377
378 return wadd_wch(stdscr, wch);
379}
380
381int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch)
382{
383 PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n",
384 win, y, x, *wch));
385
386 if (wmove(win, y, x) == ERR)
387 return ERR;
388
389 return wadd_wch(win, wch);
390}
391
392int echo_wchar(const cchar_t *wch)
393{
394 PDC_LOG(("echo_wchar() - called: wch=%x\n", *wch));
395
396 return wecho_wchar(stdscr, wch);
397}
398
399int wecho_wchar(WINDOW *win, const cchar_t *wch)
400{
401 PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch));
402
403 if (!wch || (wadd_wch(win, wch) == ERR))
404 return ERR;
405
406 return wrefresh(win);
407}
408#endif
diff --git a/scripts/kconfig/libcurses/addstr.c b/scripts/kconfig/libcurses/addstr.c
new file mode 100644
index 000000000..47f8f4e10
--- /dev/null
+++ b/scripts/kconfig/libcurses/addstr.c
@@ -0,0 +1,239 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7addstr
8------
9
10### Synopsis
11
12 int addstr(const char *str);
13 int addnstr(const char *str, int n);
14 int waddstr(WINDOW *win, const char *str);
15 int waddnstr(WINDOW *win, const char *str, int n);
16 int mvaddstr(int y, int x, const char *str);
17 int mvaddnstr(int y, int x, const char *str, int n);
18 int mvwaddstr(WINDOW *win, int y, int x, const char *str);
19 int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
20
21 int addwstr(const wchar_t *wstr);
22 int addnwstr(const wchar_t *wstr, int n);
23 int waddwstr(WINDOW *win, const wchar_t *wstr);
24 int waddnwstr(WINDOW *win, const wchar_t *wstr, int n);
25 int mvaddwstr(int y, int x, const wchar_t *wstr);
26 int mvaddnwstr(int y, int x, const wchar_t *wstr, int n);
27 int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr);
28 int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
29
30### Description
31
32 These routines write all the characters of the null-terminated string
33 str or wide-character string wstr to the given window. The
34 functionality is similar to calling waddch() once for each character
35 in the string; except that, when PDCurses is built with wide-
36 character support enabled, the narrow-character functions treat the
37 string as a multibyte string in the current locale, and convert it.
38 The routines with n as the last argument write at most n characters;
39 if n is negative, then the entire string will be added.
40
41### Return Value
42
43 All functions return OK or ERR.
44
45### Portability
46 X/Open ncurses NetBSD
47 addstr Y Y Y
48 waddstr Y Y Y
49 mvaddstr Y Y Y
50 mvwaddstr Y Y Y
51 addnstr Y Y Y
52 waddnstr Y Y Y
53 mvaddnstr Y Y Y
54 mvwaddnstr Y Y Y
55 addwstr Y Y Y
56 waddwstr Y Y Y
57 mvaddwstr Y Y Y
58 mvwaddwstr Y Y Y
59 addnwstr Y Y Y
60 waddnwstr Y Y Y
61 mvaddnwstr Y Y Y
62 mvwaddnwstr Y Y Y
63
64**man-end****************************************************************/
65
66int waddnstr(WINDOW *win, const char *str, int n)
67{
68 int i = 0;
69
70 PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n));
71
72 if (!win || !str)
73 return ERR;
74
75 while (str[i] && (i < n || n < 0))
76 {
77#ifdef PDC_WIDE
78 wchar_t wch;
79 int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6);
80
81 if (retval <= 0)
82 return OK;
83
84 i += retval;
85#else
86 chtype wch = (unsigned char)(str[i++]);
87#endif
88 if (waddch(win, wch) == ERR)
89 return ERR;
90 }
91
92 return OK;
93}
94
95int addstr(const char *str)
96{
97 PDC_LOG(("addstr() - called: string=\"%s\"\n", str));
98
99 return waddnstr(stdscr, str, -1);
100}
101
102int addnstr(const char *str, int n)
103{
104 PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n));
105
106 return waddnstr(stdscr, str, n);
107}
108
109int waddstr(WINDOW *win, const char *str)
110{
111 PDC_LOG(("waddstr() - called: string=\"%s\"\n", str));
112
113 return waddnstr(win, str, -1);
114}
115
116int mvaddstr(int y, int x, const char *str)
117{
118 PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
119
120 if (move(y, x) == ERR)
121 return ERR;
122
123 return waddnstr(stdscr, str, -1);
124}
125
126int mvaddnstr(int y, int x, const char *str, int n)
127{
128 PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
129 y, x, str, n));
130
131 if (move(y, x) == ERR)
132 return ERR;
133
134 return waddnstr(stdscr, str, n);
135}
136
137int mvwaddstr(WINDOW *win, int y, int x, const char *str)
138{
139 PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str));
140
141 if (wmove(win, y, x) == ERR)
142 return ERR;
143
144 return waddnstr(win, str, -1);
145}
146
147int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
148{
149 PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
150 y, x, str, n));
151
152 if (wmove(win, y, x) == ERR)
153 return ERR;
154
155 return waddnstr(win, str, n);
156}
157
158#ifdef PDC_WIDE
159int waddnwstr(WINDOW *win, const wchar_t *wstr, int n)
160{
161 int i = 0;
162
163 PDC_LOG(("waddnwstr() - called\n"));
164
165 if (!win || !wstr)
166 return ERR;
167
168 while (wstr[i] && (i < n || n < 0))
169 {
170 chtype wch = wstr[i++];
171
172 if (waddch(win, wch) == ERR)
173 return ERR;
174 }
175
176 return OK;
177}
178
179int addwstr(const wchar_t *wstr)
180{
181 PDC_LOG(("addwstr() - called\n"));
182
183 return waddnwstr(stdscr, wstr, -1);
184}
185
186int addnwstr(const wchar_t *wstr, int n)
187{
188 PDC_LOG(("addnwstr() - called\n"));
189
190 return waddnwstr(stdscr, wstr, n);
191}
192
193int waddwstr(WINDOW *win, const wchar_t *wstr)
194{
195 PDC_LOG(("waddwstr() - called\n"));
196
197 return waddnwstr(win, wstr, -1);
198}
199
200int mvaddwstr(int y, int x, const wchar_t *wstr)
201{
202 PDC_LOG(("mvaddstr() - called\n"));
203
204 if (move(y, x) == ERR)
205 return ERR;
206
207 return waddnwstr(stdscr, wstr, -1);
208}
209
210int mvaddnwstr(int y, int x, const wchar_t *wstr, int n)
211{
212 PDC_LOG(("mvaddnstr() - called\n"));
213
214 if (move(y, x) == ERR)
215 return ERR;
216
217 return waddnwstr(stdscr, wstr, n);
218}
219
220int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr)
221{
222 PDC_LOG(("mvwaddstr() - called\n"));
223
224 if (wmove(win, y, x) == ERR)
225 return ERR;
226
227 return waddnwstr(win, wstr, -1);
228}
229
230int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
231{
232 PDC_LOG(("mvwaddnstr() - called\n"));
233
234 if (wmove(win, y, x) == ERR)
235 return ERR;
236
237 return waddnwstr(win, wstr, n);
238}
239#endif
diff --git a/scripts/kconfig/libcurses/attr.c b/scripts/kconfig/libcurses/attr.c
new file mode 100644
index 000000000..3ab5a5637
--- /dev/null
+++ b/scripts/kconfig/libcurses/attr.c
@@ -0,0 +1,409 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7attr
8----
9
10### Synopsis
11
12 int attroff(chtype attrs);
13 int wattroff(WINDOW *win, chtype attrs);
14 int attron(chtype attrs);
15 int wattron(WINDOW *win, chtype attrs);
16 int attrset(chtype attrs);
17 int wattrset(WINDOW *win, chtype attrs);
18 int standend(void);
19 int wstandend(WINDOW *win);
20 int standout(void);
21 int wstandout(WINDOW *win);
22
23 int color_set(short color_pair, void *opts);
24 int wcolor_set(WINDOW *win, short color_pair, void *opts);
25
26 int attr_get(attr_t *attrs, short *color_pair, void *opts);
27 int attr_off(attr_t attrs, void *opts);
28 int attr_on(attr_t attrs, void *opts);
29 int attr_set(attr_t attrs, short color_pair, void *opts);
30 int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair,
31 void *opts);
32 int wattr_off(WINDOW *win, attr_t attrs, void *opts);
33 int wattr_on(WINDOW *win, attr_t attrs, void *opts);
34 int wattr_set(WINDOW *win, attr_t attrs, short color_pair,
35 void *opts);
36
37 int chgat(int n, attr_t attr, short color, const void *opts);
38 int mvchgat(int y, int x, int n, attr_t attr, short color,
39 const void *opts);
40 int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr,
41 short color, const void *opts);
42 int wchgat(WINDOW *win, int n, attr_t attr, short color,
43 const void *opts);
44
45 chtype getattrs(WINDOW *win);
46
47 int underend(void);
48 int wunderend(WINDOW *win);
49 int underscore(void);
50 int wunderscore(WINDOW *win);
51
52### Description
53
54 These functions manipulate the current attributes and/or colors of
55 the named window. These attributes can be any combination of
56 A_STANDOUT, A_REVERSE, A_BOLD, A_DIM, A_BLINK, A_UNDERLINE. These
57 constants are defined in "curses.h" and can be combined with the
58 bitwise-OR operator (|).
59
60 The current attributes of a window are applied to all chtypes that
61 are written into the window with waddch(). Attributes are a property
62 of the chtype, and move with the character through any scrolling or
63 insert/delete operations.
64
65 wattrset() sets the current attributes of the given window to attrs.
66 attrset() is the stdscr version.
67
68 wattroff() turns off the named attributes without affecting any other
69 attributes; wattron() turns them on.
70
71 wcolor_set() sets the window color to the value of color_pair. opts
72 is unused.
73
74 standout() is the same as attron(A_STANDOUT). standend() is the same
75 as attrset(A_NORMAL); that is, it turns off all attributes.
76
77 The attr_* and wattr_* functions are intended for use with the WA_*
78 attributes. In PDCurses, these are the same as A_*, and there is no
79 difference in bevahior from the chtype-based functions. In all cases,
80 opts is unused.
81
82 wattr_get() retrieves the attributes and color pair for the specified
83 window.
84
85 wchgat() sets the color pair and attributes for the next n cells on
86 the current line of a given window, without changing the existing
87 text, or alterting the window's attributes. An n of -1 extends the
88 change to the edge of the window. The changes take effect
89 immediately. opts is unused.
90
91 wunderscore() turns on the A_UNDERLINE attribute; wunderend() turns
92 it off. underscore() and underend() are the stdscr versions.
93
94### Return Value
95
96 All functions return OK on success and ERR on error.
97
98### Portability
99 X/Open ncurses NetBSD
100 attroff Y Y Y
101 wattroff Y Y Y
102 attron Y Y Y
103 wattron Y Y Y
104 attrset Y Y Y
105 wattrset Y Y Y
106 standend Y Y Y
107 wstandend Y Y Y
108 standout Y Y Y
109 wstandout Y Y Y
110 color_set Y Y Y
111 wcolor_set Y Y Y
112 attr_get Y Y Y
113 wattr_get Y Y Y
114 attr_on Y Y Y
115 wattr_on Y Y Y
116 attr_off Y Y Y
117 wattr_off Y Y Y
118 attr_set Y Y Y
119 wattr_set Y Y Y
120 chgat Y Y Y
121 wchgat Y Y Y
122 mvchgat Y Y Y
123 mvwchgat Y Y Y
124 getattrs - Y Y
125 underend - - Y
126 wunderend - - Y
127 underscore - - Y
128 wunderscore - - Y
129
130**man-end****************************************************************/
131
132int wattroff(WINDOW *win, chtype attrs)
133{
134 PDC_LOG(("wattroff() - called\n"));
135
136 if (!win)
137 return ERR;
138
139 win->_attrs &= (~attrs & A_ATTRIBUTES);
140
141 return OK;
142}
143
144int attroff(chtype attrs)
145{
146 PDC_LOG(("attroff() - called\n"));
147
148 return wattroff(stdscr, attrs);
149}
150
151int wattron(WINDOW *win, chtype attrs)
152{
153 chtype newcolr, oldcolr, newattr, oldattr;
154
155 PDC_LOG(("wattron() - called\n"));
156
157 if (!win)
158 return ERR;
159
160 if ((win->_attrs & A_COLOR) && (attrs & A_COLOR))
161 {
162 oldcolr = win->_attrs & A_COLOR;
163 oldattr = win->_attrs ^ oldcolr;
164 newcolr = attrs & A_COLOR;
165 newattr = (attrs & A_ATTRIBUTES) ^ newcolr;
166 newattr |= oldattr;
167 win->_attrs = newattr | newcolr;
168 }
169 else
170 win->_attrs |= (attrs & A_ATTRIBUTES);
171
172 return OK;
173}
174
175int attron(chtype attrs)
176{
177 PDC_LOG(("attron() - called\n"));
178
179 return wattron(stdscr, attrs);
180}
181
182int wattrset(WINDOW *win, chtype attrs)
183{
184 PDC_LOG(("wattrset() - called\n"));
185
186 if (!win)
187 return ERR;
188
189 win->_attrs = attrs & A_ATTRIBUTES;
190
191 return OK;
192}
193
194int attrset(chtype attrs)
195{
196 PDC_LOG(("attrset() - called\n"));
197
198 return wattrset(stdscr, attrs);
199}
200
201int standend(void)
202{
203 PDC_LOG(("standend() - called\n"));
204
205 return wattrset(stdscr, A_NORMAL);
206}
207
208int standout(void)
209{
210 PDC_LOG(("standout() - called\n"));
211
212 return wattrset(stdscr, A_STANDOUT);
213}
214
215int wstandend(WINDOW *win)
216{
217 PDC_LOG(("wstandend() - called\n"));
218
219 return wattrset(win, A_NORMAL);
220}
221
222int wstandout(WINDOW *win)
223{
224 PDC_LOG(("wstandout() - called\n"));
225
226 return wattrset(win, A_STANDOUT);
227}
228
229chtype getattrs(WINDOW *win)
230{
231 return win ? win->_attrs : 0;
232}
233
234int wcolor_set(WINDOW *win, short color_pair, void *opts)
235{
236 PDC_LOG(("wcolor_set() - called\n"));
237
238 if (!win)
239 return ERR;
240
241 win->_attrs = (win->_attrs & ~A_COLOR) | COLOR_PAIR(color_pair);
242
243 return OK;
244}
245
246int color_set(short color_pair, void *opts)
247{
248 PDC_LOG(("color_set() - called\n"));
249
250 return wcolor_set(stdscr, color_pair, opts);
251}
252
253int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts)
254{
255 PDC_LOG(("wattr_get() - called\n"));
256
257 if (!win)
258 return ERR;
259
260 if (attrs)
261 *attrs = win->_attrs & (A_ATTRIBUTES & ~A_COLOR);
262
263 if (color_pair)
264 *color_pair = PAIR_NUMBER(win->_attrs);
265
266 return OK;
267}
268
269int attr_get(attr_t *attrs, short *color_pair, void *opts)
270{
271 PDC_LOG(("attr_get() - called\n"));
272
273 return wattr_get(stdscr, attrs, color_pair, opts);
274}
275
276int wattr_off(WINDOW *win, attr_t attrs, void *opts)
277{
278 PDC_LOG(("wattr_off() - called\n"));
279
280 return wattroff(win, attrs);
281}
282
283int attr_off(attr_t attrs, void *opts)
284{
285 PDC_LOG(("attr_off() - called\n"));
286
287 return wattroff(stdscr, attrs);
288}
289
290int wattr_on(WINDOW *win, attr_t attrs, void *opts)
291{
292 PDC_LOG(("wattr_off() - called\n"));
293
294 return wattron(win, attrs);
295}
296
297int attr_on(attr_t attrs, void *opts)
298{
299 PDC_LOG(("attr_on() - called\n"));
300
301 return wattron(stdscr, attrs);
302}
303
304int wattr_set(WINDOW *win, attr_t attrs, short color_pair, void *opts)
305{
306 PDC_LOG(("wattr_set() - called\n"));
307
308 if (!win)
309 return ERR;
310
311 win->_attrs = (attrs & (A_ATTRIBUTES & ~A_COLOR)) | COLOR_PAIR(color_pair);
312
313 return OK;
314}
315
316int attr_set(attr_t attrs, short color_pair, void *opts)
317{
318 PDC_LOG(("attr_get() - called\n"));
319
320 return wattr_set(stdscr, attrs, color_pair, opts);
321}
322
323int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
324{
325 chtype *dest, newattr;
326 int startpos, endpos;
327
328 PDC_LOG(("wchgat() - called\n"));
329
330 if (!win)
331 return ERR;
332
333 newattr = (attr & A_ATTRIBUTES) | COLOR_PAIR(color);
334
335 startpos = win->_curx;
336 endpos = ((n < 0) ? win->_maxx : min(startpos + n, win->_maxx)) - 1;
337 dest = win->_y[win->_cury];
338
339 for (n = startpos; n <= endpos; n++)
340 dest[n] = (dest[n] & A_CHARTEXT) | newattr;
341
342 n = win->_cury;
343
344 if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
345 win->_firstch[n] = startpos;
346
347 if (endpos > win->_lastch[n])
348 win->_lastch[n] = endpos;
349
350 PDC_sync(win);
351
352 return OK;
353}
354
355int chgat(int n, attr_t attr, short color, const void *opts)
356{
357 PDC_LOG(("chgat() - called\n"));
358
359 return wchgat(stdscr, n, attr, color, opts);
360}
361
362int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
363{
364 PDC_LOG(("mvchgat() - called\n"));
365
366 if (move(y, x) == ERR)
367 return ERR;
368
369 return wchgat(stdscr, n, attr, color, opts);
370}
371
372int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr, short color,
373 const void *opts)
374{
375 PDC_LOG(("mvwchgat() - called\n"));
376
377 if (wmove(win, y, x) == ERR)
378 return ERR;
379
380 return wchgat(win, n, attr, color, opts);
381}
382
383int underend(void)
384{
385 PDC_LOG(("underend() - called\n"));
386
387 return wattroff(stdscr, A_UNDERLINE);
388}
389
390int wunderend(WINDOW *win)
391{
392 PDC_LOG(("wunderend() - called\n"));
393
394 return wattroff(win, A_UNDERLINE);
395}
396
397int underscore(void)
398{
399 PDC_LOG(("underscore() - called\n"));
400
401 return wattron(stdscr, A_UNDERLINE);
402}
403
404int wunderscore(WINDOW *win)
405{
406 PDC_LOG(("wunderscore() - called\n"));
407
408 return wattron(win, A_UNDERLINE);
409}
diff --git a/scripts/kconfig/libcurses/beep.c b/scripts/kconfig/libcurses/beep.c
new file mode 100644
index 000000000..0b97137fd
--- /dev/null
+++ b/scripts/kconfig/libcurses/beep.c
@@ -0,0 +1,74 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7beep
8----
9
10### Synopsis
11
12 int beep(void);
13 int flash(void);
14
15### Description
16
17 beep() sounds the audible bell on the terminal, if possible; if not,
18 it calls flash().
19
20 flash() "flashes" the screen, by inverting the foreground and
21 background of every cell, pausing, and then restoring the original
22 attributes.
23
24### Return Value
25
26 These functions return ERR if called before initscr(), otherwise OK.
27
28### Portability
29 X/Open ncurses NetBSD
30 beep Y Y Y
31 flash Y Y Y
32
33**man-end****************************************************************/
34
35int beep(void)
36{
37 PDC_LOG(("beep() - called\n"));
38
39 if (!SP)
40 return ERR;
41
42 if (SP->audible)
43 PDC_beep();
44 else
45 flash();
46
47 return OK;
48}
49
50int flash(void)
51{
52 int z, y, x;
53
54 PDC_LOG(("flash() - called\n"));
55
56 if (!curscr)
57 return ERR;
58
59 /* Reverse each cell; wait; restore the screen */
60
61 for (z = 0; z < 2; z++)
62 {
63 for (y = 0; y < LINES; y++)
64 for (x = 0; x < COLS; x++)
65 curscr->_y[y][x] ^= A_REVERSE;
66
67 wrefresh(curscr);
68
69 if (!z)
70 napms(50);
71 }
72
73 return OK;
74}
diff --git a/scripts/kconfig/libcurses/bkgd.c b/scripts/kconfig/libcurses/bkgd.c
new file mode 100644
index 000000000..af2d0e054
--- /dev/null
+++ b/scripts/kconfig/libcurses/bkgd.c
@@ -0,0 +1,226 @@
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 X/Open ncurses NetBSD
52 bkgd Y Y Y
53 bkgdset Y Y Y
54 getbkgd Y Y Y
55 wbkgd Y Y Y
56 wbkgdset Y Y Y
57 bkgrnd Y Y Y
58 bkgrndset Y Y Y
59 getbkgrnd Y Y Y
60 wbkgrnd Y Y Y
61 wbkgrndset Y Y Y
62 wgetbkgrnd Y Y Y
63
64**man-end****************************************************************/
65
66int wbkgd(WINDOW *win, chtype ch)
67{
68 int x, y;
69 chtype oldcolr, oldch, newcolr, newch, colr, attr;
70 chtype oldattr = 0, newattr = 0;
71 chtype *winptr;
72
73 PDC_LOG(("wbkgd() - called\n"));
74
75 if (!win)
76 return ERR;
77
78 if (win->_bkgd == ch)
79 return OK;
80
81 oldcolr = win->_bkgd & A_COLOR;
82 if (oldcolr)
83 oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
84
85 oldch = win->_bkgd & A_CHARTEXT;
86
87 wbkgdset(win, ch);
88
89 newcolr = win->_bkgd & A_COLOR;
90 if (newcolr)
91 newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
92
93 newch = win->_bkgd & A_CHARTEXT;
94
95 /* what follows is what seems to occur in the System V
96 implementation of this routine */
97
98 for (y = 0; y < win->_maxy; y++)
99 {
100 for (x = 0; x < win->_maxx; x++)
101 {
102 winptr = win->_y[y] + x;
103
104 ch = *winptr;
105
106 /* determine the colors and attributes of the character read
107 from the window */
108
109 colr = ch & A_COLOR;
110 attr = ch & (A_ATTRIBUTES ^ A_COLOR);
111
112 /* if the color is the same as the old background color,
113 then make it the new background color, otherwise leave it */
114
115 if (colr == oldcolr)
116 colr = newcolr;
117
118 /* remove any attributes (non color) from the character that
119 were part of the old background, then combine the
120 remaining ones with the new background */
121
122 attr ^= oldattr;
123 attr |= newattr;
124
125 /* change character if it is there because it was the old
126 background character */
127
128 ch &= A_CHARTEXT;
129 if (ch == oldch)
130 ch = newch;
131
132 ch |= (attr | colr);
133
134 *winptr = ch;
135
136 }
137 }
138
139 touchwin(win);
140 PDC_sync(win);
141 return OK;
142}
143
144int bkgd(chtype ch)
145{
146 PDC_LOG(("bkgd() - called\n"));
147
148 return wbkgd(stdscr, ch);
149}
150
151void wbkgdset(WINDOW *win, chtype ch)
152{
153 PDC_LOG(("wbkgdset() - called\n"));
154
155 if (win)
156 {
157 if (!(ch & A_CHARTEXT))
158 ch |= ' ';
159
160 win->_bkgd = ch;
161 }
162}
163
164void bkgdset(chtype ch)
165{
166 PDC_LOG(("bkgdset() - called\n"));
167
168 wbkgdset(stdscr, ch);
169}
170
171chtype getbkgd(WINDOW *win)
172{
173 PDC_LOG(("getbkgd() - called\n"));
174
175 return win ? win->_bkgd : (chtype)ERR;
176}
177
178#ifdef PDC_WIDE
179int wbkgrnd(WINDOW *win, const cchar_t *wch)
180{
181 PDC_LOG(("wbkgrnd() - called\n"));
182
183 return wch ? wbkgd(win, *wch) : ERR;
184}
185
186int bkgrnd(const cchar_t *wch)
187{
188 PDC_LOG(("bkgrnd() - called\n"));
189
190 return wbkgrnd(stdscr, wch);
191}
192
193void wbkgrndset(WINDOW *win, const cchar_t *wch)
194{
195 PDC_LOG(("wbkgdset() - called\n"));
196
197 if (wch)
198 wbkgdset(win, *wch);
199}
200
201void bkgrndset(const cchar_t *wch)
202{
203 PDC_LOG(("bkgrndset() - called\n"));
204
205 wbkgrndset(stdscr, wch);
206}
207
208int wgetbkgrnd(WINDOW *win, cchar_t *wch)
209{
210 PDC_LOG(("wgetbkgrnd() - called\n"));
211
212 if (!win || !wch)
213 return ERR;
214
215 *wch = win->_bkgd;
216
217 return OK;
218}
219
220int getbkgrnd(cchar_t *wch)
221{
222 PDC_LOG(("getbkgrnd() - called\n"));
223
224 return wgetbkgrnd(stdscr, wch);
225}
226#endif
diff --git a/scripts/kconfig/libcurses/border.c b/scripts/kconfig/libcurses/border.c
new file mode 100644
index 000000000..302c46ea2
--- /dev/null
+++ b/scripts/kconfig/libcurses/border.c
@@ -0,0 +1,414 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7border
8------
9
10### Synopsis
11
12 int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
13 chtype tr, chtype bl, chtype br);
14 int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
15 chtype bs, chtype tl, chtype tr, chtype bl, chtype br);
16 int box(WINDOW *win, chtype verch, chtype horch);
17 int hline(chtype ch, int n);
18 int vline(chtype ch, int n);
19 int whline(WINDOW *win, chtype ch, int n);
20 int wvline(WINDOW *win, chtype ch, int n);
21 int mvhline(int y, int x, chtype ch, int n);
22 int mvvline(int y, int x, chtype ch, int n);
23 int mvwhline(WINDOW *win, int y, int x, chtype ch, int n);
24 int mvwvline(WINDOW *win, int y, int x, chtype ch, int n);
25
26 int border_set(const cchar_t *ls, const cchar_t *rs,
27 const cchar_t *ts, const cchar_t *bs,
28 const cchar_t *tl, const cchar_t *tr,
29 const cchar_t *bl, const cchar_t *br);
30 int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
31 const cchar_t *ts, const cchar_t *bs,
32 const cchar_t *tl, const cchar_t *tr,
33 const cchar_t *bl, const cchar_t *br);
34 int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch);
35 int hline_set(const cchar_t *wch, int n);
36 int vline_set(const cchar_t *wch, int n);
37 int whline_set(WINDOW *win, const cchar_t *wch, int n);
38 int wvline_set(WINDOW *win, const cchar_t *wch, int n);
39 int mvhline_set(int y, int x, const cchar_t *wch, int n);
40 int mvvline_set(int y, int x, const cchar_t *wch, int n);
41 int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
42 int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
43
44### Description
45
46 border(), wborder(), and box() draw a border around the edge of the
47 window. If any argument is zero, an appropriate default is used:
48
49 ls left side of border ACS_VLINE
50 rs right side of border ACS_VLINE
51 ts top side of border ACS_HLINE
52 bs bottom side of border ACS_HLINE
53 tl top left corner of border ACS_ULCORNER
54 tr top right corner of border ACS_URCORNER
55 bl bottom left corner of border ACS_LLCORNER
56 br bottom right corner of border ACS_LRCORNER
57
58 hline() and whline() draw a horizontal line, using ch, starting from
59 the current cursor position. The cursor position does not change. The
60 line is at most n characters long, or as many as will fit in the
61 window.
62
63 vline() and wvline() draw a vertical line, using ch, starting from
64 the current cursor position. The cursor position does not change. The
65 line is at most n characters long, or as many as will fit in the
66 window.
67
68 The *_set functions are the "wide-character" versions, taking
69 pointers to cchar_t instead of chtype. Note that in PDCurses, chtype
70 and cchar_t are the same.
71
72### Return Value
73
74 These functions return OK on success and ERR on error.
75
76### Portability
77 X/Open ncurses NetBSD
78 border Y Y Y
79 wborder Y Y Y
80 box Y Y Y
81 hline Y Y Y
82 vline Y Y Y
83 whline Y Y Y
84 wvline Y Y Y
85 mvhline Y Y Y
86 mvvline Y Y Y
87 mvwhline Y Y Y
88 mvwvline Y Y Y
89 border_set Y Y Y
90 wborder_set Y Y Y
91 box_set Y Y Y
92 hline_set Y Y Y
93 vline_set Y Y Y
94 whline_set Y Y Y
95 wvline_set Y Y Y
96 mvhline_set Y Y Y
97 mvvline_set Y Y Y
98 mvwhline_set Y Y Y
99 mvwvline_set Y Y Y
100
101**man-end****************************************************************/
102
103/* _attr_passthru() -- Takes a single chtype 'ch' and checks if the
104 current attribute of window 'win', as set by wattrset(), and/or the
105 current background of win, as set by wbkgd(), should by combined with
106 it. Attributes set explicitly in ch take precedence. */
107
108static chtype _attr_passthru(WINDOW *win, chtype ch)
109{
110 chtype attr;
111
112 /* If the incoming character doesn't have its own attribute, then
113 use the current attributes for the window. If the incoming
114 character has attributes, but not a color component, OR the
115 attributes to the current attributes for the window. If the
116 incoming character has a color component, use only the attributes
117 from the incoming character. */
118
119 attr = ch & A_ATTRIBUTES;
120 if (!(attr & A_COLOR))
121 attr |= win->_attrs;
122
123 /* wrs (4/10/93) -- Apply the same sort of logic for the window
124 background, in that it only takes precedence if other color
125 attributes are not there. */
126
127 if (!(attr & A_COLOR))
128 attr |= win->_bkgd & A_ATTRIBUTES;
129 else
130 attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
131
132 ch = (ch & A_CHARTEXT) | attr;
133
134 return ch;
135}
136
137int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
138 chtype tl, chtype tr, chtype bl, chtype br)
139{
140 int i, ymax, xmax;
141
142 PDC_LOG(("wborder() - called\n"));
143
144 if (!win)
145 return ERR;
146
147 ymax = win->_maxy - 1;
148 xmax = win->_maxx - 1;
149
150 ls = _attr_passthru(win, ls ? ls : ACS_VLINE);
151 rs = _attr_passthru(win, rs ? rs : ACS_VLINE);
152 ts = _attr_passthru(win, ts ? ts : ACS_HLINE);
153 bs = _attr_passthru(win, bs ? bs : ACS_HLINE);
154 tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER);
155 tr = _attr_passthru(win, tr ? tr : ACS_URCORNER);
156 bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER);
157 br = _attr_passthru(win, br ? br : ACS_LRCORNER);
158
159 for (i = 1; i < xmax; i++)
160 {
161 win->_y[0][i] = ts;
162 win->_y[ymax][i] = bs;
163 }
164
165 for (i = 1; i < ymax; i++)
166 {
167 win->_y[i][0] = ls;
168 win->_y[i][xmax] = rs;
169 }
170
171 win->_y[0][0] = tl;
172 win->_y[0][xmax] = tr;
173 win->_y[ymax][0] = bl;
174 win->_y[ymax][xmax] = br;
175
176 for (i = 0; i <= ymax; i++)
177 {
178 win->_firstch[i] = 0;
179 win->_lastch[i] = xmax;
180 }
181
182 PDC_sync(win);
183
184 return OK;
185}
186
187int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
188 chtype tr, chtype bl, chtype br)
189{
190 PDC_LOG(("border() - called\n"));
191
192 return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
193}
194
195int box(WINDOW *win, chtype verch, chtype horch)
196{
197 PDC_LOG(("box() - called\n"));
198
199 return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0);
200}
201
202int whline(WINDOW *win, chtype ch, int n)
203{
204 chtype *dest;
205 int startpos, endpos;
206
207 PDC_LOG(("whline() - called\n"));
208
209 if (!win || n < 1)
210 return ERR;
211
212 startpos = win->_curx;
213 endpos = min(startpos + n, win->_maxx) - 1;
214 dest = win->_y[win->_cury];
215 ch = _attr_passthru(win, ch ? ch : ACS_HLINE);
216
217 for (n = startpos; n <= endpos; n++)
218 dest[n] = ch;
219
220 n = win->_cury;
221
222 if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
223 win->_firstch[n] = startpos;
224
225 if (endpos > win->_lastch[n])
226 win->_lastch[n] = endpos;
227
228 PDC_sync(win);
229
230 return OK;
231}
232
233int hline(chtype ch, int n)
234{
235 PDC_LOG(("hline() - called\n"));
236
237 return whline(stdscr, ch, n);
238}
239
240int mvhline(int y, int x, chtype ch, int n)
241{
242 PDC_LOG(("mvhline() - called\n"));
243
244 if (move(y, x) == ERR)
245 return ERR;
246
247 return whline(stdscr, ch, n);
248}
249
250int mvwhline(WINDOW *win, int y, int x, chtype ch, int n)
251{
252 PDC_LOG(("mvwhline() - called\n"));
253
254 if (wmove(win, y, x) == ERR)
255 return ERR;
256
257 return whline(win, ch, n);
258}
259
260int wvline(WINDOW *win, chtype ch, int n)
261{
262 int endpos, x;
263
264 PDC_LOG(("wvline() - called\n"));
265
266 if (!win || n < 1)
267 return ERR;
268
269 endpos = min(win->_cury + n, win->_maxy);
270 x = win->_curx;
271
272 ch = _attr_passthru(win, ch ? ch : ACS_VLINE);
273
274 for (n = win->_cury; n < endpos; n++)
275 {
276 win->_y[n][x] = ch;
277
278 if (x < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
279 win->_firstch[n] = x;
280
281 if (x > win->_lastch[n])
282 win->_lastch[n] = x;
283 }
284
285 PDC_sync(win);
286
287 return OK;
288}
289
290int vline(chtype ch, int n)
291{
292 PDC_LOG(("vline() - called\n"));
293
294 return wvline(stdscr, ch, n);
295}
296
297int mvvline(int y, int x, chtype ch, int n)
298{
299 PDC_LOG(("mvvline() - called\n"));
300
301 if (move(y, x) == ERR)
302 return ERR;
303
304 return wvline(stdscr, ch, n);
305}
306
307int mvwvline(WINDOW *win, int y, int x, chtype ch, int n)
308{
309 PDC_LOG(("mvwvline() - called\n"));
310
311 if (wmove(win, y, x) == ERR)
312 return ERR;
313
314 return wvline(win, ch, n);
315}
316
317#ifdef PDC_WIDE
318int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
319 const cchar_t *ts, const cchar_t *bs, const cchar_t *tl,
320 const cchar_t *tr, const cchar_t *bl, const cchar_t *br)
321{
322 PDC_LOG(("wborder_set() - called\n"));
323
324 return wborder(win, ls ? *ls : 0, rs ? *rs : 0, ts ? *ts : 0,
325 bs ? *bs : 0, tl ? *tl : 0, tr ? *tr : 0,
326 bl ? *bl : 0, br ? *br : 0);
327}
328
329int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts,
330 const cchar_t *bs, const cchar_t *tl, const cchar_t *tr,
331 const cchar_t *bl, const cchar_t *br)
332{
333 PDC_LOG(("border_set() - called\n"));
334
335 return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
336}
337
338int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch)
339{
340 PDC_LOG(("box_set() - called\n"));
341
342 return wborder_set(win, verch, verch, horch, horch,
343 (const cchar_t *)NULL, (const cchar_t *)NULL,
344 (const cchar_t *)NULL, (const cchar_t *)NULL);
345}
346
347int whline_set(WINDOW *win, const cchar_t *wch, int n)
348{
349 PDC_LOG(("whline_set() - called\n"));
350
351 return wch ? whline(win, *wch, n) : ERR;
352}
353
354int hline_set(const cchar_t *wch, int n)
355{
356 PDC_LOG(("hline_set() - called\n"));
357
358 return whline_set(stdscr, wch, n);
359}
360
361int mvhline_set(int y, int x, const cchar_t *wch, int n)
362{
363 PDC_LOG(("mvhline_set() - called\n"));
364
365 if (move(y, x) == ERR)
366 return ERR;
367
368 return whline_set(stdscr, wch, n);
369}
370
371int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
372{
373 PDC_LOG(("mvwhline_set() - called\n"));
374
375 if (wmove(win, y, x) == ERR)
376 return ERR;
377
378 return whline_set(win, wch, n);
379}
380
381int wvline_set(WINDOW *win, const cchar_t *wch, int n)
382{
383 PDC_LOG(("wvline_set() - called\n"));
384
385 return wch ? wvline(win, *wch, n) : ERR;
386}
387
388int vline_set(const cchar_t *wch, int n)
389{
390 PDC_LOG(("vline_set() - called\n"));
391
392 return wvline_set(stdscr, wch, n);
393}
394
395int mvvline_set(int y, int x, const cchar_t *wch, int n)
396{
397 PDC_LOG(("mvvline_set() - called\n"));
398
399 if (move(y, x) == ERR)
400 return ERR;
401
402 return wvline_set(stdscr, wch, n);
403}
404
405int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
406{
407 PDC_LOG(("mvwvline_set() - called\n"));
408
409 if (wmove(win, y, x) == ERR)
410 return ERR;
411
412 return wvline_set(win, wch, n);
413}
414#endif
diff --git a/scripts/kconfig/libcurses/clear.c b/scripts/kconfig/libcurses/clear.c
new file mode 100644
index 000000000..acb8edf81
--- /dev/null
+++ b/scripts/kconfig/libcurses/clear.c
@@ -0,0 +1,159 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7clear
8-----
9
10### Synopsis
11
12 int clear(void);
13 int wclear(WINDOW *win);
14 int erase(void);
15 int werase(WINDOW *win);
16 int clrtobot(void);
17 int wclrtobot(WINDOW *win);
18 int clrtoeol(void);
19 int wclrtoeol(WINDOW *win);
20
21### Description
22
23 erase() and werase() copy blanks (i.e. the background chtype) to
24 every cell of the window.
25
26 clear() and wclear() are similar to erase() and werase(), but they
27 also call clearok() to ensure that the the window is cleared on the
28 next wrefresh().
29
30 clrtobot() and wclrtobot() clear the window from the current cursor
31 position to the end of the window.
32
33 clrtoeol() and wclrtoeol() clear the window from the current cursor
34 position to the end of the current line.
35
36### Return Value
37
38 All functions return OK on success and ERR on error.
39
40### Portability
41 X/Open ncurses NetBSD
42 clear Y Y Y
43 wclear Y Y Y
44 erase Y Y Y
45 werase Y Y Y
46 clrtobot Y Y Y
47 wclrtobot Y Y Y
48 clrtoeol Y Y Y
49 wclrtoeol Y Y Y
50
51**man-end****************************************************************/
52
53int wclrtoeol(WINDOW *win)
54{
55 int x, y, minx;
56 chtype blank, *ptr;
57
58 PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
59 win->_cury, win->_curx));
60
61 if (!win)
62 return ERR;
63
64 y = win->_cury;
65 x = win->_curx;
66
67 /* wrs (4/10/93) account for window background */
68
69 blank = win->_bkgd;
70
71 for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
72 *ptr = blank;
73
74 if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
75 win->_firstch[y] = x;
76
77 win->_lastch[y] = win->_maxx - 1;
78
79 PDC_sync(win);
80 return OK;
81}
82
83int clrtoeol(void)
84{
85 PDC_LOG(("clrtoeol() - called\n"));
86
87 return wclrtoeol(stdscr);
88}
89
90int wclrtobot(WINDOW *win)
91{
92 int savey, savex;
93
94 PDC_LOG(("wclrtobot() - called\n"));
95
96 if (!win)
97 return ERR;
98
99 savey = win->_cury;
100 savex = win->_curx;
101
102 /* should this involve scrolling region somehow ? */
103
104 if (win->_cury + 1 < win->_maxy)
105 {
106 win->_curx = 0;
107 win->_cury++;
108 for (; win->_maxy > win->_cury; win->_cury++)
109 wclrtoeol(win);
110 win->_cury = savey;
111 win->_curx = savex;
112 }
113 wclrtoeol(win);
114
115 PDC_sync(win);
116 return OK;
117}
118
119int clrtobot(void)
120{
121 PDC_LOG(("clrtobot() - called\n"));
122
123 return wclrtobot(stdscr);
124}
125
126int werase(WINDOW *win)
127{
128 PDC_LOG(("werase() - called\n"));
129
130 if (wmove(win, 0, 0) == ERR)
131 return ERR;
132
133 return wclrtobot(win);
134}
135
136int erase(void)
137{
138 PDC_LOG(("erase() - called\n"));
139
140 return werase(stdscr);
141}
142
143int wclear(WINDOW *win)
144{
145 PDC_LOG(("wclear() - called\n"));
146
147 if (!win)
148 return ERR;
149
150 win->_clear = TRUE;
151 return werase(win);
152}
153
154int clear(void)
155{
156 PDC_LOG(("clear() - called\n"));
157
158 return wclear(stdscr);
159}
diff --git a/scripts/kconfig/libcurses/color.c b/scripts/kconfig/libcurses/color.c
new file mode 100644
index 000000000..83b2336f9
--- /dev/null
+++ b/scripts/kconfig/libcurses/color.c
@@ -0,0 +1,298 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7color
8-----
9
10### Synopsis
11
12 bool has_colors(void);
13 int start_color(void);
14 int init_pair(short pair, short fg, short bg);
15 int pair_content(short pair, short *fg, short *bg);
16 bool can_change_color(void);
17 int init_color(short color, short red, short green, short blue);
18 int color_content(short color, short *red, short *green, short *blue);
19
20 int assume_default_colors(int f, int b);
21 int use_default_colors(void);
22
23 int PDC_set_line_color(short color);
24
25### Description
26
27 To use these routines, first, call start_color(). Colors are always
28 used in pairs, referred to as color-pairs. A color-pair is created by
29 init_pair(), and consists of a foreground color and a background
30 color. After initialization, COLOR_PAIR(n) can be used like any other
31 video attribute.
32
33 has_colors() reports whether the terminal supports color.
34
35 start_color() initializes eight basic colors (black, red, green,
36 yellow, blue, magenta, cyan, and white), and two global variables:
37 COLORS and COLOR_PAIRS (respectively defining the maximum number of
38 colors and color-pairs the terminal is capable of displaying).
39
40 init_pair() changes the definition of a color-pair. It takes three
41 arguments: the number of the color-pair to be redefined, and the new
42 values of the foreground and background colors. The pair number must
43 be between 0 and COLOR_PAIRS - 1, inclusive. The foreground and
44 background must be between 0 and COLORS - 1, inclusive. If the color
45 pair was previously initialized, the screen is refreshed, and all
46 occurrences of that color-pair are changed to the new definition.
47
48 pair_content() is used to determine what the colors of a given color-
49 pair consist of.
50
51 can_change_color() indicates if the terminal has the capability to
52 change the definition of its colors.
53
54 init_color() is used to redefine a color, if possible. Each of the
55 components -- red, green, and blue -- is specified in a range from 0
56 to 1000, inclusive.
57
58 color_content() reports the current definition of a color in the same
59 format as used by init_color().
60
61 assume_default_colors() and use_default_colors() emulate the ncurses
62 extensions of the same names. assume_default_colors(f, b) is
63 essentially the same as init_pair(0, f, b) (which isn't allowed); it
64 redefines the default colors. use_default_colors() allows the use of
65 -1 as a foreground or background color with init_pair(), and calls
66 assume_default_colors(-1, -1); -1 represents the foreground or
67 background color that the terminal had at startup. If the environment
68 variable PDC_ORIGINAL_COLORS is set at the time start_color() is
69 called, that's equivalent to calling use_default_colors().
70
71 PDC_set_line_color() is used to set the color, globally, for the
72 color of the lines drawn for the attributes: A_UNDERLINE, A_LEFT and
73 A_RIGHT. A value of -1 (the default) indicates that the current
74 foreground color should be used.
75
76 NOTE: COLOR_PAIR() and PAIR_NUMBER() are implemented as macros.
77
78### Return Value
79
80 All functions return OK on success and ERR on error, except for
81 has_colors() and can_change_colors(), which return TRUE or FALSE.
82
83### Portability
84 X/Open ncurses NetBSD
85 has_colors Y Y Y
86 start_color Y Y Y
87 init_pair Y Y Y
88 pair_content Y Y Y
89 can_change_color Y Y Y
90 init_color Y Y Y
91 color_content Y Y Y
92 assume_default_colors - Y Y
93 use_default_colors - Y Y
94 PDC_set_line_color - - -
95
96**man-end****************************************************************/
97
98#include <stdlib.h>
99#include <string.h>
100
101int COLORS = 0;
102int COLOR_PAIRS = PDC_COLOR_PAIRS;
103
104/* pair_set[] tracks whether a pair has been set via init_pair() */
105
106static bool pair_set[PDC_COLOR_PAIRS];
107static bool default_colors = FALSE;
108static short first_col = 0;
109
110int start_color(void)
111{
112 PDC_LOG(("start_color() - called\n"));
113
114 if (!SP || SP->mono)
115 return ERR;
116
117 SP->color_started = TRUE;
118
119 PDC_set_blink(FALSE); /* Also sets COLORS */
120
121 if (!default_colors && SP->orig_attr && getenv("PDC_ORIGINAL_COLORS"))
122 default_colors = TRUE;
123
124 PDC_init_atrtab();
125
126 memset(pair_set, 0, PDC_COLOR_PAIRS);
127
128 return OK;
129}
130
131static void _normalize(short *fg, short *bg)
132{
133 if (*fg == -1)
134 *fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
135
136 if (*bg == -1)
137 *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
138}
139
140int init_pair(short pair, short fg, short bg)
141{
142 PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
143
144 if (!SP || !SP->color_started || pair < 1 || pair >= COLOR_PAIRS ||
145 fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
146 return ERR;
147
148 _normalize(&fg, &bg);
149
150 /* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
151 curscr if this call to init_pair() alters a color pair created by
152 the user. */
153
154 if (pair_set[pair])
155 {
156 short oldfg, oldbg;
157
158 PDC_pair_content(pair, &oldfg, &oldbg);
159
160 if (oldfg != fg || oldbg != bg)
161 curscr->_clear = TRUE;
162 }
163
164 PDC_init_pair(pair, fg, bg);
165
166 pair_set[pair] = TRUE;
167
168 return OK;
169}
170
171bool has_colors(void)
172{
173 PDC_LOG(("has_colors() - called\n"));
174
175 return SP ? !(SP->mono) : FALSE;
176}
177
178int init_color(short color, short red, short green, short blue)
179{
180 PDC_LOG(("init_color() - called\n"));
181
182 if (!SP || color < 0 || color >= COLORS || !PDC_can_change_color() ||
183 red < -1 || red > 1000 || green < -1 || green > 1000 ||
184 blue < -1 || blue > 1000)
185 return ERR;
186
187 SP->dirty = TRUE;
188
189 return PDC_init_color(color, red, green, blue);
190}
191
192int color_content(short color, short *red, short *green, short *blue)
193{
194 PDC_LOG(("color_content() - called\n"));
195
196 if (color < 0 || color >= COLORS || !red || !green || !blue)
197 return ERR;
198
199 if (PDC_can_change_color())
200 return PDC_color_content(color, red, green, blue);
201 else
202 {
203 /* Simulated values for platforms that don't support palette
204 changing */
205
206 short maxval = (color & 8) ? 1000 : 680;
207
208 *red = (color & COLOR_RED) ? maxval : 0;
209 *green = (color & COLOR_GREEN) ? maxval : 0;
210 *blue = (color & COLOR_BLUE) ? maxval : 0;
211
212 return OK;
213 }
214}
215
216bool can_change_color(void)
217{
218 PDC_LOG(("can_change_color() - called\n"));
219
220 return PDC_can_change_color();
221}
222
223int pair_content(short pair, short *fg, short *bg)
224{
225 PDC_LOG(("pair_content() - called\n"));
226
227 if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
228 return ERR;
229
230 return PDC_pair_content(pair, fg, bg);
231}
232
233int assume_default_colors(int f, int b)
234{
235 PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
236
237 if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
238 return ERR;
239
240 if (SP->color_started)
241 {
242 short fg, bg, oldfg, oldbg;
243
244 fg = f;
245 bg = b;
246
247 _normalize(&fg, &bg);
248
249 PDC_pair_content(0, &oldfg, &oldbg);
250
251 if (oldfg != fg || oldbg != bg)
252 curscr->_clear = TRUE;
253
254 PDC_init_pair(0, fg, bg);
255 }
256
257 return OK;
258}
259
260int use_default_colors(void)
261{
262 PDC_LOG(("use_default_colors() - called\n"));
263
264 default_colors = TRUE;
265 first_col = -1;
266
267 return assume_default_colors(-1, -1);
268}
269
270int PDC_set_line_color(short color)
271{
272 PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
273
274 if (!SP || color < -1 || color >= COLORS)
275 return ERR;
276
277 SP->line_color = color;
278
279 return OK;
280}
281
282void PDC_init_atrtab(void)
283{
284 short i, fg, bg;
285
286 if (SP->color_started && !default_colors)
287 {
288 fg = COLOR_WHITE;
289 bg = COLOR_BLACK;
290 }
291 else
292 fg = bg = -1;
293
294 _normalize(&fg, &bg);
295
296 for (i = 0; i < PDC_COLOR_PAIRS; i++)
297 PDC_init_pair(i, fg, bg);
298}
diff --git a/scripts/kconfig/libcurses/curses.h b/scripts/kconfig/libcurses/curses.h
new file mode 100644
index 000000000..b5b91fda3
--- /dev/null
+++ b/scripts/kconfig/libcurses/curses.h
@@ -0,0 +1,1406 @@
1/*----------------------------------------------------------------------*
2 * PDCurses *
3 *----------------------------------------------------------------------*/
4
5#ifndef __PDCURSES__
6#define __PDCURSES__ 1
7
8/*man-start**************************************************************
9
10Define before inclusion (only those needed):
11
12 XCURSES True if compiling for X11.
13 PDC_RGB True if you want to use RGB color definitions
14 (Red = 1, Green = 2, Blue = 4) instead of BGR.
15 PDC_WIDE True if building wide-character support.
16 PDC_DLL_BUILD True if building a Windows DLL.
17 PDC_NCMOUSE Use the ncurses mouse API instead
18 of PDCurses' traditional mouse API.
19
20Defined by this header:
21
22 PDCURSES Enables access to PDCurses-only routines.
23 PDC_BUILD Defines API build version.
24 PDC_VER_MAJOR Major version number
25 PDC_VER_MINOR Minor version number
26 PDC_VERDOT Version string
27
28**man-end****************************************************************/
29
30#define PDCURSES 1
31#define PDC_BUILD 3900
32#define PDC_VER_MAJOR 3
33#define PDC_VER_MINOR 9
34#define PDC_VERDOT "3.9"
35
36#define CHTYPE_LONG 1 /* chtype >= 32 bits */
37
38#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
39# define PDC_99 1
40#endif
41
42#if defined(__cplusplus) && __cplusplus >= 199711L
43# define PDC_PP98 1
44#endif
45
46/*----------------------------------------------------------------------*/
47
48#include <stdarg.h>
49#include <stddef.h>
50#include <stdio.h>
51
52#ifdef PDC_WIDE
53# include <wchar.h>
54#endif
55
56#if defined(PDC_99) && !defined(__bool_true_false_are_defined)
57# include <stdbool.h>
58#endif
59
60#ifdef __cplusplus
61extern "C"
62{
63# ifndef PDC_PP98
64# define bool _bool
65# endif
66#endif
67
68/*----------------------------------------------------------------------
69 *
70 * Constants and Types
71 *
72 */
73
74#undef FALSE
75#define FALSE 0
76
77#undef TRUE
78#define TRUE 1
79
80#undef ERR
81#define ERR (-1)
82
83#undef OK
84#define OK 0
85
86#if !defined(PDC_PP98) && !defined(__bool_true_false_are_defined)
87typedef unsigned char bool;
88#endif
89
90#if _LP64
91typedef unsigned int chtype;
92#else
93typedef unsigned long chtype; /* 16-bit attr + 16-bit char */
94#endif
95
96#ifdef PDC_WIDE
97typedef chtype cchar_t;
98#endif
99
100typedef chtype attr_t;
101
102/*----------------------------------------------------------------------
103 *
104 * Version Info
105 *
106 */
107
108/* Use this structure with PDC_get_version() for run-time info about the
109 way the library was built, in case it doesn't match the header. */
110
111typedef struct
112{
113 short flags; /* flags OR'd together (see below) */
114 short build; /* PDC_BUILD at compile time */
115 unsigned char major; /* PDC_VER_MAJOR */
116 unsigned char minor; /* PDC_VER_MINOR */
117 unsigned char csize; /* sizeof chtype */
118 unsigned char bsize; /* sizeof bool */
119} PDC_VERSION;
120
121enum
122{
123 PDC_VFLAG_DEBUG = 1, /* set if built with -DPDCDEBUG */
124 PDC_VFLAG_WIDE = 2, /* -DPDC_WIDE */
125 PDC_VFLAG_UTF8 = 4, /* -DPDC_FORCE_UTF8 */
126 PDC_VFLAG_DLL = 8, /* -DPDC_DLL_BUILD */
127 PDC_VFLAG_RGB = 16 /* -DPDC_RGB */
128};
129
130/*----------------------------------------------------------------------
131 *
132 * Mouse Interface
133 *
134 */
135
136#if _LP64
137typedef unsigned int mmask_t;
138#else
139typedef unsigned long mmask_t;
140#endif
141
142typedef struct
143{
144 int x; /* absolute column, 0 based, measured in characters */
145 int y; /* absolute row, 0 based, measured in characters */
146 short button[3]; /* state of each button */
147 int changes; /* flags indicating what has changed with the mouse */
148} MOUSE_STATUS;
149
150#define BUTTON_RELEASED 0x0000
151#define BUTTON_PRESSED 0x0001
152#define BUTTON_CLICKED 0x0002
153#define BUTTON_DOUBLE_CLICKED 0x0003
154#define BUTTON_TRIPLE_CLICKED 0x0004
155#define BUTTON_MOVED 0x0005 /* PDCurses */
156#define WHEEL_SCROLLED 0x0006 /* PDCurses */
157#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */
158
159#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */
160#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */
161#define PDC_BUTTON_ALT 0x0020 /* PDCurses */
162#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */
163
164#define MOUSE_X_POS (Mouse_status.x)
165#define MOUSE_Y_POS (Mouse_status.y)
166
167/*
168 * Bits associated with the .changes field:
169 * 3 2 1 0
170 * 210987654321098765432109876543210
171 * 1 <- button 1 has changed
172 * 10 <- button 2 has changed
173 * 100 <- button 3 has changed
174 * 1000 <- mouse has moved
175 * 10000 <- mouse position report
176 * 100000 <- mouse wheel up
177 * 1000000 <- mouse wheel down
178 * 10000000 <- mouse wheel left
179 * 100000000 <- mouse wheel right
180 */
181
182#define PDC_MOUSE_MOVED 0x0008
183#define PDC_MOUSE_POSITION 0x0010
184#define PDC_MOUSE_WHEEL_UP 0x0020
185#define PDC_MOUSE_WHEEL_DOWN 0x0040
186#define PDC_MOUSE_WHEEL_LEFT 0x0080
187#define PDC_MOUSE_WHEEL_RIGHT 0x0100
188
189#define A_BUTTON_CHANGED (Mouse_status.changes & 7)
190#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED)
191#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION)
192#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1)))
193#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1])
194#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP)
195#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN)
196#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT)
197#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT)
198
199/* mouse bit-masks */
200
201#define BUTTON1_RELEASED 0x00000001L
202#define BUTTON1_PRESSED 0x00000002L
203#define BUTTON1_CLICKED 0x00000004L
204#define BUTTON1_DOUBLE_CLICKED 0x00000008L
205#define BUTTON1_TRIPLE_CLICKED 0x00000010L
206#define BUTTON1_MOVED 0x00000010L /* PDCurses */
207
208#define BUTTON2_RELEASED 0x00000020L
209#define BUTTON2_PRESSED 0x00000040L
210#define BUTTON2_CLICKED 0x00000080L
211#define BUTTON2_DOUBLE_CLICKED 0x00000100L
212#define BUTTON2_TRIPLE_CLICKED 0x00000200L
213#define BUTTON2_MOVED 0x00000200L /* PDCurses */
214
215#define BUTTON3_RELEASED 0x00000400L
216#define BUTTON3_PRESSED 0x00000800L
217#define BUTTON3_CLICKED 0x00001000L
218#define BUTTON3_DOUBLE_CLICKED 0x00002000L
219#define BUTTON3_TRIPLE_CLICKED 0x00004000L
220#define BUTTON3_MOVED 0x00004000L /* PDCurses */
221
222/* For the ncurses-compatible functions only, BUTTON4_PRESSED and
223 BUTTON5_PRESSED are returned for mouse scroll wheel up and down;
224 otherwise PDCurses doesn't support buttons 4 and 5 */
225
226#define BUTTON4_RELEASED 0x00008000L
227#define BUTTON4_PRESSED 0x00010000L
228#define BUTTON4_CLICKED 0x00020000L
229#define BUTTON4_DOUBLE_CLICKED 0x00040000L
230#define BUTTON4_TRIPLE_CLICKED 0x00080000L
231
232#define BUTTON5_RELEASED 0x00100000L
233#define BUTTON5_PRESSED 0x00200000L
234#define BUTTON5_CLICKED 0x00400000L
235#define BUTTON5_DOUBLE_CLICKED 0x00800000L
236#define BUTTON5_TRIPLE_CLICKED 0x01000000L
237
238#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */
239#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */
240#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */
241#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */
242
243#define ALL_MOUSE_EVENTS 0x1fffffffL
244#define REPORT_MOUSE_POSITION 0x20000000L
245
246/* ncurses mouse interface */
247
248typedef struct
249{
250 short id; /* unused, always 0 */
251 int x, y, z; /* x, y same as MOUSE_STATUS; z unused */
252 mmask_t bstate; /* equivalent to changes + button[], but
253 in the same format as used for mousemask() */
254} MEVENT;
255
256#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION)
257# define NCURSES_MOUSE_VERSION 2
258#endif
259
260#ifdef NCURSES_MOUSE_VERSION
261# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT
262# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL
263# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL
264# define BUTTON_ALT BUTTON_MODIFIER_ALT
265#else
266# define BUTTON_SHIFT PDC_BUTTON_SHIFT
267# define BUTTON_CONTROL PDC_BUTTON_CONTROL
268# define BUTTON_ALT PDC_BUTTON_ALT
269#endif
270
271/*----------------------------------------------------------------------
272 *
273 * Window and Screen Structures
274 *
275 */
276
277typedef struct _win /* definition of a window */
278{
279 int _cury; /* current pseudo-cursor */
280 int _curx;
281 int _maxy; /* max window coordinates */
282 int _maxx;
283 int _begy; /* origin on screen */
284 int _begx;
285 int _flags; /* window properties */
286 chtype _attrs; /* standard attributes and colors */
287 chtype _bkgd; /* background, normally blank */
288 bool _clear; /* causes clear at next refresh */
289 bool _leaveit; /* leaves cursor where it is */
290 bool _scroll; /* allows window scrolling */
291 bool _nodelay; /* input character wait flag */
292 bool _immed; /* immediate update flag */
293 bool _sync; /* synchronise window ancestors */
294 bool _use_keypad; /* flags keypad key mode active */
295 chtype **_y; /* pointer to line pointer array */
296 int *_firstch; /* first changed character in line */
297 int *_lastch; /* last changed character in line */
298 int _tmarg; /* top of scrolling region */
299 int _bmarg; /* bottom of scrolling region */
300 int _delayms; /* milliseconds of delay for getch() */
301 int _parx, _pary; /* coords relative to parent (0,0) */
302 struct _win *_parent; /* subwin's pointer to parent win */
303} WINDOW;
304
305/* Avoid using the SCREEN struct directly -- use the corresponding
306 functions if possible. This struct may eventually be made private. */
307
308typedef struct
309{
310 bool alive; /* if initscr() called, and not endwin() */
311 bool autocr; /* if cr -> lf */
312 bool cbreak; /* if terminal unbuffered */
313 bool echo; /* if terminal echo */
314 bool raw_inp; /* raw input mode (v. cooked input) */
315 bool raw_out; /* raw output mode (7 v. 8 bits) */
316 bool audible; /* FALSE if the bell is visual */
317 bool mono; /* TRUE if current screen is mono */
318 bool resized; /* TRUE if TERM has been resized */
319 bool orig_attr; /* TRUE if we have the original colors */
320 short orig_fore; /* original screen foreground color */
321 short orig_back; /* original screen foreground color */
322 int cursrow; /* position of physical cursor */
323 int curscol; /* position of physical cursor */
324 int visibility; /* visibility of cursor */
325 int orig_cursor; /* original cursor size */
326 int lines; /* new value for LINES */
327 int cols; /* new value for COLS */
328 mmask_t _trap_mbe; /* trap these mouse button events */
329 int mouse_wait; /* time to wait (in ms) for a
330 button release after a press, in
331 order to count it as a click */
332 int slklines; /* lines in use by slk_init() */
333 WINDOW *slk_winptr; /* window for slk */
334 int linesrippedoff; /* lines ripped off via ripoffline() */
335 int linesrippedoffontop; /* lines ripped off on
336 top via ripoffline() */
337 int delaytenths; /* 1/10ths second to wait block
338 getch() for */
339 bool _preserve; /* TRUE if screen background
340 to be preserved */
341 int _restore; /* specifies if screen background
342 to be restored, and how */
343 unsigned long key_modifiers; /* key modifiers (SHIFT, CONTROL, etc.)
344 on last key press */
345 bool return_key_modifiers; /* TRUE if modifier keys are
346 returned as "real" keys */
347 bool key_code; /* TRUE if last key is a special key;
348 used internally by get_wch() */
349 MOUSE_STATUS mouse_status; /* last returned mouse status */
350#ifdef XCURSES
351 bool sb_on;
352 int sb_viewport_y;
353 int sb_viewport_x;
354 int sb_total_y;
355 int sb_total_x;
356 int sb_cur_y;
357 int sb_cur_x;
358#endif
359 short line_color; /* color of line attributes - default -1 */
360 attr_t termattrs; /* attribute capabilities */
361 WINDOW *lastscr; /* the last screen image */
362 FILE *dbfp; /* debug trace file pointer */
363 bool color_started; /* TRUE after start_color() */
364 bool dirty; /* redraw on napms() after init_color() */
365 int sel_start; /* start of selection (y * COLS + x) */
366 int sel_end; /* end of selection */
367} SCREEN;
368
369/*----------------------------------------------------------------------
370 *
371 * External Variables
372 *
373 */
374
375#ifdef PDC_DLL_BUILD
376# ifdef CURSES_LIBRARY
377# define PDCEX __declspec(dllexport) extern
378# else
379# define PDCEX __declspec(dllimport)
380# endif
381#else
382# define PDCEX extern
383#endif
384
385PDCEX int LINES; /* terminal height */
386PDCEX int COLS; /* terminal width */
387PDCEX WINDOW *stdscr; /* the default screen window */
388PDCEX WINDOW *curscr; /* the current screen image */
389PDCEX SCREEN *SP; /* curses variables */
390PDCEX MOUSE_STATUS Mouse_status;
391PDCEX int COLORS;
392PDCEX int COLOR_PAIRS;
393PDCEX int TABSIZE;
394PDCEX chtype acs_map[]; /* alternate character set map */
395PDCEX char ttytype[]; /* terminal name/description */
396
397/*man-start**************************************************************
398
399Text Attributes
400===============
401
402PDCurses uses a 32-bit integer for its chtype:
403
404 +--------------------------------------------------------------------+
405 |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0|
406 +--------------------------------------------------------------------+
407 color pair | modifiers | character eg 'a'
408
409There are 256 color pairs (8 bits), 8 bits for modifiers, and 16 bits
410for character data. The modifiers are bold, underline, right-line,
411left-line, italic, reverse and blink, plus the alternate character set
412indicator.
413
414**man-end****************************************************************/
415
416/*** Video attribute macros ***/
417
418#define A_NORMAL (chtype)0
419
420#define A_ALTCHARSET (chtype)0x00010000
421#define A_RIGHT (chtype)0x00020000
422#define A_LEFT (chtype)0x00040000
423#define A_ITALIC (chtype)0x00080000
424#define A_UNDERLINE (chtype)0x00100000
425#define A_REVERSE (chtype)0x00200000
426#define A_BLINK (chtype)0x00400000
427#define A_BOLD (chtype)0x00800000
428
429#define A_ATTRIBUTES (chtype)0xffff0000
430#define A_CHARTEXT (chtype)0x0000ffff
431#define A_COLOR (chtype)0xff000000
432
433#define PDC_COLOR_SHIFT 24
434
435#define A_LEFTLINE A_LEFT
436#define A_RIGHTLINE A_RIGHT
437#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */
438
439#define A_DIM A_NORMAL
440#define A_INVIS A_NORMAL
441#define A_PROTECT A_NORMAL
442
443#define A_HORIZONTAL A_NORMAL
444#define A_LOW A_NORMAL
445#define A_TOP A_NORMAL
446#define A_VERTICAL A_NORMAL
447
448#define CHR_MSK A_CHARTEXT /* Obsolete */
449#define ATR_MSK A_ATTRIBUTES /* Obsolete */
450#define ATR_NRM A_NORMAL /* Obsolete */
451
452/* For use with attr_t -- X/Open says, "these shall be distinct", so
453 this is a non-conforming implementation. */
454
455#define WA_NORMAL A_NORMAL
456
457#define WA_ALTCHARSET A_ALTCHARSET
458#define WA_BLINK A_BLINK
459#define WA_BOLD A_BOLD
460#define WA_DIM A_DIM
461#define WA_INVIS A_INVIS
462#define WA_ITALIC A_ITALIC
463#define WA_LEFT A_LEFT
464#define WA_PROTECT A_PROTECT
465#define WA_REVERSE A_REVERSE
466#define WA_RIGHT A_RIGHT
467#define WA_STANDOUT A_STANDOUT
468#define WA_UNDERLINE A_UNDERLINE
469
470#define WA_HORIZONTAL A_HORIZONTAL
471#define WA_LOW A_LOW
472#define WA_TOP A_TOP
473#define WA_VERTICAL A_VERTICAL
474
475#define WA_ATTRIBUTES A_ATTRIBUTES
476
477/*** Alternate character set macros ***/
478
479#define PDC_ACS(w) ((chtype)w | A_ALTCHARSET)
480
481/* VT100-compatible symbols -- box chars */
482
483#define ACS_ULCORNER PDC_ACS('l')
484#define ACS_LLCORNER PDC_ACS('m')
485#define ACS_URCORNER PDC_ACS('k')
486#define ACS_LRCORNER PDC_ACS('j')
487#define ACS_RTEE PDC_ACS('u')
488#define ACS_LTEE PDC_ACS('t')
489#define ACS_BTEE PDC_ACS('v')
490#define ACS_TTEE PDC_ACS('w')
491#define ACS_HLINE PDC_ACS('q')
492#define ACS_VLINE PDC_ACS('x')
493#define ACS_PLUS PDC_ACS('n')
494
495/* VT100-compatible symbols -- other */
496
497#define ACS_S1 PDC_ACS('o')
498#define ACS_S9 PDC_ACS('s')
499#define ACS_DIAMOND PDC_ACS('`')
500#define ACS_CKBOARD PDC_ACS('a')
501#define ACS_DEGREE PDC_ACS('f')
502#define ACS_PLMINUS PDC_ACS('g')
503#define ACS_BULLET PDC_ACS('~')
504
505/* Teletype 5410v1 symbols -- these are defined in SysV curses, but
506 are not well-supported by most terminals. Stick to VT100 characters
507 for optimum portability. */
508
509#define ACS_LARROW PDC_ACS(',')
510#define ACS_RARROW PDC_ACS('+')
511#define ACS_DARROW PDC_ACS('.')
512#define ACS_UARROW PDC_ACS('-')
513#define ACS_BOARD PDC_ACS('h')
514#define ACS_LANTERN PDC_ACS('i')
515#define ACS_BLOCK PDC_ACS('0')
516
517/* That goes double for these -- undocumented SysV symbols. Don't use
518 them. */
519
520#define ACS_S3 PDC_ACS('p')
521#define ACS_S7 PDC_ACS('r')
522#define ACS_LEQUAL PDC_ACS('y')
523#define ACS_GEQUAL PDC_ACS('z')
524#define ACS_PI PDC_ACS('{')
525#define ACS_NEQUAL PDC_ACS('|')
526#define ACS_STERLING PDC_ACS('}')
527
528/* Box char aliases */
529
530#define ACS_BSSB ACS_ULCORNER
531#define ACS_SSBB ACS_LLCORNER
532#define ACS_BBSS ACS_URCORNER
533#define ACS_SBBS ACS_LRCORNER
534#define ACS_SBSS ACS_RTEE
535#define ACS_SSSB ACS_LTEE
536#define ACS_SSBS ACS_BTEE
537#define ACS_BSSS ACS_TTEE
538#define ACS_BSBS ACS_HLINE
539#define ACS_SBSB ACS_VLINE
540#define ACS_SSSS ACS_PLUS
541
542/* cchar_t aliases */
543
544#ifdef PDC_WIDE
545# define WACS_ULCORNER (&(acs_map['l']))
546# define WACS_LLCORNER (&(acs_map['m']))
547# define WACS_URCORNER (&(acs_map['k']))
548# define WACS_LRCORNER (&(acs_map['j']))
549# define WACS_RTEE (&(acs_map['u']))
550# define WACS_LTEE (&(acs_map['t']))
551# define WACS_BTEE (&(acs_map['v']))
552# define WACS_TTEE (&(acs_map['w']))
553# define WACS_HLINE (&(acs_map['q']))
554# define WACS_VLINE (&(acs_map['x']))
555# define WACS_PLUS (&(acs_map['n']))
556
557# define WACS_S1 (&(acs_map['o']))
558# define WACS_S9 (&(acs_map['s']))
559# define WACS_DIAMOND (&(acs_map['`']))
560# define WACS_CKBOARD (&(acs_map['a']))
561# define WACS_DEGREE (&(acs_map['f']))
562# define WACS_PLMINUS (&(acs_map['g']))
563# define WACS_BULLET (&(acs_map['~']))
564
565# define WACS_LARROW (&(acs_map[',']))
566# define WACS_RARROW (&(acs_map['+']))
567# define WACS_DARROW (&(acs_map['.']))
568# define WACS_UARROW (&(acs_map['-']))
569# define WACS_BOARD (&(acs_map['h']))
570# define WACS_LANTERN (&(acs_map['i']))
571# define WACS_BLOCK (&(acs_map['0']))
572
573# define WACS_S3 (&(acs_map['p']))
574# define WACS_S7 (&(acs_map['r']))
575# define WACS_LEQUAL (&(acs_map['y']))
576# define WACS_GEQUAL (&(acs_map['z']))
577# define WACS_PI (&(acs_map['{']))
578# define WACS_NEQUAL (&(acs_map['|']))
579# define WACS_STERLING (&(acs_map['}']))
580
581# define WACS_BSSB WACS_ULCORNER
582# define WACS_SSBB WACS_LLCORNER
583# define WACS_BBSS WACS_URCORNER
584# define WACS_SBBS WACS_LRCORNER
585# define WACS_SBSS WACS_RTEE
586# define WACS_SSSB WACS_LTEE
587# define WACS_SSBS WACS_BTEE
588# define WACS_BSSS WACS_TTEE
589# define WACS_BSBS WACS_HLINE
590# define WACS_SBSB WACS_VLINE
591# define WACS_SSSS WACS_PLUS
592#endif
593
594/*** Color macros ***/
595
596#define COLOR_BLACK 0
597
598#ifdef PDC_RGB /* RGB */
599# define COLOR_RED 1
600# define COLOR_GREEN 2
601# define COLOR_BLUE 4
602#else /* BGR */
603# define COLOR_BLUE 1
604# define COLOR_GREEN 2
605# define COLOR_RED 4
606#endif
607
608#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN)
609#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE)
610#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN)
611
612#define COLOR_WHITE 7
613
614/*----------------------------------------------------------------------
615 *
616 * Function and Keypad Key Definitions
617 * Many are just for compatibility
618 *
619 */
620
621#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
622
623#define KEY_BREAK 0x101 /* Not on PC KBD */
624#define KEY_DOWN 0x102 /* Down arrow key */
625#define KEY_UP 0x103 /* Up arrow key */
626#define KEY_LEFT 0x104 /* Left arrow key */
627#define KEY_RIGHT 0x105 /* Right arrow key */
628#define KEY_HOME 0x106 /* home key */
629#define KEY_BACKSPACE 0x107 /* not on pc */
630#define KEY_F0 0x108 /* function keys; 64 reserved */
631
632#define KEY_DL 0x148 /* delete line */
633#define KEY_IL 0x149 /* insert line */
634#define KEY_DC 0x14a /* delete character */
635#define KEY_IC 0x14b /* insert char or enter ins mode */
636#define KEY_EIC 0x14c /* exit insert char mode */
637#define KEY_CLEAR 0x14d /* clear screen */
638#define KEY_EOS 0x14e /* clear to end of screen */
639#define KEY_EOL 0x14f /* clear to end of line */
640#define KEY_SF 0x150 /* scroll 1 line forward */
641#define KEY_SR 0x151 /* scroll 1 line back (reverse) */
642#define KEY_NPAGE 0x152 /* next page */
643#define KEY_PPAGE 0x153 /* previous page */
644#define KEY_STAB 0x154 /* set tab */
645#define KEY_CTAB 0x155 /* clear tab */
646#define KEY_CATAB 0x156 /* clear all tabs */
647#define KEY_ENTER 0x157 /* enter or send (unreliable) */
648#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */
649#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */
650#define KEY_PRINT 0x15a /* print/copy */
651#define KEY_LL 0x15b /* home down/bottom (lower left) */
652#define KEY_ABORT 0x15c /* abort/terminate key (any) */
653#define KEY_SHELP 0x15d /* short help */
654#define KEY_LHELP 0x15e /* long help */
655#define KEY_BTAB 0x15f /* Back tab key */
656#define KEY_BEG 0x160 /* beg(inning) key */
657#define KEY_CANCEL 0x161 /* cancel key */
658#define KEY_CLOSE 0x162 /* close key */
659#define KEY_COMMAND 0x163 /* cmd (command) key */
660#define KEY_COPY 0x164 /* copy key */
661#define KEY_CREATE 0x165 /* create key */
662#define KEY_END 0x166 /* end key */
663#define KEY_EXIT 0x167 /* exit key */
664#define KEY_FIND 0x168 /* find key */
665#define KEY_HELP 0x169 /* help key */
666#define KEY_MARK 0x16a /* mark key */
667#define KEY_MESSAGE 0x16b /* message key */
668#define KEY_MOVE 0x16c /* move key */
669#define KEY_NEXT 0x16d /* next object key */
670#define KEY_OPEN 0x16e /* open key */
671#define KEY_OPTIONS 0x16f /* options key */
672#define KEY_PREVIOUS 0x170 /* previous object key */
673#define KEY_REDO 0x171 /* redo key */
674#define KEY_REFERENCE 0x172 /* ref(erence) key */
675#define KEY_REFRESH 0x173 /* refresh key */
676#define KEY_REPLACE 0x174 /* replace key */
677#define KEY_RESTART 0x175 /* restart key */
678#define KEY_RESUME 0x176 /* resume key */
679#define KEY_SAVE 0x177 /* save key */
680#define KEY_SBEG 0x178 /* shifted beginning key */
681#define KEY_SCANCEL 0x179 /* shifted cancel key */
682#define KEY_SCOMMAND 0x17a /* shifted command key */
683#define KEY_SCOPY 0x17b /* shifted copy key */
684#define KEY_SCREATE 0x17c /* shifted create key */
685#define KEY_SDC 0x17d /* shifted delete char key */
686#define KEY_SDL 0x17e /* shifted delete line key */
687#define KEY_SELECT 0x17f /* select key */
688#define KEY_SEND 0x180 /* shifted end key */
689#define KEY_SEOL 0x181 /* shifted clear line key */
690#define KEY_SEXIT 0x182 /* shifted exit key */
691#define KEY_SFIND 0x183 /* shifted find key */
692#define KEY_SHOME 0x184 /* shifted home key */
693#define KEY_SIC 0x185 /* shifted input key */
694
695#define KEY_SLEFT 0x187 /* shifted left arrow key */
696#define KEY_SMESSAGE 0x188 /* shifted message key */
697#define KEY_SMOVE 0x189 /* shifted move key */
698#define KEY_SNEXT 0x18a /* shifted next key */
699#define KEY_SOPTIONS 0x18b /* shifted options key */
700#define KEY_SPREVIOUS 0x18c /* shifted prev key */
701#define KEY_SPRINT 0x18d /* shifted print key */
702#define KEY_SREDO 0x18e /* shifted redo key */
703#define KEY_SREPLACE 0x18f /* shifted replace key */
704#define KEY_SRIGHT 0x190 /* shifted right arrow */
705#define KEY_SRSUME 0x191 /* shifted resume key */
706#define KEY_SSAVE 0x192 /* shifted save key */
707#define KEY_SSUSPEND 0x193 /* shifted suspend key */
708#define KEY_SUNDO 0x194 /* shifted undo key */
709#define KEY_SUSPEND 0x195 /* suspend key */
710#define KEY_UNDO 0x196 /* undo key */
711
712/* PDCurses-specific key definitions -- PC only */
713
714#define ALT_0 0x197
715#define ALT_1 0x198
716#define ALT_2 0x199
717#define ALT_3 0x19a
718#define ALT_4 0x19b
719#define ALT_5 0x19c
720#define ALT_6 0x19d
721#define ALT_7 0x19e
722#define ALT_8 0x19f
723#define ALT_9 0x1a0
724#define ALT_A 0x1a1
725#define ALT_B 0x1a2
726#define ALT_C 0x1a3
727#define ALT_D 0x1a4
728#define ALT_E 0x1a5
729#define ALT_F 0x1a6
730#define ALT_G 0x1a7
731#define ALT_H 0x1a8
732#define ALT_I 0x1a9
733#define ALT_J 0x1aa
734#define ALT_K 0x1ab
735#define ALT_L 0x1ac
736#define ALT_M 0x1ad
737#define ALT_N 0x1ae
738#define ALT_O 0x1af
739#define ALT_P 0x1b0
740#define ALT_Q 0x1b1
741#define ALT_R 0x1b2
742#define ALT_S 0x1b3
743#define ALT_T 0x1b4
744#define ALT_U 0x1b5
745#define ALT_V 0x1b6
746#define ALT_W 0x1b7
747#define ALT_X 0x1b8
748#define ALT_Y 0x1b9
749#define ALT_Z 0x1ba
750
751#define CTL_LEFT 0x1bb /* Control-Left-Arrow */
752#define CTL_RIGHT 0x1bc
753#define CTL_PGUP 0x1bd
754#define CTL_PGDN 0x1be
755#define CTL_HOME 0x1bf
756#define CTL_END 0x1c0
757
758#define KEY_A1 0x1c1 /* upper left on Virtual keypad */
759#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */
760#define KEY_A3 0x1c3 /* upper right on Vir. keypad */
761#define KEY_B1 0x1c4 /* middle left on Virt. keypad */
762#define KEY_B2 0x1c5 /* center on Virt. keypad */
763#define KEY_B3 0x1c6 /* middle right on Vir. keypad */
764#define KEY_C1 0x1c7 /* lower left on Virt. keypad */
765#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */
766#define KEY_C3 0x1c9 /* lower right on Vir. keypad */
767
768#define PADSLASH 0x1ca /* slash on keypad */
769#define PADENTER 0x1cb /* enter on keypad */
770#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */
771#define ALT_PADENTER 0x1cd /* alt-enter on keypad */
772#define PADSTOP 0x1ce /* stop on keypad */
773#define PADSTAR 0x1cf /* star on keypad */
774#define PADMINUS 0x1d0 /* minus on keypad */
775#define PADPLUS 0x1d1 /* plus on keypad */
776#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */
777#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */
778#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */
779#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */
780#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */
781#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */
782#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */
783#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */
784#define ALT_PADSLASH 0x1da /* alt-slash on keypad */
785#define ALT_PADSTAR 0x1db /* alt-star on keypad */
786#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */
787#define CTL_INS 0x1dd /* ctl-insert */
788#define ALT_DEL 0x1de /* alt-delete */
789#define ALT_INS 0x1df /* alt-insert */
790#define CTL_UP 0x1e0 /* ctl-up arrow */
791#define CTL_DOWN 0x1e1 /* ctl-down arrow */
792#define CTL_TAB 0x1e2 /* ctl-tab */
793#define ALT_TAB 0x1e3
794#define ALT_MINUS 0x1e4
795#define ALT_EQUAL 0x1e5
796#define ALT_HOME 0x1e6
797#define ALT_PGUP 0x1e7
798#define ALT_PGDN 0x1e8
799#define ALT_END 0x1e9
800#define ALT_UP 0x1ea /* alt-up arrow */
801#define ALT_DOWN 0x1eb /* alt-down arrow */
802#define ALT_RIGHT 0x1ec /* alt-right arrow */
803#define ALT_LEFT 0x1ed /* alt-left arrow */
804#define ALT_ENTER 0x1ee /* alt-enter */
805#define ALT_ESC 0x1ef /* alt-escape */
806#define ALT_BQUOTE 0x1f0 /* alt-back quote */
807#define ALT_LBRACKET 0x1f1 /* alt-left bracket */
808#define ALT_RBRACKET 0x1f2 /* alt-right bracket */
809#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */
810#define ALT_FQUOTE 0x1f4 /* alt-forward quote */
811#define ALT_COMMA 0x1f5 /* alt-comma */
812#define ALT_STOP 0x1f6 /* alt-stop */
813#define ALT_FSLASH 0x1f7 /* alt-forward slash */
814#define ALT_BKSP 0x1f8 /* alt-backspace */
815#define CTL_BKSP 0x1f9 /* ctl-backspace */
816#define PAD0 0x1fa /* keypad 0 */
817
818#define CTL_PAD0 0x1fb /* ctl-keypad 0 */
819#define CTL_PAD1 0x1fc
820#define CTL_PAD2 0x1fd
821#define CTL_PAD3 0x1fe
822#define CTL_PAD4 0x1ff
823#define CTL_PAD5 0x200
824#define CTL_PAD6 0x201
825#define CTL_PAD7 0x202
826#define CTL_PAD8 0x203
827#define CTL_PAD9 0x204
828
829#define ALT_PAD0 0x205 /* alt-keypad 0 */
830#define ALT_PAD1 0x206
831#define ALT_PAD2 0x207
832#define ALT_PAD3 0x208
833#define ALT_PAD4 0x209
834#define ALT_PAD5 0x20a
835#define ALT_PAD6 0x20b
836#define ALT_PAD7 0x20c
837#define ALT_PAD8 0x20d
838#define ALT_PAD9 0x20e
839
840#define CTL_DEL 0x20f /* clt-delete */
841#define ALT_BSLASH 0x210 /* alt-back slash */
842#define CTL_ENTER 0x211 /* ctl-enter */
843
844#define SHF_PADENTER 0x212 /* shift-enter on keypad */
845#define SHF_PADSLASH 0x213 /* shift-slash on keypad */
846#define SHF_PADSTAR 0x214 /* shift-star on keypad */
847#define SHF_PADPLUS 0x215 /* shift-plus on keypad */
848#define SHF_PADMINUS 0x216 /* shift-minus on keypad */
849#define SHF_UP 0x217 /* shift-up on keypad */
850#define SHF_DOWN 0x218 /* shift-down on keypad */
851#define SHF_IC 0x219 /* shift-insert on keypad */
852#define SHF_DC 0x21a /* shift-delete on keypad */
853
854#define KEY_MOUSE 0x21b /* "mouse" key */
855#define KEY_SHIFT_L 0x21c /* Left-shift */
856#define KEY_SHIFT_R 0x21d /* Right-shift */
857#define KEY_CONTROL_L 0x21e /* Left-control */
858#define KEY_CONTROL_R 0x21f /* Right-control */
859#define KEY_ALT_L 0x220 /* Left-alt */
860#define KEY_ALT_R 0x221 /* Right-alt */
861#define KEY_RESIZE 0x222 /* Window resize */
862#define KEY_SUP 0x223 /* Shifted up arrow */
863#define KEY_SDOWN 0x224 /* Shifted down arrow */
864
865#define KEY_MIN KEY_BREAK /* Minimum curses key value */
866#define KEY_MAX KEY_SDOWN /* Maximum curses key */
867
868#define KEY_F(n) (KEY_F0 + (n))
869
870/*----------------------------------------------------------------------
871 *
872 * Functions
873 *
874 */
875
876/* Standard */
877
878PDCEX int addch(const chtype);
879PDCEX int addchnstr(const chtype *, int);
880PDCEX int addchstr(const chtype *);
881PDCEX int addnstr(const char *, int);
882PDCEX int addstr(const char *);
883PDCEX int attroff(chtype);
884PDCEX int attron(chtype);
885PDCEX int attrset(chtype);
886PDCEX int attr_get(attr_t *, short *, void *);
887PDCEX int attr_off(attr_t, void *);
888PDCEX int attr_on(attr_t, void *);
889PDCEX int attr_set(attr_t, short, void *);
890PDCEX int baudrate(void);
891PDCEX int beep(void);
892PDCEX int bkgd(chtype);
893PDCEX void bkgdset(chtype);
894PDCEX int border(chtype, chtype, chtype, chtype,
895 chtype, chtype, chtype, chtype);
896PDCEX int box(WINDOW *, chtype, chtype);
897PDCEX bool can_change_color(void);
898PDCEX int cbreak(void);
899PDCEX int chgat(int, attr_t, short, const void *);
900PDCEX int clearok(WINDOW *, bool);
901PDCEX int clear(void);
902PDCEX int clrtobot(void);
903PDCEX int clrtoeol(void);
904PDCEX int color_content(short, short *, short *, short *);
905PDCEX int color_set(short, void *);
906PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int,
907 int, int, int, int);
908PDCEX int curs_set(int);
909PDCEX int def_prog_mode(void);
910PDCEX int def_shell_mode(void);
911PDCEX int delay_output(int);
912PDCEX int delch(void);
913PDCEX int deleteln(void);
914PDCEX void delscreen(SCREEN *);
915PDCEX int delwin(WINDOW *);
916PDCEX WINDOW *derwin(WINDOW *, int, int, int, int);
917PDCEX int doupdate(void);
918PDCEX WINDOW *dupwin(WINDOW *);
919PDCEX int echochar(const chtype);
920PDCEX int echo(void);
921PDCEX int endwin(void);
922PDCEX char erasechar(void);
923PDCEX int erase(void);
924PDCEX void filter(void);
925PDCEX int flash(void);
926PDCEX int flushinp(void);
927PDCEX chtype getbkgd(WINDOW *);
928PDCEX int getnstr(char *, int);
929PDCEX int getstr(char *);
930PDCEX WINDOW *getwin(FILE *);
931PDCEX int halfdelay(int);
932PDCEX bool has_colors(void);
933PDCEX bool has_ic(void);
934PDCEX bool has_il(void);
935PDCEX int hline(chtype, int);
936PDCEX void idcok(WINDOW *, bool);
937PDCEX int idlok(WINDOW *, bool);
938PDCEX void immedok(WINDOW *, bool);
939PDCEX int inchnstr(chtype *, int);
940PDCEX int inchstr(chtype *);
941PDCEX chtype inch(void);
942PDCEX int init_color(short, short, short, short);
943PDCEX int init_pair(short, short, short);
944PDCEX WINDOW *initscr(void);
945PDCEX int innstr(char *, int);
946PDCEX int insch(chtype);
947PDCEX int insdelln(int);
948PDCEX int insertln(void);
949PDCEX int insnstr(const char *, int);
950PDCEX int insstr(const char *);
951PDCEX int instr(char *);
952PDCEX int intrflush(WINDOW *, bool);
953PDCEX bool isendwin(void);
954PDCEX bool is_linetouched(WINDOW *, int);
955PDCEX bool is_wintouched(WINDOW *);
956PDCEX char *keyname(int);
957PDCEX int keypad(WINDOW *, bool);
958PDCEX char killchar(void);
959PDCEX int leaveok(WINDOW *, bool);
960PDCEX char *longname(void);
961PDCEX int meta(WINDOW *, bool);
962PDCEX int move(int, int);
963PDCEX int mvaddch(int, int, const chtype);
964PDCEX int mvaddchnstr(int, int, const chtype *, int);
965PDCEX int mvaddchstr(int, int, const chtype *);
966PDCEX int mvaddnstr(int, int, const char *, int);
967PDCEX int mvaddstr(int, int, const char *);
968PDCEX int mvchgat(int, int, int, attr_t, short, const void *);
969PDCEX int mvcur(int, int, int, int);
970PDCEX int mvdelch(int, int);
971PDCEX int mvderwin(WINDOW *, int, int);
972PDCEX int mvgetch(int, int);
973PDCEX int mvgetnstr(int, int, char *, int);
974PDCEX int mvgetstr(int, int, char *);
975PDCEX int mvhline(int, int, chtype, int);
976PDCEX chtype mvinch(int, int);
977PDCEX int mvinchnstr(int, int, chtype *, int);
978PDCEX int mvinchstr(int, int, chtype *);
979PDCEX int mvinnstr(int, int, char *, int);
980PDCEX int mvinsch(int, int, chtype);
981PDCEX int mvinsnstr(int, int, const char *, int);
982PDCEX int mvinsstr(int, int, const char *);
983PDCEX int mvinstr(int, int, char *);
984PDCEX int mvprintw(int, int, const char *, ...);
985PDCEX int mvscanw(int, int, const char *, ...);
986PDCEX int mvvline(int, int, chtype, int);
987PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
988PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *);
989PDCEX int mvwaddch(WINDOW *, int, int, const chtype);
990PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int);
991PDCEX int mvwaddstr(WINDOW *, int, int, const char *);
992PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
993PDCEX int mvwdelch(WINDOW *, int, int);
994PDCEX int mvwgetch(WINDOW *, int, int);
995PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int);
996PDCEX int mvwgetstr(WINDOW *, int, int, char *);
997PDCEX int mvwhline(WINDOW *, int, int, chtype, int);
998PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int);
999PDCEX int mvwinchstr(WINDOW *, int, int, chtype *);
1000PDCEX chtype mvwinch(WINDOW *, int, int);
1001PDCEX int mvwinnstr(WINDOW *, int, int, char *, int);
1002PDCEX int mvwinsch(WINDOW *, int, int, chtype);
1003PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int);
1004PDCEX int mvwinsstr(WINDOW *, int, int, const char *);
1005PDCEX int mvwinstr(WINDOW *, int, int, char *);
1006PDCEX int mvwin(WINDOW *, int, int);
1007PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...);
1008PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...);
1009PDCEX int mvwvline(WINDOW *, int, int, chtype, int);
1010PDCEX int napms(int);
1011PDCEX WINDOW *newpad(int, int);
1012PDCEX SCREEN *newterm(const char *, FILE *, FILE *);
1013PDCEX WINDOW *newwin(int, int, int, int);
1014PDCEX int nl(void);
1015PDCEX int nocbreak(void);
1016PDCEX int nodelay(WINDOW *, bool);
1017PDCEX int noecho(void);
1018PDCEX int nonl(void);
1019PDCEX void noqiflush(void);
1020PDCEX int noraw(void);
1021PDCEX int notimeout(WINDOW *, bool);
1022PDCEX int overlay(const WINDOW *, WINDOW *);
1023PDCEX int overwrite(const WINDOW *, WINDOW *);
1024PDCEX int pair_content(short, short *, short *);
1025PDCEX int pechochar(WINDOW *, chtype);
1026PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
1027PDCEX int prefresh(WINDOW *, int, int, int, int, int, int);
1028PDCEX int printw(const char *, ...);
1029PDCEX int putwin(WINDOW *, FILE *);
1030PDCEX void qiflush(void);
1031PDCEX int raw(void);
1032PDCEX int redrawwin(WINDOW *);
1033PDCEX int refresh(void);
1034PDCEX int reset_prog_mode(void);
1035PDCEX int reset_shell_mode(void);
1036PDCEX int resetty(void);
1037PDCEX int ripoffline(int, int (*)(WINDOW *, int));
1038PDCEX int savetty(void);
1039PDCEX int scanw(const char *, ...);
1040PDCEX int scr_dump(const char *);
1041PDCEX int scr_init(const char *);
1042PDCEX int scr_restore(const char *);
1043PDCEX int scr_set(const char *);
1044PDCEX int scrl(int);
1045PDCEX int scroll(WINDOW *);
1046PDCEX int scrollok(WINDOW *, bool);
1047PDCEX SCREEN *set_term(SCREEN *);
1048PDCEX int setscrreg(int, int);
1049PDCEX int slk_attroff(const chtype);
1050PDCEX int slk_attr_off(const attr_t, void *);
1051PDCEX int slk_attron(const chtype);
1052PDCEX int slk_attr_on(const attr_t, void *);
1053PDCEX int slk_attrset(const chtype);
1054PDCEX int slk_attr_set(const attr_t, short, void *);
1055PDCEX int slk_clear(void);
1056PDCEX int slk_color(short);
1057PDCEX int slk_init(int);
1058PDCEX char *slk_label(int);
1059PDCEX int slk_noutrefresh(void);
1060PDCEX int slk_refresh(void);
1061PDCEX int slk_restore(void);
1062PDCEX int slk_set(int, const char *, int);
1063PDCEX int slk_touch(void);
1064PDCEX int standend(void);
1065PDCEX int standout(void);
1066PDCEX int start_color(void);
1067PDCEX WINDOW *subpad(WINDOW *, int, int, int, int);
1068PDCEX WINDOW *subwin(WINDOW *, int, int, int, int);
1069PDCEX int syncok(WINDOW *, bool);
1070PDCEX chtype termattrs(void);
1071PDCEX attr_t term_attrs(void);
1072PDCEX char *termname(void);
1073PDCEX void timeout(int);
1074PDCEX int touchline(WINDOW *, int, int);
1075PDCEX int touchwin(WINDOW *);
1076PDCEX int typeahead(int);
1077PDCEX int untouchwin(WINDOW *);
1078PDCEX void use_env(bool);
1079PDCEX int vidattr(chtype);
1080PDCEX int vid_attr(attr_t, short, void *);
1081PDCEX int vidputs(chtype, int (*)(int));
1082PDCEX int vid_puts(attr_t, short, void *, int (*)(int));
1083PDCEX int vline(chtype, int);
1084PDCEX int vw_printw(WINDOW *, const char *, va_list);
1085PDCEX int vwprintw(WINDOW *, const char *, va_list);
1086PDCEX int vw_scanw(WINDOW *, const char *, va_list);
1087PDCEX int vwscanw(WINDOW *, const char *, va_list);
1088PDCEX int waddchnstr(WINDOW *, const chtype *, int);
1089PDCEX int waddchstr(WINDOW *, const chtype *);
1090PDCEX int waddch(WINDOW *, const chtype);
1091PDCEX int waddnstr(WINDOW *, const char *, int);
1092PDCEX int waddstr(WINDOW *, const char *);
1093PDCEX int wattroff(WINDOW *, chtype);
1094PDCEX int wattron(WINDOW *, chtype);
1095PDCEX int wattrset(WINDOW *, chtype);
1096PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *);
1097PDCEX int wattr_off(WINDOW *, attr_t, void *);
1098PDCEX int wattr_on(WINDOW *, attr_t, void *);
1099PDCEX int wattr_set(WINDOW *, attr_t, short, void *);
1100PDCEX void wbkgdset(WINDOW *, chtype);
1101PDCEX int wbkgd(WINDOW *, chtype);
1102PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype,
1103 chtype, chtype, chtype, chtype);
1104PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *);
1105PDCEX int wclear(WINDOW *);
1106PDCEX int wclrtobot(WINDOW *);
1107PDCEX int wclrtoeol(WINDOW *);
1108PDCEX int wcolor_set(WINDOW *, short, void *);
1109PDCEX void wcursyncup(WINDOW *);
1110PDCEX int wdelch(WINDOW *);
1111PDCEX int wdeleteln(WINDOW *);
1112PDCEX int wechochar(WINDOW *, const chtype);
1113PDCEX int werase(WINDOW *);
1114PDCEX int wgetch(WINDOW *);
1115PDCEX int wgetnstr(WINDOW *, char *, int);
1116PDCEX int wgetstr(WINDOW *, char *);
1117PDCEX int whline(WINDOW *, chtype, int);
1118PDCEX int winchnstr(WINDOW *, chtype *, int);
1119PDCEX int winchstr(WINDOW *, chtype *);
1120PDCEX chtype winch(WINDOW *);
1121PDCEX int winnstr(WINDOW *, char *, int);
1122PDCEX int winsch(WINDOW *, chtype);
1123PDCEX int winsdelln(WINDOW *, int);
1124PDCEX int winsertln(WINDOW *);
1125PDCEX int winsnstr(WINDOW *, const char *, int);
1126PDCEX int winsstr(WINDOW *, const char *);
1127PDCEX int winstr(WINDOW *, char *);
1128PDCEX int wmove(WINDOW *, int, int);
1129PDCEX int wnoutrefresh(WINDOW *);
1130PDCEX int wprintw(WINDOW *, const char *, ...);
1131PDCEX int wredrawln(WINDOW *, int, int);
1132PDCEX int wrefresh(WINDOW *);
1133PDCEX int wscanw(WINDOW *, const char *, ...);
1134PDCEX int wscrl(WINDOW *, int);
1135PDCEX int wsetscrreg(WINDOW *, int, int);
1136PDCEX int wstandend(WINDOW *);
1137PDCEX int wstandout(WINDOW *);
1138PDCEX void wsyncdown(WINDOW *);
1139PDCEX void wsyncup(WINDOW *);
1140PDCEX void wtimeout(WINDOW *, int);
1141PDCEX int wtouchln(WINDOW *, int, int, int);
1142PDCEX int wvline(WINDOW *, chtype, int);
1143
1144/* Wide-character functions */
1145
1146#ifdef PDC_WIDE
1147PDCEX int addnwstr(const wchar_t *, int);
1148PDCEX int addwstr(const wchar_t *);
1149PDCEX int add_wch(const cchar_t *);
1150PDCEX int add_wchnstr(const cchar_t *, int);
1151PDCEX int add_wchstr(const cchar_t *);
1152PDCEX int bkgrnd(const cchar_t *);
1153PDCEX void bkgrndset(const cchar_t *);
1154PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *,
1155 const cchar_t *, const cchar_t *, const cchar_t *,
1156 const cchar_t *, const cchar_t *);
1157PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *);
1158PDCEX int echo_wchar(const cchar_t *);
1159PDCEX int erasewchar(wchar_t *);
1160PDCEX int getbkgrnd(cchar_t *);
1161PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
1162PDCEX int getn_wstr(wint_t *, int);
1163PDCEX int get_wch(wint_t *);
1164PDCEX int get_wstr(wint_t *);
1165PDCEX int hline_set(const cchar_t *, int);
1166PDCEX int innwstr(wchar_t *, int);
1167PDCEX int ins_nwstr(const wchar_t *, int);
1168PDCEX int ins_wch(const cchar_t *);
1169PDCEX int ins_wstr(const wchar_t *);
1170PDCEX int inwstr(wchar_t *);
1171PDCEX int in_wch(cchar_t *);
1172PDCEX int in_wchnstr(cchar_t *, int);
1173PDCEX int in_wchstr(cchar_t *);
1174PDCEX char *key_name(wchar_t);
1175PDCEX int killwchar(wchar_t *);
1176PDCEX int mvaddnwstr(int, int, const wchar_t *, int);
1177PDCEX int mvaddwstr(int, int, const wchar_t *);
1178PDCEX int mvadd_wch(int, int, const cchar_t *);
1179PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int);
1180PDCEX int mvadd_wchstr(int, int, const cchar_t *);
1181PDCEX int mvgetn_wstr(int, int, wint_t *, int);
1182PDCEX int mvget_wch(int, int, wint_t *);
1183PDCEX int mvget_wstr(int, int, wint_t *);
1184PDCEX int mvhline_set(int, int, const cchar_t *, int);
1185PDCEX int mvinnwstr(int, int, wchar_t *, int);
1186PDCEX int mvins_nwstr(int, int, const wchar_t *, int);
1187PDCEX int mvins_wch(int, int, const cchar_t *);
1188PDCEX int mvins_wstr(int, int, const wchar_t *);
1189PDCEX int mvinwstr(int, int, wchar_t *);
1190PDCEX int mvin_wch(int, int, cchar_t *);
1191PDCEX int mvin_wchnstr(int, int, cchar_t *, int);
1192PDCEX int mvin_wchstr(int, int, cchar_t *);
1193PDCEX int mvvline_set(int, int, const cchar_t *, int);
1194PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
1195PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
1196PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
1197PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
1198PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
1199PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
1200PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *);
1201PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *);
1202PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
1203PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
1204PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
1205PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *);
1206PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
1207PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *);
1208PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
1209PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
1210PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *);
1211PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
1212PDCEX int pecho_wchar(WINDOW *, const cchar_t*);
1213PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t,
1214 short, const void*);
1215PDCEX int slk_wset(int, const wchar_t *, int);
1216PDCEX int unget_wch(const wchar_t);
1217PDCEX int vline_set(const cchar_t *, int);
1218PDCEX int waddnwstr(WINDOW *, const wchar_t *, int);
1219PDCEX int waddwstr(WINDOW *, const wchar_t *);
1220PDCEX int wadd_wch(WINDOW *, const cchar_t *);
1221PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int);
1222PDCEX int wadd_wchstr(WINDOW *, const cchar_t *);
1223PDCEX int wbkgrnd(WINDOW *, const cchar_t *);
1224PDCEX void wbkgrndset(WINDOW *, const cchar_t *);
1225PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *,
1226 const cchar_t *, const cchar_t *, const cchar_t *,
1227 const cchar_t *, const cchar_t *, const cchar_t *);
1228PDCEX int wecho_wchar(WINDOW *, const cchar_t *);
1229PDCEX int wgetbkgrnd(WINDOW *, cchar_t *);
1230PDCEX int wgetn_wstr(WINDOW *, wint_t *, int);
1231PDCEX int wget_wch(WINDOW *, wint_t *);
1232PDCEX int wget_wstr(WINDOW *, wint_t *);
1233PDCEX int whline_set(WINDOW *, const cchar_t *, int);
1234PDCEX int winnwstr(WINDOW *, wchar_t *, int);
1235PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int);
1236PDCEX int wins_wch(WINDOW *, const cchar_t *);
1237PDCEX int wins_wstr(WINDOW *, const wchar_t *);
1238PDCEX int winwstr(WINDOW *, wchar_t *);
1239PDCEX int win_wch(WINDOW *, cchar_t *);
1240PDCEX int win_wchnstr(WINDOW *, cchar_t *, int);
1241PDCEX int win_wchstr(WINDOW *, cchar_t *);
1242PDCEX wchar_t *wunctrl(cchar_t *);
1243PDCEX int wvline_set(WINDOW *, const cchar_t *, int);
1244#endif
1245
1246/* Quasi-standard */
1247
1248PDCEX chtype getattrs(WINDOW *);
1249PDCEX int getbegx(WINDOW *);
1250PDCEX int getbegy(WINDOW *);
1251PDCEX int getmaxx(WINDOW *);
1252PDCEX int getmaxy(WINDOW *);
1253PDCEX int getparx(WINDOW *);
1254PDCEX int getpary(WINDOW *);
1255PDCEX int getcurx(WINDOW *);
1256PDCEX int getcury(WINDOW *);
1257PDCEX void traceoff(void);
1258PDCEX void traceon(void);
1259PDCEX char *unctrl(chtype);
1260
1261PDCEX int crmode(void);
1262PDCEX int nocrmode(void);
1263PDCEX int draino(int);
1264PDCEX int resetterm(void);
1265PDCEX int fixterm(void);
1266PDCEX int saveterm(void);
1267PDCEX void setsyx(int, int);
1268
1269PDCEX int mouse_set(mmask_t);
1270PDCEX int mouse_on(mmask_t);
1271PDCEX int mouse_off(mmask_t);
1272PDCEX int request_mouse_pos(void);
1273PDCEX void wmouse_position(WINDOW *, int *, int *);
1274PDCEX mmask_t getmouse(void);
1275
1276/* ncurses */
1277
1278PDCEX int assume_default_colors(int, int);
1279PDCEX const char *curses_version(void);
1280PDCEX bool has_key(int);
1281PDCEX bool is_keypad(const WINDOW *);
1282PDCEX bool is_leaveok(const WINDOW *);
1283PDCEX bool is_pad(const WINDOW *);
1284PDCEX int set_tabsize(int);
1285PDCEX int use_default_colors(void);
1286PDCEX int wresize(WINDOW *, int, int);
1287
1288PDCEX bool has_mouse(void);
1289PDCEX int mouseinterval(int);
1290PDCEX mmask_t mousemask(mmask_t, mmask_t *);
1291PDCEX bool mouse_trafo(int *, int *, bool);
1292PDCEX int nc_getmouse(MEVENT *);
1293PDCEX int ungetmouse(MEVENT *);
1294PDCEX bool wenclose(const WINDOW *, int, int);
1295PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool);
1296
1297/* PDCurses */
1298
1299PDCEX int addrawch(chtype);
1300PDCEX int insrawch(chtype);
1301PDCEX bool is_termresized(void);
1302PDCEX int mvaddrawch(int, int, chtype);
1303PDCEX int mvdeleteln(int, int);
1304PDCEX int mvinsertln(int, int);
1305PDCEX int mvinsrawch(int, int, chtype);
1306PDCEX int mvwaddrawch(WINDOW *, int, int, chtype);
1307PDCEX int mvwdeleteln(WINDOW *, int, int);
1308PDCEX int mvwinsertln(WINDOW *, int, int);
1309PDCEX int mvwinsrawch(WINDOW *, int, int, chtype);
1310PDCEX int raw_output(bool);
1311PDCEX int resize_term(int, int);
1312PDCEX WINDOW *resize_window(WINDOW *, int, int);
1313PDCEX int waddrawch(WINDOW *, chtype);
1314PDCEX int winsrawch(WINDOW *, chtype);
1315PDCEX char wordchar(void);
1316
1317#ifdef PDC_WIDE
1318PDCEX wchar_t *slk_wlabel(int);
1319#endif
1320
1321PDCEX void PDC_debug(const char *, ...);
1322PDCEX void PDC_get_version(PDC_VERSION *);
1323PDCEX int PDC_ungetch(int);
1324PDCEX int PDC_set_blink(bool);
1325PDCEX int PDC_set_bold(bool);
1326PDCEX int PDC_set_line_color(short);
1327PDCEX void PDC_set_title(const char *);
1328
1329PDCEX int PDC_clearclipboard(void);
1330PDCEX int PDC_freeclipboard(char *);
1331PDCEX int PDC_getclipboard(char **, long *);
1332PDCEX int PDC_setclipboard(const char *, long);
1333
1334PDCEX unsigned long PDC_get_input_fd(void);
1335PDCEX unsigned long PDC_get_key_modifiers(void);
1336PDCEX int PDC_return_key_modifiers(bool);
1337
1338#ifdef XCURSES
1339PDCEX WINDOW *Xinitscr(int, char **);
1340PDCEX void XCursesExit(void);
1341PDCEX int sb_init(void);
1342PDCEX int sb_set_horz(int, int, int);
1343PDCEX int sb_set_vert(int, int, int);
1344PDCEX int sb_get_horz(int *, int *, int *);
1345PDCEX int sb_get_vert(int *, int *, int *);
1346PDCEX int sb_refresh(void);
1347#endif
1348
1349/* NetBSD */
1350
1351PDCEX int touchoverlap(const WINDOW *, WINDOW *);
1352PDCEX int underend(void);
1353PDCEX int underscore(void);
1354PDCEX int wunderend(WINDOW *);
1355PDCEX int wunderscore(WINDOW *);
1356
1357/*** Functions defined as macros ***/
1358
1359/* getch() and ungetch() conflict with some DOS libraries */
1360
1361#define getch() wgetch(stdscr)
1362#define ungetch(ch) PDC_ungetch(ch)
1363
1364#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR)
1365#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT)
1366
1367/* These will _only_ work as macros */
1368
1369#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w))
1370#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w))
1371#define getparyx(w, y, x) (y = getpary(w), x = getparx(w))
1372#define getyx(w, y, x) (y = getcury(w), x = getcurx(w))
1373
1374#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \
1375 else getyx(curscr,(y),(x)); }
1376
1377#ifdef NCURSES_MOUSE_VERSION
1378# define getmouse(x) nc_getmouse(x)
1379#endif
1380
1381/* Deprecated */
1382
1383#define PDC_save_key_modifiers(x) (OK)
1384
1385/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */
1386
1387#define PDC_CLIP_SUCCESS 0
1388#define PDC_CLIP_ACCESS_ERROR 1
1389#define PDC_CLIP_EMPTY 2
1390#define PDC_CLIP_MEMORY_ERROR 3
1391
1392/* PDCurses key modifier masks */
1393
1394#define PDC_KEY_MODIFIER_SHIFT 1
1395#define PDC_KEY_MODIFIER_CONTROL 2
1396#define PDC_KEY_MODIFIER_ALT 4
1397#define PDC_KEY_MODIFIER_NUMLOCK 8
1398
1399#ifdef __cplusplus
1400# ifndef PDC_PP98
1401# undef bool
1402# endif
1403}
1404#endif
1405
1406#endif /* __PDCURSES__ */
diff --git a/scripts/kconfig/libcurses/curspriv.h b/scripts/kconfig/libcurses/curspriv.h
new file mode 100644
index 000000000..8bb712a8e
--- /dev/null
+++ b/scripts/kconfig/libcurses/curspriv.h
@@ -0,0 +1,119 @@
1/* Private definitions and declarations for use within PDCurses.
2 These should generally not be referenced by applications. */
3
4#ifndef __CURSES_INTERNALS__
5#define __CURSES_INTERNALS__ 1
6
7#define CURSES_LIBRARY
8#include "curses.h"
9
10#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
11 defined(PDC_99) || defined(__WATCOMC__)
12# ifndef HAVE_VSSCANF
13# define HAVE_VSSCANF /* have vsscanf() */
14# endif
15#endif
16
17#if defined(PDC_99) || defined(__WATCOMC__)
18# ifndef HAVE_VSNPRINTF
19# define HAVE_VSNPRINTF /* have vsnprintf() */
20# endif
21#endif
22
23/*----------------------------------------------------------------------*/
24
25typedef struct /* structure for ripped off lines */
26{
27 int line;
28 int (*init)(WINDOW *, int);
29} RIPPEDOFFLINE;
30
31/* Window properties */
32
33#define _SUBWIN 0x01 /* window is a subwindow */
34#define _PAD 0x10 /* X/Open Pad. */
35#define _SUBPAD 0x20 /* X/Open subpad. */
36
37/* Miscellaneous */
38
39#define _NO_CHANGE -1 /* flags line edge unchanged */
40
41#define _ECHAR 0x08 /* Erase char (^H) */
42#define _DWCHAR 0x17 /* Delete Word char (^W) */
43#define _DLCHAR 0x15 /* Delete Line char (^U) */
44
45/*----------------------------------------------------------------------*/
46
47/* Platform implementation functions */
48
49void PDC_beep(void);
50bool PDC_can_change_color(void);
51int PDC_color_content(short, short *, short *, short *);
52bool PDC_check_key(void);
53int PDC_curs_set(int);
54void PDC_flushinp(void);
55int PDC_get_columns(void);
56int PDC_get_cursor_mode(void);
57int PDC_get_key(void);
58int PDC_get_rows(void);
59void PDC_gotoyx(int, int);
60bool PDC_has_mouse(void);
61int PDC_init_color(short, short, short, short);
62void PDC_init_pair(short, short, short);
63int PDC_modifiers_set(void);
64int PDC_mouse_set(void);
65void PDC_napms(int);
66int PDC_pair_content(short, short *, short *);
67void PDC_reset_prog_mode(void);
68void PDC_reset_shell_mode(void);
69int PDC_resize_screen(int, int);
70void PDC_restore_screen_mode(int);
71void PDC_save_screen_mode(int);
72void PDC_scr_close(void);
73void PDC_scr_free(void);
74int PDC_scr_open(int, char **);
75void PDC_set_keyboard_binary(bool);
76void PDC_transform_line(int, int, int, const chtype *);
77const char *PDC_sysname(void);
78
79/* Internal cross-module functions */
80
81void PDC_init_atrtab(void);
82WINDOW *PDC_makelines(WINDOW *);
83WINDOW *PDC_makenew(int, int, int, int);
84int PDC_mouse_in_slk(int, int);
85void PDC_slk_free(void);
86void PDC_slk_initialize(void);
87void PDC_sync(WINDOW *);
88
89#ifdef PDC_WIDE
90int PDC_mbtowc(wchar_t *, const char *, size_t);
91size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
92size_t PDC_wcstombs(char *, const wchar_t *, size_t);
93#endif
94
95#ifdef PDCDEBUG
96# define PDC_LOG(x) if (SP && SP->dbfp) PDC_debug x
97#else
98# define PDC_LOG(x)
99#endif
100
101/* Internal macros for attributes */
102
103#define PDC_COLOR_PAIRS 256
104
105#ifndef max
106# define max(a,b) (((a) > (b)) ? (a) : (b))
107#endif
108#ifndef min
109# define min(a,b) (((a) < (b)) ? (a) : (b))
110#endif
111
112#define DIVROUND(num, divisor) ((num) + ((divisor) >> 1)) / (divisor)
113
114#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if
115 not set by mouseinterval() */
116
117#define PDC_MAXCOL 768 /* maximum possible COLORS; may be less */
118
119#endif /* __CURSES_INTERNALS__ */
diff --git a/scripts/kconfig/libcurses/getch.c b/scripts/kconfig/libcurses/getch.c
new file mode 100644
index 000000000..fa0c674b5
--- /dev/null
+++ b/scripts/kconfig/libcurses/getch.c
@@ -0,0 +1,587 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7getch
8-----
9
10### Synopsis
11
12 int getch(void);
13 int wgetch(WINDOW *win);
14 int mvgetch(int y, int x);
15 int mvwgetch(WINDOW *win, int y, int x);
16 int ungetch(int ch);
17 int flushinp(void);
18
19 int get_wch(wint_t *wch);
20 int wget_wch(WINDOW *win, wint_t *wch);
21 int mvget_wch(int y, int x, wint_t *wch);
22 int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
23 int unget_wch(const wchar_t wch);
24
25 unsigned long PDC_get_key_modifiers(void);
26 int PDC_return_key_modifiers(bool flag);
27
28### Description
29
30 With the getch(), wgetch(), mvgetch(), and mvwgetch() functions, a
31 character is read from the terminal associated with the window. In
32 nodelay mode, if there is no input waiting, the value ERR is
33 returned. In delay mode, the program will hang until the system
34 passes text through to the program. Depending on the setting of
35 cbreak(), this will be after one character or after the first
36 newline. Unless noecho() has been set, the character will also be
37 echoed into the designated window.
38
39 If keypad() is TRUE, and a function key is pressed, the token for
40 that function key will be returned instead of the raw characters.
41 Possible function keys are defined in "curses.h" with integers
42 beginning with 0401, whose names begin with KEY_.
43
44 If nodelay(win, TRUE) has been called on the window and no input is
45 waiting, the value ERR is returned.
46
47 ungetch() places ch back onto the input queue to be returned by the
48 next call to wgetch().
49
50 flushinp() throws away any type-ahead that has been typed by the user
51 and has not yet been read by the program.
52
53 wget_wch() is the wide-character version of wgetch(), available when
54 PDCurses is built with the PDC_WIDE option. It takes a pointer to a
55 wint_t rather than returning the key as an int, and instead returns
56 KEY_CODE_YES if the key is a function key. Otherwise, it returns OK
57 or ERR. It's important to check for KEY_CODE_YES, since regular wide
58 characters can have the same values as function key codes.
59
60 unget_wch() puts a wide character on the input queue.
61
62 PDC_get_key_modifiers() returns the keyboard modifiers (shift,
63 control, alt, numlock) effective at the time of the last getch()
64 call. Use the macros PDC_KEY_MODIFIER_* to determine which
65 modifier(s) were set. PDC_return_key_modifiers() tells getch() to
66 return modifier keys pressed alone as keystrokes (KEY_ALT_L, etc.).
67 These may not work on all platforms.
68
69 NOTE: getch() and ungetch() are implemented as macros, to avoid
70 conflict with many DOS compiler's runtime libraries.
71
72### Return Value
73
74 These functions return ERR or the value of the character, meta
75 character or function key token.
76
77### Portability
78 X/Open ncurses NetBSD
79 getch Y Y Y
80 wgetch Y Y Y
81 mvgetch Y Y Y
82 mvwgetch Y Y Y
83 ungetch Y Y Y
84 flushinp Y Y Y
85 get_wch Y Y Y
86 wget_wch Y Y Y
87 mvget_wch Y Y Y
88 mvwget_wch Y Y Y
89 unget_wch Y Y Y
90 PDC_get_key_modifiers - - -
91
92**man-end****************************************************************/
93
94#include <stdlib.h>
95
96#define _INBUFSIZ 512 /* size of terminal input buffer */
97#define NUNGETCH 256 /* max # chars to ungetch() */
98
99static int c_pindex = 0; /* putter index */
100static int c_gindex = 1; /* getter index */
101static int c_ungind = 0; /* ungetch() push index */
102static int c_ungch[NUNGETCH]; /* array of ungotten chars */
103
104static int _get_box(int *y_start, int *y_end, int *x_start, int *x_end)
105{
106 int start, end;
107
108 if (SP->sel_start < SP->sel_end)
109 {
110 start = SP->sel_start;
111 end = SP->sel_end;
112 }
113 else
114 {
115 start = SP->sel_end;
116 end = SP->sel_start;
117 }
118
119 *y_start = start / COLS;
120 *x_start = start % COLS;
121
122 *y_end = end / COLS;
123 *x_end = end % COLS;
124
125 return (end - start) + (*y_end - *y_start);
126}
127
128static void _highlight(void)
129{
130 int i, j, y_start, y_end, x_start, x_end;
131
132 if (-1 == SP->sel_start)
133 return;
134
135 _get_box(&y_start, &y_end, &x_start, &x_end);
136
137 for (j = y_start; j <= y_end; j++)
138 for (i = (j == y_start ? x_start : 0);
139 i < (j == y_end ? x_end : COLS); i++)
140 curscr->_y[j][i] ^= A_REVERSE;
141
142 wrefresh(curscr);
143}
144
145static void _copy(void)
146{
147#ifdef PDC_WIDE
148 wchar_t *wtmp;
149# define TMP wtmp
150# define MASK A_CHARTEXT
151#else
152# define TMP tmp
153# define MASK 0xff
154#endif
155 char *tmp;
156 long pos;
157 int i, j, y_start, y_end, x_start, x_end, len;
158
159 if (-1 == SP->sel_start)
160 return;
161
162 len = _get_box(&y_start, &y_end, &x_start, &x_end);
163
164 if (!len)
165 return;
166
167#ifdef PDC_WIDE
168 wtmp = malloc((len + 1) * sizeof(wchar_t));
169 len *= 3;
170#endif
171 tmp = malloc(len + 1);
172
173 for (j = y_start, pos = 0; j <= y_end; j++)
174 {
175 for (i = (j == y_start ? x_start : 0);
176 i < (j == y_end ? x_end : COLS); i++)
177 TMP[pos++] = curscr->_y[j][i] & MASK;
178
179 while (y_start != y_end && pos > 0 && TMP[pos - 1] == 32)
180 pos--;
181
182 if (j < y_end)
183 TMP[pos++] = 10;
184 }
185 TMP[pos] = 0;
186
187#ifdef PDC_WIDE
188 pos = PDC_wcstombs(tmp, wtmp, len);
189#endif
190
191 PDC_setclipboard(tmp, pos);
192 free(tmp);
193#ifdef PDC_WIDE
194 free(wtmp);
195#endif
196}
197
198static int _paste(void)
199{
200#ifdef PDC_WIDE
201 wchar_t *wpaste;
202# define PASTE wpaste
203#else
204# define PASTE paste
205#endif
206 char *paste;
207 long len;
208 int key;
209
210 key = PDC_getclipboard(&paste, &len);
211 if (PDC_CLIP_SUCCESS != key || !len)
212 return -1;
213
214#ifdef PDC_WIDE
215 wpaste = malloc(len * sizeof(wchar_t));
216 len = PDC_mbstowcs(wpaste, paste, len);
217#endif
218 while (len > 1)
219 PDC_ungetch(PASTE[--len]);
220 key = *PASTE;
221#ifdef PDC_WIDE
222 free(wpaste);
223#endif
224 PDC_freeclipboard(paste);
225 SP->key_modifiers = 0;
226
227 return key;
228}
229
230static int _mouse_key(void)
231{
232 int i, key = KEY_MOUSE, changes = SP->mouse_status.changes;
233 unsigned long mbe = SP->_trap_mbe;
234
235 /* Selection highlighting? */
236
237 if ((!mbe || SP->mouse_status.button[0] & BUTTON_SHIFT) && changes & 1)
238 {
239 i = SP->mouse_status.y * COLS + SP->mouse_status.x;
240 switch (SP->mouse_status.button[0] & BUTTON_ACTION_MASK)
241 {
242 case BUTTON_PRESSED:
243 _highlight();
244 SP->sel_start = SP->sel_end = i;
245 return -1;
246 case BUTTON_MOVED:
247 _highlight();
248 SP->sel_end = i;
249 _highlight();
250 return -1;
251 case BUTTON_RELEASED:
252 _copy();
253 return -1;
254 }
255 }
256 else if ((!mbe || SP->mouse_status.button[1] & BUTTON_SHIFT) &&
257 changes & 2 && (SP->mouse_status.button[1] &
258 BUTTON_ACTION_MASK) == BUTTON_CLICKED)
259 {
260 SP->key_code = FALSE;
261 return _paste();
262 }
263
264 /* Filter unwanted mouse events */
265
266 for (i = 0; i < 3; i++)
267 {
268 if (changes & (1 << i))
269 {
270 int shf = i * 5;
271 short button = SP->mouse_status.button[i] & BUTTON_ACTION_MASK;
272
273 if ( (!(mbe & (BUTTON1_PRESSED << shf)) &&
274 (button == BUTTON_PRESSED))
275
276 || (!(mbe & (BUTTON1_CLICKED << shf)) &&
277 (button == BUTTON_CLICKED))
278
279 || (!(mbe & (BUTTON1_DOUBLE_CLICKED << shf)) &&
280 (button == BUTTON_DOUBLE_CLICKED))
281
282 || (!(mbe & (BUTTON1_MOVED << shf)) &&
283 (button == BUTTON_MOVED))
284
285 || (!(mbe & (BUTTON1_RELEASED << shf)) &&
286 (button == BUTTON_RELEASED))
287 )
288 SP->mouse_status.changes ^= (1 << i);
289 }
290 }
291
292 if (changes & PDC_MOUSE_MOVED)
293 {
294 if (!(mbe & (BUTTON1_MOVED|BUTTON2_MOVED|BUTTON3_MOVED)))
295 SP->mouse_status.changes ^= PDC_MOUSE_MOVED;
296 }
297
298 if (changes & (PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN))
299 {
300 if (!(mbe & MOUSE_WHEEL_SCROLL))
301 SP->mouse_status.changes &=
302 ~(PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN);
303 }
304
305 if (!changes)
306 return -1;
307
308 /* Check for click in slk area */
309
310 i = PDC_mouse_in_slk(SP->mouse_status.y, SP->mouse_status.x);
311
312 if (i)
313 {
314 if (SP->mouse_status.button[0] & (BUTTON_PRESSED|BUTTON_CLICKED))
315 key = KEY_F(i);
316 else
317 key = -1;
318 }
319
320 return key;
321}
322
323int wgetch(WINDOW *win)
324{
325 static int buffer[_INBUFSIZ]; /* character buffer */
326 int key, waitcount;
327
328 PDC_LOG(("wgetch() - called\n"));
329
330 if (!win || !SP)
331 return ERR;
332
333 waitcount = 0;
334
335 /* set the number of 1/20th second napms() calls */
336
337 if (SP->delaytenths)
338 waitcount = 2 * SP->delaytenths;
339 else
340 if (win->_delayms)
341 {
342 /* Can't really do millisecond intervals, so delay in
343 1/20ths of a second (50ms) */
344
345 waitcount = win->_delayms / 50;
346 if (!waitcount)
347 waitcount = 1;
348 }
349
350 /* refresh window when wgetch is called if there have been changes
351 to it and it is not a pad */
352
353 if (!(win->_flags & _PAD) && ((!win->_leaveit &&
354 (win->_begx + win->_curx != SP->curscol ||
355 win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win)))
356 wrefresh(win);
357
358 /* if ungotten char exists, remove and return it */
359
360 if (c_ungind)
361 return c_ungch[--c_ungind];
362
363 /* if normal and data in buffer */
364
365 if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex))
366 return buffer[c_gindex++];
367
368 /* prepare to buffer data */
369
370 c_pindex = 0;
371 c_gindex = 0;
372
373 /* to get here, no keys are buffered. go and get one. */
374
375 for (;;) /* loop for any buffering */
376 {
377 /* is there a keystroke ready? */
378
379 if (!PDC_check_key())
380 {
381 /* if not, handle timeout() and halfdelay() */
382
383 if (SP->delaytenths || win->_delayms)
384 {
385 if (!waitcount)
386 return ERR;
387
388 waitcount--;
389 }
390 else
391 if (win->_nodelay)
392 return ERR;
393
394 napms(50); /* sleep for 1/20th second */
395 continue; /* then check again */
396 }
397
398 /* if there is, fetch it */
399
400 key = PDC_get_key();
401
402 /* copy or paste? */
403
404 if (SP->key_modifiers & PDC_KEY_MODIFIER_SHIFT)
405 {
406 if (0x03 == key)
407 {
408 _copy();
409 continue;
410 }
411 else if (0x16 == key)
412 key = _paste();
413 }
414
415 /* filter mouse events; translate mouse clicks in the slk
416 area to function keys */
417
418 if (SP->key_code && key == KEY_MOUSE)
419 key = _mouse_key();
420
421 /* filter special keys if not in keypad mode */
422
423 if (SP->key_code && !win->_use_keypad)
424 key = -1;
425
426 /* unwanted key? loop back */
427
428 if (key == -1)
429 continue;
430
431 _highlight();
432 SP->sel_start = SP->sel_end = -1;
433
434 /* translate CR */
435
436 if (key == '\r' && SP->autocr && !SP->raw_inp)
437 key = '\n';
438
439 /* if echo is enabled */
440
441 if (SP->echo && !SP->key_code)
442 {
443 waddch(win, key);
444 wrefresh(win);
445 }
446
447 /* if no buffering */
448
449 if (SP->raw_inp || SP->cbreak)
450 return key;
451
452 /* if no overflow, put data in buffer */
453
454 if (key == '\b')
455 {
456 if (c_pindex > c_gindex)
457 c_pindex--;
458 }
459 else
460 if (c_pindex < _INBUFSIZ - 2)
461 buffer[c_pindex++] = key;
462
463 /* if we got a line */
464
465 if (key == '\n' || key == '\r')
466 return buffer[c_gindex++];
467 }
468}
469
470int mvgetch(int y, int x)
471{
472 PDC_LOG(("mvgetch() - called\n"));
473
474 if (move(y, x) == ERR)
475 return ERR;
476
477 return wgetch(stdscr);
478}
479
480int mvwgetch(WINDOW *win, int y, int x)
481{
482 PDC_LOG(("mvwgetch() - called\n"));
483
484 if (wmove(win, y, x) == ERR)
485 return ERR;
486
487 return wgetch(win);
488}
489
490int PDC_ungetch(int ch)
491{
492 PDC_LOG(("ungetch() - called\n"));
493
494 if (c_ungind >= NUNGETCH) /* pushback stack full */
495 return ERR;
496
497 c_ungch[c_ungind++] = ch;
498
499 return OK;
500}
501
502int flushinp(void)
503{
504 PDC_LOG(("flushinp() - called\n"));
505
506 PDC_flushinp();
507
508 c_gindex = 1; /* set indices to kill buffer */
509 c_pindex = 0;
510 c_ungind = 0; /* clear c_ungch array */
511
512 return OK;
513}
514
515unsigned long PDC_get_key_modifiers(void)
516{
517 PDC_LOG(("PDC_get_key_modifiers() - called\n"));
518
519 if (!SP)
520 return ERR;
521
522 return SP->key_modifiers;
523}
524
525int PDC_return_key_modifiers(bool flag)
526{
527 PDC_LOG(("PDC_return_key_modifiers() - called\n"));
528
529 if (!SP)
530 return ERR;
531
532 SP->return_key_modifiers = flag;
533 return PDC_modifiers_set();
534}
535
536#ifdef PDC_WIDE
537int wget_wch(WINDOW *win, wint_t *wch)
538{
539 int key;
540
541 PDC_LOG(("wget_wch() - called\n"));
542
543 if (!wch)
544 return ERR;
545
546 key = wgetch(win);
547
548 if (key == ERR)
549 return ERR;
550
551 *wch = key;
552
553 return SP->key_code ? KEY_CODE_YES : OK;
554}
555
556int get_wch(wint_t *wch)
557{
558 PDC_LOG(("get_wch() - called\n"));
559
560 return wget_wch(stdscr, wch);
561}
562
563int mvget_wch(int y, int x, wint_t *wch)
564{
565 PDC_LOG(("mvget_wch() - called\n"));
566
567 if (move(y, x) == ERR)
568 return ERR;
569
570 return wget_wch(stdscr, wch);
571}
572
573int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch)
574{
575 PDC_LOG(("mvwget_wch() - called\n"));
576
577 if (wmove(win, y, x) == ERR)
578 return ERR;
579
580 return wget_wch(win, wch);
581}
582
583int unget_wch(const wchar_t wch)
584{
585 return PDC_ungetch(wch);
586}
587#endif
diff --git a/scripts/kconfig/libcurses/getyx.c b/scripts/kconfig/libcurses/getyx.c
new file mode 100644
index 000000000..5f104df99
--- /dev/null
+++ b/scripts/kconfig/libcurses/getyx.c
@@ -0,0 +1,142 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7getyx
8-----
9
10### Synopsis
11
12 void getyx(WINDOW *win, int y, int x);
13 void getparyx(WINDOW *win, int y, int x);
14 void getbegyx(WINDOW *win, int y, int x);
15 void getmaxyx(WINDOW *win, int y, int x);
16
17 void getsyx(int y, int x);
18 void setsyx(int y, int x);
19
20 int getbegy(WINDOW *win);
21 int getbegx(WINDOW *win);
22 int getcury(WINDOW *win);
23 int getcurx(WINDOW *win);
24 int getpary(WINDOW *win);
25 int getparx(WINDOW *win);
26 int getmaxy(WINDOW *win);
27 int getmaxx(WINDOW *win);
28
29### Description
30
31 The getyx() macro (defined in curses.h -- the prototypes here are
32 merely illustrative) puts the current cursor position of the
33 specified window into y and x. getbegyx() and getmaxyx() return the
34 starting coordinates and size of the specified window, respectively.
35 getparyx() returns the starting coordinates of the parent's window,
36 if the specified window is a subwindow; otherwise it sets y and x to
37 -1. These are all macros.
38
39 getsyx() gets the coordinates of the virtual screen cursor, and
40 stores them in y and x. If leaveok() is TRUE, it returns -1, -1. If
41 lines have been removed with ripoffline(), then getsyx() includes
42 these lines in its count; so, the returned y and x values should only
43 be used with setsyx().
44
45 setsyx() sets the virtual screen cursor to the y, x coordinates. If
46 either y or x is -1, leaveok() is set TRUE, else it's set FALSE.
47
48 getsyx() and setsyx() are meant to be used by a library routine that
49 manipulates curses windows without altering the position of the
50 cursor. Note that getsyx() is defined only as a macro.
51
52 getbegy(), getbegx(), getcurx(), getcury(), getmaxy(), getmaxx(),
53 getpary(), and getparx() return the appropriate coordinate or size
54 values, or ERR in the case of a NULL window.
55
56### Portability
57 X/Open ncurses NetBSD
58 getyx Y Y Y
59 getparyx Y Y Y
60 getbegyx Y Y Y
61 getmaxyx Y Y Y
62 getsyx - Y Y
63 setsyx - Y Y
64 getbegy - Y Y
65 getbegx - Y Y
66 getcury - Y Y
67 getcurx - Y Y
68 getpary - Y Y
69 getparx - Y Y
70 getmaxy - Y Y
71 getmaxx - Y Y
72
73**man-end****************************************************************/
74
75int getbegy(WINDOW *win)
76{
77 PDC_LOG(("getbegy() - called\n"));
78
79 return win ? win->_begy : ERR;
80}
81
82int getbegx(WINDOW *win)
83{
84 PDC_LOG(("getbegx() - called\n"));
85
86 return win ? win->_begx : ERR;
87}
88
89int getcury(WINDOW *win)
90{
91 PDC_LOG(("getcury() - called\n"));
92
93 return win ? win->_cury : ERR;
94}
95
96int getcurx(WINDOW *win)
97{
98 PDC_LOG(("getcurx() - called\n"));
99
100 return win ? win->_curx : ERR;
101}
102
103int getpary(WINDOW *win)
104{
105 PDC_LOG(("getpary() - called\n"));
106
107 return win ? win->_pary : ERR;
108}
109
110int getparx(WINDOW *win)
111{
112 PDC_LOG(("getparx() - called\n"));
113
114 return win ? win->_parx : ERR;
115}
116
117int getmaxy(WINDOW *win)
118{
119 PDC_LOG(("getmaxy() - called\n"));
120
121 return win ? win->_maxy : ERR;
122}
123
124int getmaxx(WINDOW *win)
125{
126 PDC_LOG(("getmaxx() - called\n"));
127
128 return win ? win->_maxx : ERR;
129}
130
131void setsyx(int y, int x)
132{
133 PDC_LOG(("setsyx() - called\n"));
134
135 if (curscr)
136 {
137 curscr->_leaveit = y == -1 || x == -1;
138
139 if (!curscr->_leaveit)
140 wmove(curscr, y, x);
141 }
142}
diff --git a/scripts/kconfig/libcurses/inch.c b/scripts/kconfig/libcurses/inch.c
new file mode 100644
index 000000000..2bd4430f6
--- /dev/null
+++ b/scripts/kconfig/libcurses/inch.c
@@ -0,0 +1,126 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7inch
8----
9
10### Synopsis
11
12 chtype inch(void);
13 chtype winch(WINDOW *win);
14 chtype mvinch(int y, int x);
15 chtype mvwinch(WINDOW *win, int y, int x);
16
17 int in_wch(cchar_t *wcval);
18 int win_wch(WINDOW *win, cchar_t *wcval);
19 int mvin_wch(int y, int x, cchar_t *wcval);
20 int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval);
21
22### Description
23
24 The inch() functions retrieve the character and attribute from the
25 current or specified window position, in the form of a chtype. If a
26 NULL window is specified, (chtype)ERR is returned.
27
28 The in_wch() functions are the wide-character versions; instead of
29 returning a chtype, they store a cchar_t at the address specified by
30 wcval, and return OK or ERR. (No value is stored when ERR is
31 returned.) Note that in PDCurses, chtype and cchar_t are the same.
32
33### Portability
34 X/Open ncurses NetBSD
35 inch Y Y Y
36 winch Y Y Y
37 mvinch Y Y Y
38 mvwinch Y Y Y
39 in_wch Y Y Y
40 win_wch Y Y Y
41 mvin_wch Y Y Y
42 mvwin_wch Y Y Y
43
44**man-end****************************************************************/
45
46chtype winch(WINDOW *win)
47{
48 PDC_LOG(("winch() - called\n"));
49
50 if (!win)
51 return (chtype)ERR;
52
53 return win->_y[win->_cury][win->_curx];
54}
55
56chtype inch(void)
57{
58 PDC_LOG(("inch() - called\n"));
59
60 return winch(stdscr);
61}
62
63chtype mvinch(int y, int x)
64{
65 PDC_LOG(("mvinch() - called\n"));
66
67 if (move(y, x) == ERR)
68 return (chtype)ERR;
69
70 return stdscr->_y[stdscr->_cury][stdscr->_curx];
71}
72
73chtype mvwinch(WINDOW *win, int y, int x)
74{
75 PDC_LOG(("mvwinch() - called\n"));
76
77 if (wmove(win, y, x) == ERR)
78 return (chtype)ERR;
79
80 return win->_y[win->_cury][win->_curx];
81}
82
83#ifdef PDC_WIDE
84int win_wch(WINDOW *win, cchar_t *wcval)
85{
86 PDC_LOG(("win_wch() - called\n"));
87
88 if (!win || !wcval)
89 return ERR;
90
91 *wcval = win->_y[win->_cury][win->_curx];
92
93 return OK;
94}
95
96int in_wch(cchar_t *wcval)
97{
98 PDC_LOG(("in_wch() - called\n"));
99
100 return win_wch(stdscr, wcval);
101}
102
103int mvin_wch(int y, int x, cchar_t *wcval)
104{
105 PDC_LOG(("mvin_wch() - called\n"));
106
107 if (!wcval || (move(y, x) == ERR))
108 return ERR;
109
110 *wcval = stdscr->_y[stdscr->_cury][stdscr->_curx];
111
112 return OK;
113}
114
115int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval)
116{
117 PDC_LOG(("mvwin_wch() - called\n"));
118
119 if (!wcval || (wmove(win, y, x) == ERR))
120 return ERR;
121
122 *wcval = win->_y[win->_cury][win->_curx];
123
124 return OK;
125}
126#endif
diff --git a/scripts/kconfig/libcurses/initscr.c b/scripts/kconfig/libcurses/initscr.c
new file mode 100644
index 000000000..be0b2a066
--- /dev/null
+++ b/scripts/kconfig/libcurses/initscr.c
@@ -0,0 +1,400 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7initscr
8-------
9
10### Synopsis
11
12 WINDOW *initscr(void);
13 WINDOW *Xinitscr(int argc, char *argv[]);
14 int endwin(void);
15 bool isendwin(void);
16 SCREEN *newterm(const char *type, FILE *outfd, FILE *infd);
17 SCREEN *set_term(SCREEN *new);
18 void delscreen(SCREEN *sp);
19
20 int resize_term(int nlines, int ncols);
21 bool is_termresized(void);
22 const char *curses_version(void);
23 void PDC_get_version(PDC_VERSION *ver);
24
25 int set_tabsize(int tabsize);
26
27### Description
28
29 initscr() should be the first curses routine called. It will
30 initialize all curses data structures, and arrange that the first
31 call to refresh() will clear the screen. In case of error, initscr()
32 will write a message to standard error and end the program.
33
34 endwin() should be called before exiting or escaping from curses mode
35 temporarily. It will restore tty modes, move the cursor to the lower
36 left corner of the screen and reset the terminal into the proper
37 non-visual mode. To resume curses after a temporary escape, call
38 refresh() or doupdate().
39
40 isendwin() returns TRUE if endwin() has been called without a
41 subsequent refresh, unless SP is NULL.
42
43 In some implementations of curses, newterm() allows the use of
44 multiple terminals. Here, it's just an alternative interface for
45 initscr(). It always returns SP, or NULL.
46
47 delscreen() frees the memory allocated by newterm() or initscr(),
48 since it's not freed by endwin(). This function is usually not
49 needed. In PDCurses, the parameter must be the value of SP, and
50 delscreen() sets SP to NULL.
51
52 set_term() does nothing meaningful in PDCurses, but is included for
53 compatibility with other curses implementations.
54
55 resize_term() is effectively two functions: When called with nonzero
56 values for nlines and ncols, it attempts to resize the screen to the
57 given size. When called with (0, 0), it merely adjusts the internal
58 structures to match the current size after the screen is resized by
59 the user. On the currently supported platforms, SDL, Windows console,
60 and X11 allow user resizing, while DOS, OS/2, SDL and Windows console
61 allow programmatic resizing. If you want to support user resizing,
62 you should check for getch() returning KEY_RESIZE, and/or call
63 is_termresized() at appropriate times; if either condition occurs,
64 call resize_term(0, 0). Then, with either user or programmatic
65 resizing, you'll have to resize any windows you've created, as
66 appropriate; resize_term() only handles stdscr and curscr.
67
68 is_termresized() returns TRUE if the curses screen has been resized
69 by the user, and a call to resize_term() is needed. Checking for
70 KEY_RESIZE is generally preferable, unless you're not handling the
71 keyboard.
72
73 curses_version() returns a string describing the version of PDCurses.
74
75 PDC_get_version() fills a PDC_VERSION structure provided by the user
76 with more detailed version info (see curses.h).
77
78 set_tabsize() sets the tab interval, stored in TABSIZE.
79
80### Return Value
81
82 All functions return NULL on error, except endwin(), which always
83 returns OK, and resize_term(), which returns either OK or ERR.
84
85### Portability
86 X/Open ncurses NetBSD
87 initscr Y Y Y
88 endwin Y Y Y
89 isendwin Y Y Y
90 newterm Y Y Y
91 set_term Y Y Y
92 delscreen Y Y Y
93 resize_term - Y Y
94 set_tabsize - Y Y
95 curses_version - Y -
96 is_termresized - - -
97
98**man-end****************************************************************/
99
100#include <stdlib.h>
101
102char ttytype[128];
103
104const char *_curses_notice = "PDCurses " PDC_VERDOT " - " __DATE__;
105
106SCREEN *SP = (SCREEN*)NULL; /* curses variables */
107WINDOW *curscr = (WINDOW *)NULL; /* the current screen image */
108WINDOW *stdscr = (WINDOW *)NULL; /* the default screen window */
109
110int LINES = 0; /* current terminal height */
111int COLS = 0; /* current terminal width */
112int TABSIZE = 8;
113
114MOUSE_STATUS Mouse_status;
115
116extern RIPPEDOFFLINE linesripped[5];
117extern char linesrippedoff;
118
119#ifndef XCURSES
120static
121#endif
122WINDOW *Xinitscr(int argc, char *argv[])
123{
124 int i;
125
126 PDC_LOG(("Xinitscr() - called\n"));
127
128 if (SP && SP->alive)
129 return NULL;
130
131 if (PDC_scr_open(argc, argv) == ERR)
132 {
133 fprintf(stderr, "initscr(): Unable to create SP\n");
134 exit(8);
135 }
136
137 SP->autocr = TRUE; /* cr -> lf by default */
138 SP->raw_out = FALSE; /* tty I/O modes */
139 SP->raw_inp = FALSE; /* tty I/O modes */
140 SP->cbreak = TRUE;
141 SP->key_modifiers = 0L;
142 SP->return_key_modifiers = FALSE;
143 SP->echo = TRUE;
144 SP->visibility = 1;
145 SP->resized = FALSE;
146 SP->_trap_mbe = 0L;
147 SP->linesrippedoff = 0;
148 SP->linesrippedoffontop = 0;
149 SP->delaytenths = 0;
150 SP->line_color = -1;
151 SP->lastscr = (WINDOW *)NULL;
152 SP->dbfp = NULL;
153 SP->color_started = FALSE;
154 SP->dirty = FALSE;
155 SP->sel_start = -1;
156 SP->sel_end = -1;
157
158 SP->orig_cursor = PDC_get_cursor_mode();
159
160 LINES = SP->lines;
161 COLS = SP->cols;
162
163 if (LINES < 2 || COLS < 2)
164 {
165 fprintf(stderr, "initscr(): LINES=%d COLS=%d: too small.\n",
166 LINES, COLS);
167 exit(4);
168 }
169
170 curscr = newwin(LINES, COLS, 0, 0);
171 if (!curscr)
172 {
173 fprintf(stderr, "initscr(): Unable to create curscr.\n");
174 exit(2);
175 }
176
177 SP->lastscr = newwin(LINES, COLS, 0, 0);
178 if (!SP->lastscr)
179 {
180 fprintf(stderr, "initscr(): Unable to create SP->lastscr.\n");
181 exit(2);
182 }
183
184 wattrset(SP->lastscr, (chtype)(-1));
185 werase(SP->lastscr);
186
187 PDC_slk_initialize();
188 LINES -= SP->slklines;
189
190 /* We have to sort out ripped off lines here, and reduce the height
191 of stdscr by the number of lines ripped off */
192
193 for (i = 0; i < linesrippedoff; i++)
194 {
195 if (linesripped[i].line < 0)
196 (*linesripped[i].init)(newwin(1, COLS, LINES - 1, 0), COLS);
197 else
198 (*linesripped[i].init)(newwin(1, COLS,
199 SP->linesrippedoffontop++, 0), COLS);
200
201 SP->linesrippedoff++;
202 LINES--;
203 }
204
205 linesrippedoff = 0;
206
207 stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0);
208 if (!stdscr)
209 {
210 fprintf(stderr, "initscr(): Unable to create stdscr.\n");
211 exit(1);
212 }
213
214 wclrtobot(stdscr);
215
216 /* If preserving the existing screen, don't allow a screen clear */
217
218 if (SP->_preserve)
219 {
220 untouchwin(curscr);
221 untouchwin(stdscr);
222 stdscr->_clear = FALSE;
223 curscr->_clear = FALSE;
224 }
225 else
226 curscr->_clear = TRUE;
227
228 PDC_init_atrtab(); /* set up default colors */
229
230 MOUSE_X_POS = MOUSE_Y_POS = -1;
231 BUTTON_STATUS(1) = BUTTON_RELEASED;
232 BUTTON_STATUS(2) = BUTTON_RELEASED;
233 BUTTON_STATUS(3) = BUTTON_RELEASED;
234 Mouse_status.changes = 0;
235
236 SP->alive = TRUE;
237
238 def_shell_mode();
239
240 sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname());
241
242 return stdscr;
243}
244
245WINDOW *initscr(void)
246{
247 PDC_LOG(("initscr() - called\n"));
248
249 return Xinitscr(0, NULL);
250}
251
252int endwin(void)
253{
254 PDC_LOG(("endwin() - called\n"));
255
256 /* Allow temporary exit from curses using endwin() */
257
258 def_prog_mode();
259 PDC_scr_close();
260
261 SP->alive = FALSE;
262
263 return OK;
264}
265
266bool isendwin(void)
267{
268 PDC_LOG(("isendwin() - called\n"));
269
270 return SP ? !(SP->alive) : FALSE;
271}
272
273SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
274{
275 PDC_LOG(("newterm() - called\n"));
276
277 return Xinitscr(0, NULL) ? SP : NULL;
278}
279
280SCREEN *set_term(SCREEN *new)
281{
282 PDC_LOG(("set_term() - called\n"));
283
284 /* We only support one screen */
285
286 return (new == SP) ? SP : NULL;
287}
288
289void delscreen(SCREEN *sp)
290{
291 PDC_LOG(("delscreen() - called\n"));
292
293 if (sp != SP)
294 return;
295
296 PDC_slk_free(); /* free the soft label keys, if needed */
297
298 delwin(stdscr);
299 delwin(curscr);
300 delwin(SP->lastscr);
301 stdscr = (WINDOW *)NULL;
302 curscr = (WINDOW *)NULL;
303 SP->lastscr = (WINDOW *)NULL;
304
305 SP->alive = FALSE;
306
307 PDC_scr_free(); /* free SP */
308
309 SP = (SCREEN *)NULL;
310}
311
312int resize_term(int nlines, int ncols)
313{
314 PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
315
316 if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
317 return ERR;
318
319 SP->lines = PDC_get_rows();
320 LINES = SP->lines - SP->linesrippedoff - SP->slklines;
321 SP->cols = COLS = PDC_get_columns();
322
323 if (wresize(curscr, SP->lines, SP->cols) == ERR ||
324 wresize(stdscr, LINES, COLS) == ERR ||
325 wresize(SP->lastscr, SP->lines, SP->cols) == ERR)
326 return ERR;
327
328 werase(SP->lastscr);
329 curscr->_clear = TRUE;
330
331 if (SP->slk_winptr)
332 {
333 if (wresize(SP->slk_winptr, SP->slklines, COLS) == ERR)
334 return ERR;
335
336 wmove(SP->slk_winptr, 0, 0);
337 wclrtobot(SP->slk_winptr);
338 PDC_slk_initialize();
339 slk_noutrefresh();
340 }
341
342 touchwin(stdscr);
343 wnoutrefresh(stdscr);
344
345 return OK;
346}
347
348bool is_termresized(void)
349{
350 PDC_LOG(("is_termresized() - called\n"));
351
352 return SP->resized;
353}
354
355const char *curses_version(void)
356{
357 return _curses_notice;
358}
359
360void PDC_get_version(PDC_VERSION *ver)
361{
362 if (!ver)
363 return;
364
365 ver->flags = 0
366#ifdef PDCDEBUG
367 | PDC_VFLAG_DEBUG
368#endif
369#ifdef PDC_WIDE
370 | PDC_VFLAG_WIDE
371#endif
372#ifdef PDC_FORCE_UTF8
373 | PDC_VFLAG_UTF8
374#endif
375#ifdef PDC_DLL_BUILD
376 | PDC_VFLAG_DLL
377#endif
378#ifdef PDC_RGB
379 | PDC_VFLAG_RGB
380#endif
381 ;
382
383 ver->build = PDC_BUILD;
384 ver->major = PDC_VER_MAJOR;
385 ver->minor = PDC_VER_MINOR;
386 ver->csize = sizeof(chtype);
387 ver->bsize = sizeof(bool);
388}
389
390int set_tabsize(int tabsize)
391{
392 PDC_LOG(("set_tabsize() - called: tabsize %d\n", tabsize));
393
394 if (tabsize < 1)
395 return ERR;
396
397 TABSIZE = tabsize;
398
399 return OK;
400}
diff --git a/scripts/kconfig/libcurses/inopts.c b/scripts/kconfig/libcurses/inopts.c
new file mode 100644
index 000000000..918b7d1af
--- /dev/null
+++ b/scripts/kconfig/libcurses/inopts.c
@@ -0,0 +1,368 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7inopts
8------
9
10### Synopsis
11
12 int cbreak(void);
13 int nocbreak(void);
14 int echo(void);
15 int noecho(void);
16 int halfdelay(int tenths);
17 int intrflush(WINDOW *win, bool bf);
18 int keypad(WINDOW *win, bool bf);
19 int meta(WINDOW *win, bool bf);
20 int nl(void);
21 int nonl(void);
22 int nodelay(WINDOW *win, bool bf);
23 int notimeout(WINDOW *win, bool bf);
24 int raw(void);
25 int noraw(void);
26 void noqiflush(void);
27 void qiflush(void);
28 void timeout(int delay);
29 void wtimeout(WINDOW *win, int delay);
30 int typeahead(int fildes);
31
32 int crmode(void);
33 int nocrmode(void);
34
35 bool is_keypad(const WINDOW *win);
36
37### Description
38
39 cbreak() and nocbreak() toggle cbreak mode. In cbreak mode,
40 characters typed by the user are made available immediately, and
41 erase/kill character processing is not performed. In nocbreak mode,
42 typed characters are buffered until a newline or carriage return.
43 Interrupt and flow control characters are unaffected by this mode.
44 PDCurses always starts in cbreak mode.
45
46 echo() and noecho() control whether typed characters are echoed by
47 the input routine. Initially, input characters are echoed. Subsequent
48 calls to echo() and noecho() do not flush type-ahead.
49
50 halfdelay() is similar to cbreak(), but allows for a time limit to be
51 specified, in tenths of a second. This causes getch() to block for
52 that period before returning ERR if no key has been received. tenths
53 must be between 1 and 255.
54
55 keypad() controls whether getch() returns function/special keys as
56 single key codes (e.g., the left arrow key as KEY_LEFT). Per X/Open,
57 the default for keypad mode is OFF. You'll probably want it on. With
58 keypad mode off, if a special key is pressed, getch() does nothing or
59 returns ERR.
60
61 nodelay() controls whether wgetch() is a non-blocking call. If the
62 option is enabled, and no input is ready, wgetch() will return ERR.
63 If disabled, wgetch() will hang until input is ready.
64
65 nl() enables the translation of a carriage return into a newline on
66 input. nonl() disables this. Initially, the translation does occur.
67
68 raw() and noraw() toggle raw mode. Raw mode is similar to cbreak
69 mode, in that characters typed are immediately passed through to the
70 user program. The difference is that in raw mode, the INTR, QUIT,
71 SUSP, and STOP characters are passed through without being
72 interpreted, and without generating a signal.
73
74 In PDCurses, the meta() function sets raw mode on or off.
75
76 timeout() and wtimeout() set blocking or non-blocking reads for the
77 specified window. If the delay is negative, a blocking read is used;
78 if zero, then non-blocking reads are done -- if no input is waiting,
79 ERR is returned immediately. If the delay is positive, the read
80 blocks for the delay period; if the period expires, ERR is returned.
81 The delay is given in milliseconds, but this is rounded down to 50ms
82 (1/20th sec) intervals, with a minimum of one interval if a postive
83 delay is given; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms,
84 etc.
85
86 intrflush(), notimeout(), noqiflush(), qiflush() and typeahead() do
87 nothing in PDCurses, but are included for compatibility with other
88 curses implementations.
89
90 crmode() and nocrmode() are archaic equivalents to cbreak() and
91 nocbreak(), respectively.
92
93 is_keypad() reports whether the specified window is in keypad mode.
94
95### Return Value
96
97 All functions except is_keypad() and the void functions return OK on
98 success and ERR on error.
99
100### Portability
101 X/Open ncurses NetBSD
102 cbreak Y Y Y
103 nocbreak Y Y Y
104 echo Y Y Y
105 noecho Y Y Y
106 halfdelay Y Y Y
107 intrflush Y Y Y
108 keypad Y Y Y
109 meta Y Y Y
110 nl Y Y Y
111 nonl Y Y Y
112 nodelay Y Y Y
113 notimeout Y Y Y
114 raw Y Y Y
115 noraw Y Y Y
116 noqiflush Y Y Y
117 qiflush Y Y Y
118 timeout Y Y Y
119 wtimeout Y Y Y
120 typeahead Y Y Y
121 crmode Y Y Y
122 nocrmode Y Y Y
123 is_keypad - Y Y
124
125**man-end****************************************************************/
126
127int cbreak(void)
128{
129 PDC_LOG(("cbreak() - called\n"));
130
131 if (!SP)
132 return ERR;
133
134 SP->cbreak = TRUE;
135
136 return OK;
137}
138
139int nocbreak(void)
140{
141 PDC_LOG(("nocbreak() - called\n"));
142
143 if (!SP)
144 return ERR;
145
146 SP->cbreak = FALSE;
147 SP->delaytenths = 0;
148
149 return OK;
150}
151
152int echo(void)
153{
154 PDC_LOG(("echo() - called\n"));
155
156 if (!SP)
157 return ERR;
158
159 SP->echo = TRUE;
160
161 return OK;
162}
163
164int noecho(void)
165{
166 PDC_LOG(("noecho() - called\n"));
167
168 if (!SP)
169 return ERR;
170
171 SP->echo = FALSE;
172
173 return OK;
174}
175
176int halfdelay(int tenths)
177{
178 PDC_LOG(("halfdelay() - called\n"));
179
180 if (!SP || tenths < 1 || tenths > 255)
181 return ERR;
182
183 SP->delaytenths = tenths;
184
185 return OK;
186}
187
188int intrflush(WINDOW *win, bool bf)
189{
190 PDC_LOG(("intrflush() - called\n"));
191
192 return OK;
193}
194
195int keypad(WINDOW *win, bool bf)
196{
197 PDC_LOG(("keypad() - called\n"));
198
199 if (!win)
200 return ERR;
201
202 win->_use_keypad = bf;
203
204 return OK;
205}
206
207int meta(WINDOW *win, bool bf)
208{
209 PDC_LOG(("meta() - called\n"));
210
211 if (!SP)
212 return ERR;
213
214 SP->raw_inp = bf;
215
216 return OK;
217}
218
219int nl(void)
220{
221 PDC_LOG(("nl() - called\n"));
222
223 if (!SP)
224 return ERR;
225
226 SP->autocr = TRUE;
227
228 return OK;
229}
230
231int nonl(void)
232{
233 PDC_LOG(("nonl() - called\n"));
234
235 if (!SP)
236 return ERR;
237
238 SP->autocr = FALSE;
239
240 return OK;
241}
242
243int nodelay(WINDOW *win, bool flag)
244{
245 PDC_LOG(("nodelay() - called\n"));
246
247 if (!win)
248 return ERR;
249
250 win->_nodelay = flag;
251
252 return OK;
253}
254
255int notimeout(WINDOW *win, bool flag)
256{
257 PDC_LOG(("notimeout() - called\n"));
258
259 return OK;
260}
261
262int raw(void)
263{
264 PDC_LOG(("raw() - called\n"));
265
266 if (!SP)
267 return ERR;
268
269 PDC_set_keyboard_binary(TRUE);
270 SP->raw_inp = TRUE;
271
272 return OK;
273}
274
275int noraw(void)
276{
277 PDC_LOG(("noraw() - called\n"));
278
279 if (!SP)
280 return ERR;
281
282 PDC_set_keyboard_binary(FALSE);
283 SP->raw_inp = FALSE;
284
285 return OK;
286}
287
288void noqiflush(void)
289{
290 PDC_LOG(("noqiflush() - called\n"));
291}
292
293void qiflush(void)
294{
295 PDC_LOG(("qiflush() - called\n"));
296}
297
298int typeahead(int fildes)
299{
300 PDC_LOG(("typeahead() - called\n"));
301
302 return OK;
303}
304
305void wtimeout(WINDOW *win, int delay)
306{
307 PDC_LOG(("wtimeout() - called\n"));
308
309 if (!win)
310 return;
311
312 if (delay < 0)
313 {
314 /* This causes a blocking read on the window, so turn on delay
315 mode */
316
317 win->_nodelay = FALSE;
318 win->_delayms = 0;
319 }
320 else if (!delay)
321 {
322 /* This causes a non-blocking read on the window, so turn off
323 delay mode */
324
325 win->_nodelay = TRUE;
326 win->_delayms = 0;
327 }
328 else
329 {
330 /* This causes the read on the window to delay for the number of
331 milliseconds. Also forces the window into non-blocking read
332 mode */
333
334 /*win->_nodelay = TRUE;*/
335 win->_delayms = delay;
336 }
337}
338
339void timeout(int delay)
340{
341 PDC_LOG(("timeout() - called\n"));
342
343 wtimeout(stdscr, delay);
344}
345
346int crmode(void)
347{
348 PDC_LOG(("crmode() - called\n"));
349
350 return cbreak();
351}
352
353int nocrmode(void)
354{
355 PDC_LOG(("nocrmode() - called\n"));
356
357 return nocbreak();
358}
359
360bool is_keypad(const WINDOW *win)
361{
362 PDC_LOG(("is_keypad() - called\n"));
363
364 if (!win)
365 return FALSE;
366
367 return win->_use_keypad;
368}
diff --git a/scripts/kconfig/libcurses/kernel.c b/scripts/kconfig/libcurses/kernel.c
new file mode 100644
index 000000000..afb2d0661
--- /dev/null
+++ b/scripts/kconfig/libcurses/kernel.c
@@ -0,0 +1,297 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7kernel
8------
9
10### Synopsis
11
12 int def_prog_mode(void);
13 int def_shell_mode(void);
14 int reset_prog_mode(void);
15 int reset_shell_mode(void);
16 int resetty(void);
17 int savetty(void);
18 int ripoffline(int line, int (*init)(WINDOW *, int));
19 int curs_set(int visibility);
20 int napms(int ms);
21
22 int draino(int ms);
23 int resetterm(void);
24 int fixterm(void);
25 int saveterm(void);
26
27### Description
28
29 def_prog_mode() and def_shell_mode() save the current terminal modes
30 as the "program" (in curses) or "shell" (not in curses) state for use
31 by the reset_prog_mode() and reset_shell_mode() functions. This is
32 done automatically by initscr().
33
34 reset_prog_mode() and reset_shell_mode() restore the terminal to
35 "program" (in curses) or "shell" (not in curses) state. These are
36 done automatically by endwin() and doupdate() after an endwin(), so
37 they would normally not be called before these functions.
38
39 savetty() and resetty() save and restore the state of the terminal
40 modes. savetty() saves the current state in a buffer, and resetty()
41 restores the state to what it was at the last call to savetty().
42
43 curs_set() alters the appearance of the cursor. A visibility of 0
44 makes it disappear; 1 makes it appear "normal" (usually an underline)
45 and 2 makes it "highly visible" (usually a block).
46
47 ripoffline() reduces the size of stdscr by one line. If the "line"
48 parameter is positive, the line is removed from the top of the
49 screen; if negative, from the bottom. Up to 5 lines can be ripped off
50 stdscr by calling ripoffline() repeatedly. The function argument,
51 init, is called from within initscr() or newterm(), so ripoffline()
52 must be called before either of these functions. The init function
53 receives a pointer to a one-line WINDOW, and the width of the window.
54 Calling ripoffline() with a NULL init function pointer is an error.
55
56 napms() suspends the program for the specified number of
57 milliseconds. draino() is an archaic equivalent. Note that since
58 napms() attempts to give up a time slice and yield control back to
59 the OS, all times are approximate. (In DOS, the delay is actually
60 rounded down to 50ms (1/20th sec) intervals, with a minimum of one
61 interval; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms, etc.)
62 0 returns immediately.
63
64 resetterm(), fixterm() and saveterm() are archaic equivalents for
65 reset_shell_mode(), reset_prog_mode() and def_prog_mode(),
66 respectively.
67
68### Return Value
69
70 All functions return OK on success and ERR on error, except
71 curs_set(), which returns the previous visibility.
72
73### Portability
74 X/Open ncurses NetBSD
75 def_prog_mode Y Y Y
76 def_shell_mode Y Y Y
77 reset_prog_mode Y Y Y
78 reset_shell_mode Y Y Y
79 resetty Y Y Y
80 savetty Y Y Y
81 ripoffline Y Y Y
82 curs_set Y Y Y
83 napms Y Y Y
84 fixterm - Y -
85 resetterm - Y -
86 saveterm - Y -
87 draino - - -
88
89**man-end****************************************************************/
90
91#include <string.h>
92
93RIPPEDOFFLINE linesripped[5];
94char linesrippedoff = 0;
95
96static struct cttyset
97{
98 bool been_set;
99 SCREEN saved;
100} ctty[3];
101
102enum { PDC_SH_TTY, PDC_PR_TTY, PDC_SAVE_TTY };
103
104static void _save_mode(int i)
105{
106 ctty[i].been_set = TRUE;
107
108 memcpy(&(ctty[i].saved), SP, sizeof(SCREEN));
109
110 PDC_save_screen_mode(i);
111}
112
113static int _restore_mode(int i)
114{
115 if (ctty[i].been_set == TRUE)
116 {
117 memcpy(SP, &(ctty[i].saved), sizeof(SCREEN));
118
119 if (ctty[i].saved.raw_out)
120 raw();
121
122 PDC_restore_screen_mode(i);
123
124 if ((LINES != ctty[i].saved.lines) ||
125 (COLS != ctty[i].saved.cols))
126 resize_term(ctty[i].saved.lines, ctty[i].saved.cols);
127
128 PDC_curs_set(ctty[i].saved.visibility);
129
130 PDC_gotoyx(ctty[i].saved.cursrow, ctty[i].saved.curscol);
131 }
132
133 return ctty[i].been_set ? OK : ERR;
134}
135
136int def_prog_mode(void)
137{
138 PDC_LOG(("def_prog_mode() - called\n"));
139
140 if (!SP)
141 return ERR;
142
143 _save_mode(PDC_PR_TTY);
144
145 return OK;
146}
147
148int def_shell_mode(void)
149{
150 PDC_LOG(("def_shell_mode() - called\n"));
151
152 if (!SP)
153 return ERR;
154
155 _save_mode(PDC_SH_TTY);
156
157 return OK;
158}
159
160int reset_prog_mode(void)
161{
162 PDC_LOG(("reset_prog_mode() - called\n"));
163
164 if (!SP)
165 return ERR;
166
167 _restore_mode(PDC_PR_TTY);
168 PDC_reset_prog_mode();
169
170 return OK;
171}
172
173int reset_shell_mode(void)
174{
175 PDC_LOG(("reset_shell_mode() - called\n"));
176
177 if (!SP)
178 return ERR;
179
180 _restore_mode(PDC_SH_TTY);
181 PDC_reset_shell_mode();
182
183 return OK;
184}
185
186int resetty(void)
187{
188 PDC_LOG(("resetty() - called\n"));
189
190 if (!SP)
191 return ERR;
192
193 return _restore_mode(PDC_SAVE_TTY);
194}
195
196int savetty(void)
197{
198 PDC_LOG(("savetty() - called\n"));
199
200 if (!SP)
201 return ERR;
202
203 _save_mode(PDC_SAVE_TTY);
204
205 return OK;
206}
207
208int curs_set(int visibility)
209{
210 int ret_vis;
211
212 PDC_LOG(("curs_set() - called: visibility=%d\n", visibility));
213
214 if (!SP || visibility < 0 || visibility > 2)
215 return ERR;
216
217 ret_vis = PDC_curs_set(visibility);
218
219 /* If the cursor is changing from invisible to visible, update
220 its position */
221
222 if (visibility && !ret_vis)
223 PDC_gotoyx(SP->cursrow, SP->curscol);
224
225 return ret_vis;
226}
227
228int napms(int ms)
229{
230 PDC_LOG(("napms() - called: ms=%d\n", ms));
231
232 if (!SP)
233 return ERR;
234
235 if (SP->dirty)
236 {
237 int curs_state = SP->visibility;
238 bool leave_state = is_leaveok(curscr);
239
240 SP->dirty = FALSE;
241
242 leaveok(curscr, TRUE);
243
244 wrefresh(curscr);
245
246 leaveok(curscr, leave_state);
247 curs_set(curs_state);
248 }
249
250 if (ms)
251 PDC_napms(ms);
252
253 return OK;
254}
255
256int ripoffline(int line, int (*init)(WINDOW *, int))
257{
258 PDC_LOG(("ripoffline() - called: line=%d\n", line));
259
260 if (linesrippedoff < 5 && line && init)
261 {
262 linesripped[(int)linesrippedoff].line = line;
263 linesripped[(int)linesrippedoff++].init = init;
264
265 return OK;
266 }
267
268 return ERR;
269}
270
271int draino(int ms)
272{
273 PDC_LOG(("draino() - called\n"));
274
275 return napms(ms);
276}
277
278int resetterm(void)
279{
280 PDC_LOG(("resetterm() - called\n"));
281
282 return reset_shell_mode();
283}
284
285int fixterm(void)
286{
287 PDC_LOG(("fixterm() - called\n"));
288
289 return reset_prog_mode();
290}
291
292int saveterm(void)
293{
294 PDC_LOG(("saveterm() - called\n"));
295
296 return def_prog_mode();
297}
diff --git a/scripts/kconfig/libcurses/move.c b/scripts/kconfig/libcurses/move.c
new file mode 100644
index 000000000..96496445e
--- /dev/null
+++ b/scripts/kconfig/libcurses/move.c
@@ -0,0 +1,77 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7move
8----
9
10### Synopsis
11
12 int move(int y, int x);
13 int mvcur(int oldrow, int oldcol, int newrow, int newcol);
14 int wmove(WINDOW *win, int y, int x);
15
16### Description
17
18 move() and wmove() move the cursor associated with the window to the
19 given location. This does not move the physical cursor of the
20 terminal until refresh() is called. The position specified is
21 relative to the upper left corner of the window, which is (0,0).
22
23 mvcur() moves the physical cursor without updating any window cursor
24 positions.
25
26### Return Value
27
28 All functions return OK on success and ERR on error.
29
30### Portability
31 X/Open ncurses NetBSD
32 move Y Y Y
33 mvcur Y Y Y
34 wmove Y Y Y
35
36**man-end****************************************************************/
37
38int move(int y, int x)
39{
40 PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
41
42 if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
43 return ERR;
44
45 stdscr->_curx = x;
46 stdscr->_cury = y;
47
48 return OK;
49}
50
51int mvcur(int oldrow, int oldcol, int newrow, int newcol)
52{
53 PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
54 oldrow, oldcol, newrow, newcol));
55
56 if (!SP || newrow < 0 || newrow >= LINES || newcol < 0 || newcol >= COLS)
57 return ERR;
58
59 PDC_gotoyx(newrow, newcol);
60 SP->cursrow = newrow;
61 SP->curscol = newcol;
62
63 return OK;
64}
65
66int wmove(WINDOW *win, int y, int x)
67{
68 PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
69
70 if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
71 return ERR;
72
73 win->_curx = x;
74 win->_cury = y;
75
76 return OK;
77}
diff --git a/scripts/kconfig/libcurses/outopts.c b/scripts/kconfig/libcurses/outopts.c
new file mode 100644
index 000000000..28f93f1f2
--- /dev/null
+++ b/scripts/kconfig/libcurses/outopts.c
@@ -0,0 +1,175 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7outopts
8-------
9
10### Synopsis
11
12 int clearok(WINDOW *win, bool bf);
13 int idlok(WINDOW *win, bool bf);
14 void idcok(WINDOW *win, bool bf);
15 void immedok(WINDOW *win, bool bf);
16 int leaveok(WINDOW *win, bool bf);
17 int setscrreg(int top, int bot);
18 int wsetscrreg(WINDOW *win, int top, int bot);
19 int scrollok(WINDOW *win, bool bf);
20
21 int raw_output(bool bf);
22
23 bool is_leaveok(const WINDOW *win);
24
25### Description
26
27 With clearok(), if bf is TRUE, the next call to wrefresh() with this
28 window will clear the screen completely and redraw the entire screen.
29
30 immedok(), called with a second argument of TRUE, causes an automatic
31 wrefresh() every time a change is made to the specified window.
32
33 Normally, the hardware cursor is left at the location of the window
34 being refreshed. leaveok() allows the cursor to be left wherever the
35 update happens to leave it. It's useful for applications where the
36 cursor is not used, since it reduces the need for cursor motions. If
37 possible, the cursor is made invisible when this option is enabled.
38
39 wsetscrreg() sets a scrolling region in a window; "top" and "bot" are
40 the line numbers for the top and bottom margins. If this option and
41 scrollok() are enabled, any attempt to move off the bottom margin
42 will cause all lines in the scrolling region to scroll up one line.
43 setscrreg() is the stdscr version.
44
45 idlok() and idcok() do nothing in PDCurses, but are provided for
46 compatibility with other curses implementations.
47
48 raw_output() enables the output of raw characters using the standard
49 *add* and *ins* curses functions (that is, it disables translation of
50 control characters).
51
52 is_leaveok() reports whether the specified window is in leaveok mode.
53
54### Return Value
55
56 All functions except is_leaveok() return OK on success and ERR on
57 error.
58
59### Portability
60 X/Open ncurses NetBSD
61 clearok Y Y Y
62 idlok Y Y Y
63 idcok Y Y Y
64 immedok Y Y Y
65 leaveok Y Y Y
66 setscrreg Y Y Y
67 wsetscrreg Y Y Y
68 scrollok Y Y Y
69 is_leaveok - Y Y
70 raw_output - - -
71
72**man-end****************************************************************/
73
74int clearok(WINDOW *win, bool bf)
75{
76 PDC_LOG(("clearok() - called\n"));
77
78 if (!win)
79 return ERR;
80
81 win->_clear = bf;
82
83 return OK;
84}
85
86int idlok(WINDOW *win, bool bf)
87{
88 PDC_LOG(("idlok() - called\n"));
89
90 return OK;
91}
92
93void idcok(WINDOW *win, bool bf)
94{
95 PDC_LOG(("idcok() - called\n"));
96}
97
98void immedok(WINDOW *win, bool bf)
99{
100 PDC_LOG(("immedok() - called\n"));
101
102 if (win)
103 win->_immed = bf;
104}
105
106int leaveok(WINDOW *win, bool bf)
107{
108 PDC_LOG(("leaveok() - called\n"));
109
110 if (!win)
111 return ERR;
112
113 win->_leaveit = bf;
114
115 curs_set(!bf);
116
117 return OK;
118}
119
120int setscrreg(int top, int bottom)
121{
122 PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
123
124 return wsetscrreg(stdscr, top, bottom);
125}
126
127int wsetscrreg(WINDOW *win, int top, int bottom)
128{
129 PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
130
131 if (win && 0 <= top && top <= win->_cury &&
132 win->_cury <= bottom && bottom < win->_maxy)
133 {
134 win->_tmarg = top;
135 win->_bmarg = bottom;
136
137 return OK;
138 }
139 else
140 return ERR;
141}
142
143int scrollok(WINDOW *win, bool bf)
144{
145 PDC_LOG(("scrollok() - called\n"));
146
147 if (!win)
148 return ERR;
149
150 win->_scroll = bf;
151
152 return OK;
153}
154
155int raw_output(bool bf)
156{
157 PDC_LOG(("raw_output() - called\n"));
158
159 if (!SP)
160 return ERR;
161
162 SP->raw_out = bf;
163
164 return OK;
165}
166
167bool is_leaveok(const WINDOW *win)
168{
169 PDC_LOG(("is_leaveok() - called\n"));
170
171 if (!win)
172 return FALSE;
173
174 return win->_leaveit;
175}
diff --git a/scripts/kconfig/libcurses/overlay.c b/scripts/kconfig/libcurses/overlay.c
new file mode 100644
index 000000000..ae1903da8
--- /dev/null
+++ b/scripts/kconfig/libcurses/overlay.c
@@ -0,0 +1,214 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7overlay
8-------
9
10### Synopsis
11
12 int overlay(const WINDOW *src_w, WINDOW *dst_w)
13 int overwrite(const WINDOW *src_w, WINDOW *dst_w)
14 int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
15 int src_tc, int dst_tr, int dst_tc, int dst_br,
16 int dst_bc, int _overlay)
17
18### Description
19
20 overlay() and overwrite() copy all the text from src_w into dst_w.
21 The windows need not be the same size. Those characters in the source
22 window that intersect with the destination window are copied, so that
23 the characters appear in the same physical position on the screen.
24 The difference between the two functions is that overlay() is non-
25 destructive (blanks are not copied) while overwrite() is destructive
26 (blanks are copied).
27
28 copywin() is similar, but doesn't require that the two windows
29 overlap. The arguments src_tc and src_tr specify the top left corner
30 of the region to be copied. dst_tc, dst_tr, dst_br, and dst_bc
31 specify the region within the destination window to copy to. The
32 argument "overlay", if TRUE, indicates that the copy is done non-
33 destructively (as in overlay()); blanks in the source window are not
34 copied to the destination window. When overlay is FALSE, blanks are
35 copied.
36
37### Return Value
38
39 All functions return OK on success and ERR on error.
40
41### Portability
42 X/Open ncurses NetBSD
43 overlay Y Y Y
44 overwrite Y Y Y
45 copywin Y Y Y
46
47**man-end****************************************************************/
48
49/* Thanks to Andreas Otte <venn@@uni-paderborn.de> for the
50 corrected overlay()/overwrite() behavior. */
51
52static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
53 int src_tc, int src_br, int src_bc, int dst_tr,
54 int dst_tc, bool _overlay)
55{
56 int col, line, y1, fc, *minchng, *maxchng;
57 chtype *w1ptr, *w2ptr;
58
59 int lc = 0;
60 int xdiff = src_bc - src_tc;
61 int ydiff = src_br - src_tr;
62
63 if (!src_w || !dst_w)
64 return ERR;
65
66 minchng = dst_w->_firstch;
67 maxchng = dst_w->_lastch;
68
69 for (y1 = 0; y1 < dst_tr; y1++)
70 {
71 minchng++;
72 maxchng++;
73 }
74
75 for (line = 0; line < ydiff; line++)
76 {
77 w1ptr = src_w->_y[line + src_tr] + src_tc;
78 w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
79
80 fc = _NO_CHANGE;
81
82 for (col = 0; col < xdiff; col++)
83 {
84 if ((*w1ptr) != (*w2ptr) &&
85 !((*w1ptr & A_CHARTEXT) == ' ' && _overlay))
86 {
87 *w2ptr = *w1ptr;
88
89 if (fc == _NO_CHANGE)
90 fc = col + dst_tc;
91
92 lc = col + dst_tc;
93 }
94
95 w1ptr++;
96 w2ptr++;
97 }
98
99 if (*minchng == _NO_CHANGE)
100 {
101 *minchng = fc;
102 *maxchng = lc;
103 }
104 else if (fc != _NO_CHANGE)
105 {
106 if (fc < *minchng)
107 *minchng = fc;
108 if (lc > *maxchng)
109 *maxchng = lc;
110 }
111
112 minchng++;
113 maxchng++;
114 }
115
116 return OK;
117}
118
119int _copy_overlap(const WINDOW *src_w, WINDOW *dst_w, bool overlay)
120{
121 int first_line, first_col, last_line, last_col;
122 int src_start_x, src_start_y, dst_start_x, dst_start_y;
123 int xdiff, ydiff;
124
125 if (!src_w || !dst_w)
126 return ERR;
127
128 first_col = max(dst_w->_begx, src_w->_begx);
129 first_line = max(dst_w->_begy, src_w->_begy);
130
131 last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
132 last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
133
134 /* determine the overlapping region of the two windows in real
135 coordinates */
136
137 /* if no overlapping region, do nothing */
138
139 if ((last_col < first_col) || (last_line < first_line))
140 return OK;
141
142 /* size of overlapping region */
143
144 xdiff = last_col - first_col;
145 ydiff = last_line - first_line;
146
147 if (src_w->_begx <= dst_w->_begx)
148 {
149 src_start_x = dst_w->_begx - src_w->_begx;
150 dst_start_x = 0;
151 }
152 else
153 {
154 dst_start_x = src_w->_begx - dst_w->_begx;
155 src_start_x = 0;
156 }
157
158 if (src_w->_begy <= dst_w->_begy)
159 {
160 src_start_y = dst_w->_begy - src_w->_begy;
161 dst_start_y = 0;
162 }
163 else
164 {
165 dst_start_y = src_w->_begy - dst_w->_begy;
166 src_start_y = 0;
167 }
168
169 return _copy_win(src_w, dst_w, src_start_y, src_start_x,
170 src_start_y + ydiff, src_start_x + xdiff,
171 dst_start_y, dst_start_x, overlay);
172}
173
174int overlay(const WINDOW *src_w, WINDOW *dst_w)
175{
176 PDC_LOG(("overlay() - called\n"));
177
178 return _copy_overlap(src_w, dst_w, TRUE);
179}
180
181int overwrite(const WINDOW *src_w, WINDOW *dst_w)
182{
183 PDC_LOG(("overwrite() - called\n"));
184
185 return _copy_overlap(src_w, dst_w, FALSE);
186}
187
188int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc,
189 int dst_tr, int dst_tc, int dst_br, int dst_bc, int _overlay)
190{
191 int src_end_x, src_end_y;
192 int src_rows, src_cols, dst_rows, dst_cols;
193 int min_rows, min_cols;
194
195 PDC_LOG(("copywin() - called\n"));
196
197 if (!src_w || !dst_w || dst_w == curscr || dst_br >= dst_w->_maxy
198 || dst_bc >= dst_w->_maxx || dst_tr < 0 || dst_tc < 0)
199 return ERR;
200
201 src_rows = src_w->_maxy - src_tr;
202 src_cols = src_w->_maxx - src_tc;
203 dst_rows = dst_br - dst_tr + 1;
204 dst_cols = dst_bc - dst_tc + 1;
205
206 min_rows = min(src_rows, dst_rows);
207 min_cols = min(src_cols, dst_cols);
208
209 src_end_y = src_tr + min_rows;
210 src_end_x = src_tc + min_cols;
211
212 return _copy_win(src_w, dst_w, src_tr, src_tc, src_end_y, src_end_x,
213 dst_tr, dst_tc, _overlay);
214}
diff --git a/scripts/kconfig/libcurses/pad.c b/scripts/kconfig/libcurses/pad.c
new file mode 100644
index 000000000..5003ecbb4
--- /dev/null
+++ b/scripts/kconfig/libcurses/pad.c
@@ -0,0 +1,278 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7pad
8---
9
10### Synopsis
11
12 WINDOW *newpad(int nlines, int ncols);
13 WINDOW *subpad(WINDOW *orig, int nlines, int ncols,
14 int begy, int begx);
15 int prefresh(WINDOW *win, int py, int px, int sy1, int sx1,
16 int sy2, int sx2);
17 int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1,
18 int sy2, int sx2);
19 int pechochar(WINDOW *pad, chtype ch);
20 int pecho_wchar(WINDOW *pad, const cchar_t *wch);
21
22 bool is_pad(const WINDOW *pad);
23
24### Description
25
26 A pad is a special kind of window, which is not restricted by the
27 screen size, and is not necessarily associated with a particular part
28 of the screen. You can use a pad when you need a large window, and
29 only a part of the window will be on the screen at one time. Pads are
30 not refreshed automatically (e.g., from scrolling or echoing of
31 input). You can't call wrefresh() with a pad as an argument; use
32 prefresh() or pnoutrefresh() instead. Note that these routines
33 require additional parameters to specify the part of the pad to be
34 displayed, and the location to use on the screen.
35
36 newpad() creates a new pad data structure.
37
38 subpad() creates a new sub-pad within a pad, at position (begy,
39 begx), with dimensions of nlines lines and ncols columns. This
40 position is relative to the pad, and not to the screen as with
41 subwin. Changes to either the parent pad or sub-pad will affect both.
42 When using sub-pads, you may need to call touchwin() before calling
43 prefresh().
44
45 pnoutrefresh() copies the specified pad to the virtual screen.
46
47 prefresh() calls pnoutrefresh(), followed by doupdate().
48
49 These routines are analogous to wnoutrefresh() and wrefresh(). (py,
50 px) specifies the upper left corner of the part of the pad to be
51 displayed; (sy1, sx1) and (sy2, sx2) describe the screen rectangle
52 that will contain the selected part of the pad.
53
54 pechochar() is functionally equivalent to addch() followed by a call
55 to prefresh(), with the last-used coordinates and dimensions.
56 pecho_wchar() is the wide-character version.
57
58 is_pad() reports whether the specified window is a pad.
59
60### Return Value
61
62 All functions except is_pad() return OK on success and ERR on error.
63
64### Portability
65 X/Open ncurses NetBSD
66 newpad Y Y Y
67 subpad Y Y Y
68 prefresh Y Y Y
69 pnoutrefresh Y Y Y
70 pechochar Y Y Y
71 pecho_wchar Y Y Y
72 is_pad - Y Y
73
74**man-end****************************************************************/
75
76#include <string.h>
77
78/* save values for pechochar() */
79
80static int save_pminrow, save_pmincol;
81static int save_sminrow, save_smincol, save_smaxrow, save_smaxcol;
82
83WINDOW *newpad(int nlines, int ncols)
84{
85 WINDOW *win;
86
87 PDC_LOG(("newpad() - called: lines=%d cols=%d\n", nlines, ncols));
88
89 win = PDC_makenew(nlines, ncols, 0, 0);
90 if (win)
91 win = PDC_makelines(win);
92
93 if (!win)
94 return (WINDOW *)NULL;
95
96 werase(win);
97
98 win->_flags = _PAD;
99
100 /* save default values in case pechochar() is the first call to
101 prefresh(). */
102
103 save_pminrow = 0;
104 save_pmincol = 0;
105 save_sminrow = 0;
106 save_smincol = 0;
107 save_smaxrow = min(LINES, nlines) - 1;
108 save_smaxcol = min(COLS, ncols) - 1;
109
110 return win;
111}
112
113WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
114{
115 WINDOW *win;
116 int i;
117
118 PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n",
119 nlines, ncols, begy, begx));
120
121 if (!orig || !(orig->_flags & _PAD))
122 return (WINDOW *)NULL;
123
124 /* make sure window fits inside the original one */
125
126 if (begy < 0 || begx < 0 ||
127 (begy + nlines) > orig->_maxy ||
128 (begx + ncols) > orig->_maxx)
129 return (WINDOW *)NULL;
130
131 if (!nlines)
132 nlines = orig->_maxy - begy;
133
134 if (!ncols)
135 ncols = orig->_maxx - begx;
136
137 win = PDC_makenew(nlines, ncols, begy, begx);
138 if (!win)
139 return (WINDOW *)NULL;
140
141 /* initialize window variables */
142
143 win->_attrs = orig->_attrs;
144 win->_leaveit = orig->_leaveit;
145 win->_scroll = orig->_scroll;
146 win->_nodelay = orig->_nodelay;
147 win->_use_keypad = orig->_use_keypad;
148 win->_parent = orig;
149
150 for (i = 0; i < nlines; i++)
151 win->_y[i] = orig->_y[begy + i] + begx;
152
153 win->_flags = _SUBPAD;
154
155 /* save default values in case pechochar() is the first call
156 to prefresh(). */
157
158 save_pminrow = 0;
159 save_pmincol = 0;
160 save_sminrow = 0;
161 save_smincol = 0;
162 save_smaxrow = min(LINES, nlines) - 1;
163 save_smaxcol = min(COLS, ncols) - 1;
164
165 return win;
166}
167
168int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2)
169{
170 PDC_LOG(("prefresh() - called\n"));
171
172 if (pnoutrefresh(win, py, px, sy1, sx1, sy2, sx2) == ERR)
173 return ERR;
174
175 doupdate();
176 return OK;
177}
178
179int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
180{
181 int num_cols;
182 int sline = sy1;
183 int pline = py;
184
185 PDC_LOG(("pnoutrefresh() - called\n"));
186
187 if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sx2 >= COLS))
188 return ERR;
189
190 if (py < 0)
191 py = 0;
192 if (px < 0)
193 px = 0;
194 if (sy1 < 0)
195 sy1 = 0;
196 if (sx1 < 0)
197 sx1 = 0;
198
199 if (sy2 < sy1 || sx2 < sx1)
200 return ERR;
201
202 num_cols = min((sx2 - sx1 + 1), (w->_maxx - px));
203
204 while (sline <= sy2)
205 {
206 if (pline < w->_maxy)
207 {
208 memcpy(curscr->_y[sline] + sx1, w->_y[pline] + px,
209 num_cols * sizeof(chtype));
210
211 if ((curscr->_firstch[sline] == _NO_CHANGE)
212 || (curscr->_firstch[sline] > sx1))
213 curscr->_firstch[sline] = sx1;
214
215 if (sx2 > curscr->_lastch[sline])
216 curscr->_lastch[sline] = sx2;
217
218 w->_firstch[pline] = _NO_CHANGE; /* updated now */
219 w->_lastch[pline] = _NO_CHANGE; /* updated now */
220 }
221
222 sline++;
223 pline++;
224 }
225
226 if (w->_clear)
227 {
228 w->_clear = FALSE;
229 curscr->_clear = TRUE;
230 }
231
232 /* position the cursor to the pad's current position if possible --
233 is the pad current position going to end up displayed? if not,
234 then don't move the cursor; if so, move it to the correct place */
235
236 if (!w->_leaveit && w->_cury >= py && w->_curx >= px &&
237 w->_cury <= py + (sy2 - sy1) && w->_curx <= px + (sx2 - sx1))
238 {
239 curscr->_cury = (w->_cury - py) + sy1;
240 curscr->_curx = (w->_curx - px) + sx1;
241 }
242
243 return OK;
244}
245
246int pechochar(WINDOW *pad, chtype ch)
247{
248 PDC_LOG(("pechochar() - called\n"));
249
250 if (waddch(pad, ch) == ERR)
251 return ERR;
252
253 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
254 save_smincol, save_smaxrow, save_smaxcol);
255}
256
257#ifdef PDC_WIDE
258int pecho_wchar(WINDOW *pad, const cchar_t *wch)
259{
260 PDC_LOG(("pecho_wchar() - called\n"));
261
262 if (!wch || (waddch(pad, *wch) == ERR))
263 return ERR;
264
265 return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
266 save_smincol, save_smaxrow, save_smaxcol);
267}
268#endif
269
270bool is_pad(const WINDOW *pad)
271{
272 PDC_LOG(("is_pad() - called\n"));
273
274 if (!pad)
275 return FALSE;
276
277 return (pad->_flags & _PAD) ? TRUE : FALSE;
278}
diff --git a/scripts/kconfig/libcurses/pdcclip.c b/scripts/kconfig/libcurses/pdcclip.c
new file mode 100644
index 000000000..740221280
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcclip.c
@@ -0,0 +1,149 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5#include <string.h>
6
7/*man-start**************************************************************
8
9clipboard
10---------
11
12### Synopsis
13
14 int PDC_getclipboard(char **contents, long *length);
15 int PDC_setclipboard(const char *contents, long length);
16 int PDC_freeclipboard(char *contents);
17 int PDC_clearclipboard(void);
18
19### Description
20
21 PDC_getclipboard() gets the textual contents of the system's
22 clipboard. This function returns the contents of the clipboard in the
23 contents argument. It is the responsibility of the caller to free the
24 memory returned, via PDC_freeclipboard(). The length of the clipboard
25 contents is returned in the length argument.
26
27 PDC_setclipboard copies the supplied text into the system's
28 clipboard, emptying the clipboard prior to the copy.
29
30 PDC_clearclipboard() clears the internal clipboard.
31
32### Return Values
33
34 indicator of success/failure of call.
35 PDC_CLIP_SUCCESS the call was successful
36 PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
37 the clipboard contents
38 PDC_CLIP_EMPTY the clipboard contains no text
39 PDC_CLIP_ACCESS_ERROR no clipboard support
40
41### Portability
42 X/Open ncurses NetBSD
43 PDC_getclipboard - - -
44 PDC_setclipboard - - -
45 PDC_freeclipboard - - -
46 PDC_clearclipboard - - -
47
48**man-end****************************************************************/
49
50#ifdef PDC_WIDE
51# define PDC_TEXT CF_UNICODETEXT
52#else
53# define PDC_TEXT CF_OEMTEXT
54#endif
55
56int PDC_getclipboard(char **contents, long *length)
57{
58 HANDLE handle;
59 long len;
60
61 PDC_LOG(("PDC_getclipboard() - called\n"));
62
63 if (!OpenClipboard(NULL))
64 return PDC_CLIP_ACCESS_ERROR;
65
66 if ((handle = GetClipboardData(PDC_TEXT)) == NULL)
67 {
68 CloseClipboard();
69 return PDC_CLIP_EMPTY;
70 }
71
72#ifdef PDC_WIDE
73 len = wcslen((wchar_t *)handle) * 3;
74#else
75 len = strlen((char *)handle);
76#endif
77 *contents = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
78
79 if (!*contents)
80 {
81 CloseClipboard();
82 return PDC_CLIP_MEMORY_ERROR;
83 }
84
85#ifdef PDC_WIDE
86 len = PDC_wcstombs((char *)*contents, (wchar_t *)handle, len);
87#else
88 strcpy((char *)*contents, (char *)handle);
89#endif
90 *length = len;
91 CloseClipboard();
92
93 return PDC_CLIP_SUCCESS;
94}
95
96int PDC_setclipboard(const char *contents, long length)
97{
98 HGLOBAL ptr1;
99 LPTSTR ptr2;
100
101 PDC_LOG(("PDC_setclipboard() - called\n"));
102
103 if (!OpenClipboard(NULL))
104 return PDC_CLIP_ACCESS_ERROR;
105
106 ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
107 (length + 1) * sizeof(TCHAR));
108
109 if (!ptr1)
110 return PDC_CLIP_MEMORY_ERROR;
111
112 ptr2 = GlobalLock(ptr1);
113
114#ifdef PDC_WIDE
115 PDC_mbstowcs((wchar_t *)ptr2, contents, length);
116#else
117 memcpy((char *)ptr2, contents, length + 1);
118#endif
119 GlobalUnlock(ptr1);
120 EmptyClipboard();
121
122 if (!SetClipboardData(PDC_TEXT, ptr1))
123 {
124 GlobalFree(ptr1);
125 return PDC_CLIP_ACCESS_ERROR;
126 }
127
128 CloseClipboard();
129 GlobalFree(ptr1);
130
131 return PDC_CLIP_SUCCESS;
132}
133
134int PDC_freeclipboard(char *contents)
135{
136 PDC_LOG(("PDC_freeclipboard() - called\n"));
137
138 GlobalFree(contents);
139 return PDC_CLIP_SUCCESS;
140}
141
142int PDC_clearclipboard(void)
143{
144 PDC_LOG(("PDC_clearclipboard() - called\n"));
145
146 EmptyClipboard();
147
148 return PDC_CLIP_SUCCESS;
149}
diff --git a/scripts/kconfig/libcurses/pdcdisp.c b/scripts/kconfig/libcurses/pdcdisp.c
new file mode 100644
index 000000000..a0a4a0659
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcdisp.c
@@ -0,0 +1,303 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5#include <stdlib.h>
6#include <string.h>
7
8#ifdef PDC_WIDE
9# include "acsuni.h"
10#else
11# include "acs437.h"
12#endif
13
14DWORD pdc_last_blink;
15static bool blinked_off = FALSE;
16static bool in_italic = FALSE;
17
18/* position hardware cursor at (y, x) */
19
20void PDC_gotoyx(int row, int col)
21{
22 COORD coord;
23
24 PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
25 row, col, SP->cursrow, SP->curscol));
26
27 coord.X = col;
28 coord.Y = row;
29
30 SetConsoleCursorPosition(pdc_con_out, coord);
31}
32
33void _set_ansi_color(short f, short b, attr_t attr)
34{
35 char esc[64], *p;
36 short tmp, underline;
37 bool italic;
38
39 if (f < 16 && !pdc_color[f].mapped)
40 f = pdc_curstoansi[f];
41
42 if (b < 16 && !pdc_color[b].mapped)
43 b = pdc_curstoansi[b];
44
45 if (attr & A_REVERSE)
46 {
47 tmp = f;
48 f = b;
49 b = tmp;
50 }
51 attr &= SP->termattrs;
52 italic = !!(attr & A_ITALIC);
53 underline = !!(attr & A_UNDERLINE);
54
55 p = esc + sprintf(esc, "\x1b[");
56
57 if (f != pdc_oldf)
58 {
59 if (f < 8 && !pdc_color[f].mapped)
60 p += sprintf(p, "%d", f + 30);
61 else if (f < 16 && !pdc_color[f].mapped)
62 p += sprintf(p, "%d", f + 82);
63 else if (f < 256 && !pdc_color[f].mapped)
64 p += sprintf(p, "38;5;%d", f);
65 else
66 {
67 short red = DIVROUND(pdc_color[f].r * 255, 1000);
68 short green = DIVROUND(pdc_color[f].g * 255, 1000);
69 short blue = DIVROUND(pdc_color[f].b * 255, 1000);
70
71 p += sprintf(p, "38;2;%d;%d;%d", red, green, blue);
72 }
73
74 pdc_oldf = f;
75 }
76
77 if (b != pdc_oldb)
78 {
79 if (strlen(esc) > 2)
80 p += sprintf(p, ";");
81
82 if (b < 8 && !pdc_color[b].mapped)
83 p += sprintf(p, "%d", b + 40);
84 else if (b < 16 && !pdc_color[b].mapped)
85 p += sprintf(p, "%d", b + 92);
86 else if (b < 256 && !pdc_color[b].mapped)
87 p += sprintf(p, "48;5;%d", b);
88 else
89 {
90 short red = DIVROUND(pdc_color[b].r * 255, 1000);
91 short green = DIVROUND(pdc_color[b].g * 255, 1000);
92 short blue = DIVROUND(pdc_color[b].b * 255, 1000);
93
94 p += sprintf(p, "48;2;%d;%d;%d", red, green, blue);
95 }
96
97 pdc_oldb = b;
98 }
99
100 if (italic != in_italic)
101 {
102 if (strlen(esc) > 2)
103 p += sprintf(p, ";");
104
105 if (italic)
106 p += sprintf(p, "3");
107 else
108 p += sprintf(p, "23");
109
110 in_italic = italic;
111 }
112
113 if (underline != pdc_oldu)
114 {
115 if (strlen(esc) > 2)
116 p += sprintf(p, ";");
117
118 if (underline)
119 p += sprintf(p, "4");
120 else
121 p += sprintf(p, "24");
122
123 pdc_oldu = underline;
124 }
125
126 if (strlen(esc) > 2)
127 {
128 sprintf(p, "m");
129 if (!pdc_conemu)
130 SetConsoleMode(pdc_con_out, 0x0015);
131
132 WriteConsoleA(pdc_con_out, esc, strlen(esc), NULL, NULL);
133
134 if (!pdc_conemu)
135 SetConsoleMode(pdc_con_out, 0x0010);
136 }
137}
138
139void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
140{
141 int j;
142 short fore, back;
143 bool blink, ansi;
144
145 if (pdc_ansi && (lineno == (SP->lines - 1)) && ((x + len) == SP->cols))
146 {
147 len--;
148 if (len)
149 _new_packet(attr, lineno, x, len, srcp);
150 pdc_ansi = FALSE;
151 _new_packet(attr, lineno, x + len, 1, srcp + len);
152 pdc_ansi = TRUE;
153 return;
154 }
155
156 PDC_pair_content(PAIR_NUMBER(attr), &fore, &back);
157 ansi = pdc_ansi || (fore >= 16 || back >= 16);
158 blink = (SP->termattrs & A_BLINK) && (attr & A_BLINK);
159
160 if (blink)
161 {
162 attr &= ~A_BLINK;
163 if (blinked_off)
164 attr &= ~(A_UNDERLINE | A_RIGHT | A_LEFT);
165 }
166
167 if (attr & A_BOLD)
168 fore |= 8;
169 if (attr & A_BLINK)
170 back |= 8;
171
172 if (ansi)
173 {
174#ifdef PDC_WIDE
175 WCHAR buffer[512];
176#else
177 char buffer[512];
178#endif
179 for (j = 0; j < len; j++)
180 {
181 chtype ch = srcp[j];
182
183 if (ch & A_ALTCHARSET && !(ch & 0xff80))
184 ch = acs_map[ch & 0x7f];
185
186 if (blink && blinked_off)
187 ch = ' ';
188
189 buffer[j] = ch & A_CHARTEXT;
190 }
191
192 PDC_gotoyx(lineno, x);
193 _set_ansi_color(fore, back, attr);
194#ifdef PDC_WIDE
195 WriteConsoleW(pdc_con_out, buffer, len, NULL, NULL);
196#else
197 WriteConsoleA(pdc_con_out, buffer, len, NULL, NULL);
198#endif
199 }
200 else
201 {
202 CHAR_INFO buffer[512];
203 COORD bufSize, bufPos;
204 SMALL_RECT sr;
205 WORD mapped_attr;
206
207 fore = pdc_curstoreal[fore];
208 back = pdc_curstoreal[back];
209
210 if (attr & A_REVERSE)
211 mapped_attr = back | (fore << 4);
212 else
213 mapped_attr = fore | (back << 4);
214
215 if (attr & A_UNDERLINE)
216 mapped_attr |= 0x8000; /* COMMON_LVB_UNDERSCORE */
217 if (attr & A_LEFT)
218 mapped_attr |= 0x0800; /* COMMON_LVB_GRID_LVERTICAL */
219 if (attr & A_RIGHT)
220 mapped_attr |= 0x1000; /* COMMON_LVB_GRID_RVERTICAL */
221
222 for (j = 0; j < len; j++)
223 {
224 chtype ch = srcp[j];
225
226 if (ch & A_ALTCHARSET && !(ch & 0xff80))
227 ch = acs_map[ch & 0x7f];
228
229 if (blink && blinked_off)
230 ch = ' ';
231
232 buffer[j].Attributes = mapped_attr;
233 buffer[j].Char.UnicodeChar = ch & A_CHARTEXT;
234 }
235
236 bufPos.X = bufPos.Y = 0;
237 bufSize.X = len;
238 bufSize.Y = 1;
239
240 sr.Top = sr.Bottom = lineno;
241 sr.Left = x;
242 sr.Right = x + len - 1;
243
244 WriteConsoleOutput(pdc_con_out, buffer, bufSize, bufPos, &sr);
245 }
246}
247
248/* update the given physical line to look like the corresponding line in
249 curscr */
250
251void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
252{
253 attr_t old_attr, attr;
254 int i, j;
255
256 PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
257
258 old_attr = *srcp & (A_ATTRIBUTES ^ A_ALTCHARSET);
259
260 for (i = 1, j = 1; j < len; i++, j++)
261 {
262 attr = srcp[i] & (A_ATTRIBUTES ^ A_ALTCHARSET);
263
264 if (attr != old_attr)
265 {
266 _new_packet(old_attr, lineno, x, i, srcp);
267 old_attr = attr;
268 srcp += i;
269 x += i;
270 i = 0;
271 }
272 }
273
274 _new_packet(old_attr, lineno, x, i, srcp);
275}
276
277void PDC_blink_text(void)
278{
279 int i, j, k;
280
281 if (!(SP->termattrs & A_BLINK))
282 blinked_off = FALSE;
283 else
284 blinked_off = !blinked_off;
285
286 for (i = 0; i < SP->lines; i++)
287 {
288 const chtype *srcp = curscr->_y[i];
289
290 for (j = 0; j < SP->cols; j++)
291 if (srcp[j] & A_BLINK)
292 {
293 k = j;
294 while (k < SP->cols && (srcp[k] & A_BLINK))
295 k++;
296 PDC_transform_line(i, j, k - j, srcp + j);
297 j = k;
298 }
299 }
300
301 PDC_gotoyx(SP->cursrow, SP->curscol);
302 pdc_last_blink = GetTickCount();
303}
diff --git a/scripts/kconfig/libcurses/pdcgetsc.c b/scripts/kconfig/libcurses/pdcgetsc.c
new file mode 100644
index 000000000..a8323ebc1
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcgetsc.c
@@ -0,0 +1,42 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5/* get the cursor size/shape */
6
7int PDC_get_cursor_mode(void)
8{
9 CONSOLE_CURSOR_INFO ci;
10
11 PDC_LOG(("PDC_get_cursor_mode() - called\n"));
12
13 GetConsoleCursorInfo(pdc_con_out, &ci);
14
15 return ci.dwSize;
16}
17
18/* return number of screen rows */
19
20int PDC_get_rows(void)
21{
22 CONSOLE_SCREEN_BUFFER_INFO scr;
23
24 PDC_LOG(("PDC_get_rows() - called\n"));
25
26 GetConsoleScreenBufferInfo(pdc_con_out, &scr);
27
28 return scr.srWindow.Bottom - scr.srWindow.Top + 1;
29}
30
31/* return width of screen/viewport */
32
33int PDC_get_columns(void)
34{
35 CONSOLE_SCREEN_BUFFER_INFO scr;
36
37 PDC_LOG(("PDC_get_columns() - called\n"));
38
39 GetConsoleScreenBufferInfo(pdc_con_out, &scr);
40
41 return scr.srWindow.Right - scr.srWindow.Left + 1;
42}
diff --git a/scripts/kconfig/libcurses/pdckbd.c b/scripts/kconfig/libcurses/pdckbd.c
new file mode 100644
index 000000000..958697140
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdckbd.c
@@ -0,0 +1,681 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5/*man-start**************************************************************
6
7pdckbd
8------
9
10### Synopsis
11
12 unsigned long PDC_get_input_fd(void);
13
14### Description
15
16 PDC_get_input_fd() returns the file descriptor that PDCurses reads
17 its input from. It can be used for select().
18
19### Portability
20 X/Open ncurses NetBSD
21 PDC_get_input_fd - - -
22
23**man-end****************************************************************/
24
25/* These variables are used to store information about the next
26 Input Event. */
27
28static INPUT_RECORD save_ip;
29static MOUSE_STATUS old_mouse_status;
30static DWORD event_count = 0;
31static SHORT left_key;
32static int key_count = 0;
33static int save_press = 0;
34
35#define KEV save_ip.Event.KeyEvent
36#define MEV save_ip.Event.MouseEvent
37#define REV save_ip.Event.WindowBufferSizeEvent
38
39/************************************************************************
40 * Table for key code translation of function keys in keypad mode *
41 * These values are for strict IBM keyboard compatibles only *
42 ************************************************************************/
43
44typedef struct
45{
46 unsigned short normal;
47 unsigned short shift;
48 unsigned short control;
49 unsigned short alt;
50 unsigned short extended;
51} KPTAB;
52
53static KPTAB kptab[] =
54{
55 {0, 0, 0, 0, 0 }, /* 0 */
56 {0, 0, 0, 0, 0 }, /* 1 VK_LBUTTON */
57 {0, 0, 0, 0, 0 }, /* 2 VK_RBUTTON */
58 {0, 0, 0, 0, 0 }, /* 3 VK_CANCEL */
59 {0, 0, 0, 0, 0 }, /* 4 VK_MBUTTON */
60 {0, 0, 0, 0, 0 }, /* 5 */
61 {0, 0, 0, 0, 0 }, /* 6 */
62 {0, 0, 0, 0, 0 }, /* 7 */
63 {0x08, 0x08, 0x7F, ALT_BKSP, 0 }, /* 8 VK_BACK */
64 {0x09, KEY_BTAB, CTL_TAB, ALT_TAB, 999 }, /* 9 VK_TAB */
65 {0, 0, 0, 0, 0 }, /* 10 */
66 {0, 0, 0, 0, 0 }, /* 11 */
67 {KEY_B2, 0x35, CTL_PAD5, ALT_PAD5, 0 }, /* 12 VK_CLEAR */
68 {0x0D, 0x0D, CTL_ENTER, ALT_ENTER, 1 }, /* 13 VK_RETURN */
69 {0, 0, 0, 0, 0 }, /* 14 */
70 {0, 0, 0, 0, 0 }, /* 15 */
71 {0, 0, 0, 0, 0 }, /* 16 VK_SHIFT HANDLED SEPARATELY */
72 {0, 0, 0, 0, 0 }, /* 17 VK_CONTROL HANDLED SEPARATELY */
73 {0, 0, 0, 0, 0 }, /* 18 VK_MENU HANDLED SEPARATELY */
74 {0, 0, 0, 0, 0 }, /* 19 VK_PAUSE */
75 {0, 0, 0, 0, 0 }, /* 20 VK_CAPITAL HANDLED SEPARATELY */
76 {0, 0, 0, 0, 0 }, /* 21 VK_HANGUL */
77 {0, 0, 0, 0, 0 }, /* 22 */
78 {0, 0, 0, 0, 0 }, /* 23 VK_JUNJA */
79 {0, 0, 0, 0, 0 }, /* 24 VK_FINAL */
80 {0, 0, 0, 0, 0 }, /* 25 VK_HANJA */
81 {0, 0, 0, 0, 0 }, /* 26 */
82 {0x1B, 0x1B, 0x1B, ALT_ESC, 0 }, /* 27 VK_ESCAPE */
83 {0, 0, 0, 0, 0 }, /* 28 VK_CONVERT */
84 {0, 0, 0, 0, 0 }, /* 29 VK_NONCONVERT */
85 {0, 0, 0, 0, 0 }, /* 30 VK_ACCEPT */
86 {0, 0, 0, 0, 0 }, /* 31 VK_MODECHANGE */
87 {0x20, 0x20, 0x20, 0x20, 0 }, /* 32 VK_SPACE */
88 {KEY_A3, 0x39, CTL_PAD9, ALT_PAD9, 3 }, /* 33 VK_PRIOR */
89 {KEY_C3, 0x33, CTL_PAD3, ALT_PAD3, 4 }, /* 34 VK_NEXT */
90 {KEY_C1, 0x31, CTL_PAD1, ALT_PAD1, 5 }, /* 35 VK_END */
91 {KEY_A1, 0x37, CTL_PAD7, ALT_PAD7, 6 }, /* 36 VK_HOME */
92 {KEY_B1, 0x34, CTL_PAD4, ALT_PAD4, 7 }, /* 37 VK_LEFT */
93 {KEY_A2, 0x38, CTL_PAD8, ALT_PAD8, 8 }, /* 38 VK_UP */
94 {KEY_B3, 0x36, CTL_PAD6, ALT_PAD6, 9 }, /* 39 VK_RIGHT */
95 {KEY_C2, 0x32, CTL_PAD2, ALT_PAD2, 10 }, /* 40 VK_DOWN */
96 {0, 0, 0, 0, 0 }, /* 41 VK_SELECT */
97 {0, 0, 0, 0, 0 }, /* 42 VK_PRINT */
98 {0, 0, 0, 0, 0 }, /* 43 VK_EXECUTE */
99 {0, 0, 0, 0, 0 }, /* 44 VK_SNAPSHOT*/
100 {PAD0, 0x30, CTL_PAD0, ALT_PAD0, 11 }, /* 45 VK_INSERT */
101 {PADSTOP, 0x2E, CTL_PADSTOP, ALT_PADSTOP,12 }, /* 46 VK_DELETE */
102 {0, 0, 0, 0, 0 }, /* 47 VK_HELP */
103 {0x30, 0x29, 0, ALT_0, 0 }, /* 48 */
104 {0x31, 0x21, 0, ALT_1, 0 }, /* 49 */
105 {0x32, 0x40, 0, ALT_2, 0 }, /* 50 */
106 {0x33, 0x23, 0, ALT_3, 0 }, /* 51 */
107 {0x34, 0x24, 0, ALT_4, 0 }, /* 52 */
108 {0x35, 0x25, 0, ALT_5, 0 }, /* 53 */
109 {0x36, 0x5E, 0, ALT_6, 0 }, /* 54 */
110 {0x37, 0x26, 0, ALT_7, 0 }, /* 55 */
111 {0x38, 0x2A, 0, ALT_8, 0 }, /* 56 */
112 {0x39, 0x28, 0, ALT_9, 0 }, /* 57 */
113 {0, 0, 0, 0, 0 }, /* 58 */
114 {0, 0, 0, 0, 0 }, /* 59 */
115 {0, 0, 0, 0, 0 }, /* 60 */
116 {0, 0, 0, 0, 0 }, /* 61 */
117 {0, 0, 0, 0, 0 }, /* 62 */
118 {0, 0, 0, 0, 0 }, /* 63 */
119 {0, 0, 0, 0, 0 }, /* 64 */
120 {0x61, 0x41, 0x01, ALT_A, 0 }, /* 65 */
121 {0x62, 0x42, 0x02, ALT_B, 0 }, /* 66 */
122 {0x63, 0x43, 0x03, ALT_C, 0 }, /* 67 */
123 {0x64, 0x44, 0x04, ALT_D, 0 }, /* 68 */
124 {0x65, 0x45, 0x05, ALT_E, 0 }, /* 69 */
125 {0x66, 0x46, 0x06, ALT_F, 0 }, /* 70 */
126 {0x67, 0x47, 0x07, ALT_G, 0 }, /* 71 */
127 {0x68, 0x48, 0x08, ALT_H, 0 }, /* 72 */
128 {0x69, 0x49, 0x09, ALT_I, 0 }, /* 73 */
129 {0x6A, 0x4A, 0x0A, ALT_J, 0 }, /* 74 */
130 {0x6B, 0x4B, 0x0B, ALT_K, 0 }, /* 75 */
131 {0x6C, 0x4C, 0x0C, ALT_L, 0 }, /* 76 */
132 {0x6D, 0x4D, 0x0D, ALT_M, 0 }, /* 77 */
133 {0x6E, 0x4E, 0x0E, ALT_N, 0 }, /* 78 */
134 {0x6F, 0x4F, 0x0F, ALT_O, 0 }, /* 79 */
135 {0x70, 0x50, 0x10, ALT_P, 0 }, /* 80 */
136 {0x71, 0x51, 0x11, ALT_Q, 0 }, /* 81 */
137 {0x72, 0x52, 0x12, ALT_R, 0 }, /* 82 */
138 {0x73, 0x53, 0x13, ALT_S, 0 }, /* 83 */
139 {0x74, 0x54, 0x14, ALT_T, 0 }, /* 84 */
140 {0x75, 0x55, 0x15, ALT_U, 0 }, /* 85 */
141 {0x76, 0x56, 0x16, ALT_V, 0 }, /* 86 */
142 {0x77, 0x57, 0x17, ALT_W, 0 }, /* 87 */
143 {0x78, 0x58, 0x18, ALT_X, 0 }, /* 88 */
144 {0x79, 0x59, 0x19, ALT_Y, 0 }, /* 89 */
145 {0x7A, 0x5A, 0x1A, ALT_Z, 0 }, /* 90 */
146 {0, 0, 0, 0, 0 }, /* 91 VK_LWIN */
147 {0, 0, 0, 0, 0 }, /* 92 VK_RWIN */
148 {0, 0, 0, 0, 0 }, /* 93 VK_APPS */
149 {0, 0, 0, 0, 0 }, /* 94 */
150 {0, 0, 0, 0, 0 }, /* 95 */
151 {0x30, 0, CTL_PAD0, ALT_PAD0, 0 }, /* 96 VK_NUMPAD0 */
152 {0x31, 0, CTL_PAD1, ALT_PAD1, 0 }, /* 97 VK_NUMPAD1 */
153 {0x32, 0, CTL_PAD2, ALT_PAD2, 0 }, /* 98 VK_NUMPAD2 */
154 {0x33, 0, CTL_PAD3, ALT_PAD3, 0 }, /* 99 VK_NUMPAD3 */
155 {0x34, 0, CTL_PAD4, ALT_PAD4, 0 }, /* 100 VK_NUMPAD4 */
156 {0x35, 0, CTL_PAD5, ALT_PAD5, 0 }, /* 101 VK_NUMPAD5 */
157 {0x36, 0, CTL_PAD6, ALT_PAD6, 0 }, /* 102 VK_NUMPAD6 */
158 {0x37, 0, CTL_PAD7, ALT_PAD7, 0 }, /* 103 VK_NUMPAD7 */
159 {0x38, 0, CTL_PAD8, ALT_PAD8, 0 }, /* 104 VK_NUMPAD8 */
160 {0x39, 0, CTL_PAD9, ALT_PAD9, 0 }, /* 105 VK_NUMPAD9 */
161 {PADSTAR, SHF_PADSTAR,CTL_PADSTAR, ALT_PADSTAR,999 }, /* 106 VK_MULTIPLY*/
162 {PADPLUS, SHF_PADPLUS,CTL_PADPLUS, ALT_PADPLUS,999 }, /* 107 VK_ADD */
163 {0, 0, 0, 0, 0 }, /* 108 VK_SEPARATOR */
164 {PADMINUS, SHF_PADMINUS,CTL_PADMINUS,ALT_PADMINUS,999}, /* 109 VK_SUBTRACT*/
165 {0x2E, 0, CTL_PADSTOP, ALT_PADSTOP,0 }, /* 110 VK_DECIMAL */
166 {PADSLASH, SHF_PADSLASH,CTL_PADSLASH,ALT_PADSLASH,2 }, /* 111 VK_DIVIDE */
167 {KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37), 0 }, /* 112 VK_F1 */
168 {KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38), 0 }, /* 113 VK_F2 */
169 {KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39), 0 }, /* 114 VK_F3 */
170 {KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40), 0 }, /* 115 VK_F4 */
171 {KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41), 0 }, /* 116 VK_F5 */
172 {KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42), 0 }, /* 117 VK_F6 */
173 {KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43), 0 }, /* 118 VK_F7 */
174 {KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44), 0 }, /* 119 VK_F8 */
175 {KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45), 0 }, /* 120 VK_F9 */
176 {KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46), 0 }, /* 121 VK_F10 */
177 {KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47), 0 }, /* 122 VK_F11 */
178 {KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48), 0 }, /* 123 VK_F12 */
179
180 /* 124 through 218 */
181
182 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
183 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
184 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
185 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
186 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
187 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
188 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
189 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
190 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
191 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
192 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
193 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
194 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
195 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
196 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
197 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
198 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
199 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
200 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
201 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
202 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
203 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
204 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
205 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
206
207 {0x5B, 0x7B, 0x1B, ALT_LBRACKET,0 }, /* 219 */
208 {0x5C, 0x7C, 0x1C, ALT_BSLASH, 0 }, /* 220 */
209 {0x5D, 0x7D, 0x1D, ALT_RBRACKET,0 }, /* 221 */
210 {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */
211 {0, 0, 0, 0, 0 }, /* 223 */
212 {0, 0, 0, 0, 0 }, /* 224 */
213 {0, 0, 0, 0, 0 } /* 225 */
214};
215
216static KPTAB ext_kptab[] =
217{
218 {0, 0, 0, 0, }, /* MUST BE EMPTY */
219 {PADENTER, SHF_PADENTER, CTL_PADENTER, ALT_PADENTER}, /* 13 */
220 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 111 */
221 {KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP }, /* 33 */
222 {KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN }, /* 34 */
223 {KEY_END, KEY_SEND, CTL_END, ALT_END }, /* 35 */
224 {KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME }, /* 36 */
225 {KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT }, /* 37 */
226 {KEY_UP, KEY_SUP, CTL_UP, ALT_UP }, /* 38 */
227 {KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT }, /* 39 */
228 {KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN }, /* 40 */
229 {KEY_IC, KEY_SIC, CTL_INS, ALT_INS }, /* 45 */
230 {KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL }, /* 46 */
231 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 191 */
232};
233
234/* End of kptab[] */
235
236unsigned long PDC_get_input_fd(void)
237{
238 PDC_LOG(("PDC_get_input_fd() - called\n"));
239
240 return 0L;
241}
242
243void PDC_set_keyboard_binary(bool on)
244{
245 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
246}
247
248/* check if a key or mouse event is waiting */
249
250bool PDC_check_key(void)
251{
252 if (key_count > 0)
253 return TRUE;
254
255 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
256
257 return (event_count != 0);
258}
259
260/* _get_key_count returns 0 if save_ip doesn't contain an event which
261 should be passed back to the user. This function filters "useless"
262 events.
263
264 The function returns the number of keys waiting. This may be > 1
265 if the repetition of real keys pressed so far are > 1.
266
267 Returns 0 on NUMLOCK, CAPSLOCK, SCROLLLOCK.
268
269 Returns 1 for SHIFT, ALT, CTRL only if no other key has been pressed
270 in between, and SP->return_key_modifiers is set; these are returned
271 on keyup.
272
273 Normal keys are returned on keydown only. The number of repetitions
274 are returned. Dead keys (diacritics) are omitted. See below for a
275 description.
276*/
277
278static int _get_key_count(void)
279{
280 int num_keys = 0, vk;
281
282 PDC_LOG(("_get_key_count() - called\n"));
283
284 vk = KEV.wVirtualKeyCode;
285
286 if (KEV.bKeyDown)
287 {
288 /* key down */
289
290 save_press = 0;
291
292 if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
293 {
294 /* throw away these modifiers */
295 }
296 else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
297 {
298 /* These keys are returned on keyup only. */
299
300 save_press = vk;
301 switch (vk)
302 {
303 case VK_SHIFT:
304 left_key = GetKeyState(VK_LSHIFT);
305 break;
306 case VK_CONTROL:
307 left_key = GetKeyState(VK_LCONTROL);
308 break;
309 case VK_MENU:
310 left_key = GetKeyState(VK_LMENU);
311 }
312 }
313 else
314 {
315 /* Check for diacritics. These are dead keys. Some locales
316 have modified characters like umlaut-a, which is an "a"
317 with two dots on it. In some locales you have to press a
318 special key (the dead key) immediately followed by the
319 "a" to get a composed umlaut-a. The special key may have
320 a normal meaning with different modifiers. */
321
322 if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
323 num_keys = KEV.wRepeatCount;
324 }
325 }
326 else
327 {
328 /* key up */
329
330 /* Only modifier keys or the results of ALT-numpad entry are
331 returned on keyup */
332
333 if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
334 ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
335 vk == save_press))
336 {
337 save_press = 0;
338 num_keys = 1;
339 }
340 }
341
342 PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));
343
344 return num_keys;
345}
346
347/* _process_key_event returns -1 if the key in save_ip should be
348 ignored. Otherwise it returns the keycode which should be returned
349 by PDC_get_key(). save_ip must be a key event.
350
351 CTRL-ALT support has been disabled, when is it emitted plainly? */
352
353static int _process_key_event(void)
354{
355 int key = (unsigned short)KEV.uChar.UnicodeChar;
356 WORD vk = KEV.wVirtualKeyCode;
357 DWORD state = KEV.dwControlKeyState;
358
359 int idx;
360 BOOL enhanced;
361
362 SP->key_code = TRUE;
363
364 /* Save the key modifiers. Do this first to allow to detect e.g. a
365 pressed CTRL key after a hit of NUMLOCK. */
366
367 if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
368 SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
369
370 if (state & SHIFT_PRESSED)
371 SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
372
373 if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
374 SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
375
376 if (state & NUMLOCK_ON)
377 SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
378
379 /* Handle modifier keys hit by themselves */
380
381 switch (vk)
382 {
383 case VK_SHIFT: /* shift */
384 if (!SP->return_key_modifiers)
385 return -1;
386
387 return (left_key & 0x8000) ? KEY_SHIFT_L : KEY_SHIFT_R;
388
389 case VK_CONTROL: /* control */
390 if (!SP->return_key_modifiers)
391 return -1;
392
393 return (left_key & 0x8000) ? KEY_CONTROL_L : KEY_CONTROL_R;
394
395 case VK_MENU: /* alt */
396 if (!key)
397 {
398 if (!SP->return_key_modifiers)
399 return -1;
400
401 return (left_key & 0x8000) ? KEY_ALT_L : KEY_ALT_R;
402 }
403 }
404
405 /* The system may emit Ascii or Unicode characters depending on
406 whether ReadConsoleInputA or ReadConsoleInputW is used.
407
408 Normally, if key != 0 then the system did the translation
409 successfully. But this is not true for LEFT_ALT (different to
410 RIGHT_ALT). In case of LEFT_ALT we can get key != 0. So
411 check for this first. */
412
413 if (key && ( !(state & LEFT_ALT_PRESSED) ||
414 (state & RIGHT_ALT_PRESSED) ))
415 {
416 /* This code should catch all keys returning a printable
417 character. Characters above 0x7F should be returned as
418 positive codes. */
419
420 if (kptab[vk].extended == 0)
421 {
422 SP->key_code = FALSE;
423 return key;
424 }
425 }
426
427 /* This case happens if a functional key has been entered. */
428
429 if ((state & ENHANCED_KEY) && (kptab[vk].extended != 999))
430 {
431 enhanced = TRUE;
432 idx = kptab[vk].extended;
433 }
434 else
435 {
436 enhanced = FALSE;
437 idx = vk;
438 }
439
440 if (state & SHIFT_PRESSED)
441 key = enhanced ? ext_kptab[idx].shift : kptab[idx].shift;
442
443 else if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
444 key = enhanced ? ext_kptab[idx].control : kptab[idx].control;
445
446 else if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
447 key = enhanced ? ext_kptab[idx].alt : kptab[idx].alt;
448
449 else
450 key = enhanced ? ext_kptab[idx].normal : kptab[idx].normal;
451
452 if (key < KEY_CODE_YES)
453 SP->key_code = FALSE;
454
455 return key;
456}
457
458static int _process_mouse_event(void)
459{
460 static const DWORD button_mask[] = {1, 4, 2};
461 short action, shift_flags = 0;
462 int i;
463
464 save_press = 0;
465 SP->key_code = TRUE;
466
467 memset(&SP->mouse_status, 0, sizeof(MOUSE_STATUS));
468
469 /* Handle scroll wheel */
470
471 if (MEV.dwEventFlags == 4)
472 {
473 SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
474 PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
475
476 SP->mouse_status.x = -1;
477 SP->mouse_status.y = -1;
478
479 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
480
481 return KEY_MOUSE;
482 }
483
484 if (MEV.dwEventFlags == 8)
485 {
486 SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
487 PDC_MOUSE_WHEEL_RIGHT : PDC_MOUSE_WHEEL_LEFT;
488
489 SP->mouse_status.x = -1;
490 SP->mouse_status.y = -1;
491
492 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
493
494 return KEY_MOUSE;
495 }
496
497 action = (MEV.dwEventFlags == 2) ? BUTTON_DOUBLE_CLICKED :
498 ((MEV.dwEventFlags == 1) ? BUTTON_MOVED : BUTTON_PRESSED);
499
500 for (i = 0; i < 3; i++)
501 SP->mouse_status.button[i] =
502 (MEV.dwButtonState & button_mask[i]) ? action : 0;
503
504 if (action == BUTTON_PRESSED && MEV.dwButtonState & 7 && SP->mouse_wait)
505 {
506 /* Check for a click -- a PRESS followed immediately by a release */
507
508 if (!event_count)
509 {
510 napms(SP->mouse_wait);
511
512 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
513 }
514
515 if (event_count)
516 {
517 INPUT_RECORD ip;
518 DWORD count;
519 bool have_click = FALSE;
520
521 PeekConsoleInput(pdc_con_in, &ip, 1, &count);
522
523 for (i = 0; i < 3; i++)
524 {
525 if (SP->mouse_status.button[i] == BUTTON_PRESSED &&
526 !(ip.Event.MouseEvent.dwButtonState & button_mask[i]))
527 {
528 SP->mouse_status.button[i] = BUTTON_CLICKED;
529 have_click = TRUE;
530 }
531 }
532
533 /* If a click was found, throw out the event */
534
535 if (have_click)
536 ReadConsoleInput(pdc_con_in, &ip, 1, &count);
537 }
538 }
539
540 SP->mouse_status.x = MEV.dwMousePosition.X;
541 SP->mouse_status.y = MEV.dwMousePosition.Y;
542
543 SP->mouse_status.changes = 0;
544
545 for (i = 0; i < 3; i++)
546 {
547 if (old_mouse_status.button[i] != SP->mouse_status.button[i])
548 SP->mouse_status.changes |= (1 << i);
549
550 if (SP->mouse_status.button[i] == BUTTON_MOVED)
551 {
552 /* Discard non-moved "moves" */
553
554 if (SP->mouse_status.x == old_mouse_status.x &&
555 SP->mouse_status.y == old_mouse_status.y)
556 return -1;
557
558 /* Motion events always flag the button as changed */
559
560 SP->mouse_status.changes |= (1 << i);
561 SP->mouse_status.changes |= PDC_MOUSE_MOVED;
562 break;
563 }
564 }
565
566 old_mouse_status = SP->mouse_status;
567
568 /* Treat click events as release events for comparison purposes */
569
570 for (i = 0; i < 3; i++)
571 {
572 if (old_mouse_status.button[i] == BUTTON_CLICKED ||
573 old_mouse_status.button[i] == BUTTON_DOUBLE_CLICKED)
574 old_mouse_status.button[i] = BUTTON_RELEASED;
575 }
576
577 /* Check for SHIFT/CONTROL/ALT */
578
579 if (MEV.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
580 shift_flags |= BUTTON_ALT;
581
582 if (MEV.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
583 shift_flags |= BUTTON_CONTROL;
584
585 if (MEV.dwControlKeyState & SHIFT_PRESSED)
586 shift_flags |= BUTTON_SHIFT;
587
588 if (shift_flags)
589 {
590 for (i = 0; i < 3; i++)
591 {
592 if (SP->mouse_status.changes & (1 << i))
593 SP->mouse_status.button[i] |= shift_flags;
594 }
595 }
596
597 return KEY_MOUSE;
598}
599
600/* return the next available key or mouse event */
601
602int PDC_get_key(void)
603{
604 SP->key_modifiers = 0L;
605
606 if (!key_count)
607 {
608 DWORD count;
609
610 ReadConsoleInput(pdc_con_in, &save_ip, 1, &count);
611 event_count--;
612
613 if (save_ip.EventType == MOUSE_EVENT ||
614 save_ip.EventType == WINDOW_BUFFER_SIZE_EVENT)
615 key_count = 1;
616 else if (save_ip.EventType == KEY_EVENT)
617 key_count = _get_key_count();
618 }
619
620 if (key_count)
621 {
622 key_count--;
623
624 switch (save_ip.EventType)
625 {
626 case KEY_EVENT:
627 return _process_key_event();
628
629 case MOUSE_EVENT:
630 return _process_mouse_event();
631
632 case WINDOW_BUFFER_SIZE_EVENT:
633 if (REV.dwSize.Y != LINES || REV.dwSize.X != COLS)
634 {
635 if (!SP->resized)
636 {
637 SP->resized = TRUE;
638 SP->key_code = TRUE;
639 return KEY_RESIZE;
640 }
641 }
642 }
643 }
644
645 return -1;
646}
647
648/* discard any pending keyboard or mouse input -- this is the core
649 routine for flushinp() */
650
651void PDC_flushinp(void)
652{
653 PDC_LOG(("PDC_flushinp() - called\n"));
654
655 FlushConsoleInputBuffer(pdc_con_in);
656}
657
658bool PDC_has_mouse(void)
659{
660 return TRUE;
661}
662
663int PDC_mouse_set(void)
664{
665 /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
666 all other flags, including the extended flags;
667 If turning off the mouse: Set QuickEdit Mode to the status it
668 had on startup, and clear all other flags */
669
670 SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
671 (ENABLE_MOUSE_INPUT|0x0088) : (pdc_quick_edit|0x0088));
672
673 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
674
675 return OK;
676}
677
678int PDC_modifiers_set(void)
679{
680 return OK;
681}
diff --git a/scripts/kconfig/libcurses/pdcscrn.c b/scripts/kconfig/libcurses/pdcscrn.c
new file mode 100644
index 000000000..e6640a379
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcscrn.c
@@ -0,0 +1,733 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5#include <stdlib.h>
6
7/* COLOR_PAIR to attribute encoding table. */
8
9static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
10
11/* Color component table */
12
13PDCCOLOR pdc_color[PDC_MAXCOL];
14
15HANDLE std_con_out = INVALID_HANDLE_VALUE;
16HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
17HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
18
19DWORD pdc_quick_edit;
20
21static short realtocurs[16] =
22{
23 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
24 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
25 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
26 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
27};
28
29static short ansitocurs[16] =
30{
31 COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE,
32 COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE, COLOR_BLACK + 8,
33 COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, COLOR_BLUE + 8,
34 COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8
35};
36
37short pdc_curstoreal[16], pdc_curstoansi[16];
38short pdc_oldf, pdc_oldb, pdc_oldu;
39bool pdc_conemu, pdc_ansi;
40
41enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER };
42
43/* Struct for storing console registry keys, and for use with the
44 undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
45 www.catch22.net. */
46
47static struct
48{
49 ULONG Length;
50 COORD ScreenBufferSize;
51 COORD WindowSize;
52 ULONG WindowPosX;
53 ULONG WindowPosY;
54
55 COORD FontSize;
56 ULONG FontFamily;
57 ULONG FontWeight;
58 WCHAR FaceName[32];
59
60 ULONG CursorSize;
61 ULONG FullScreen;
62 ULONG QuickEdit;
63 ULONG AutoPosition;
64 ULONG InsertMode;
65
66 USHORT ScreenColors;
67 USHORT PopupColors;
68 ULONG HistoryNoDup;
69 ULONG HistoryBufferSize;
70 ULONG NumberOfHistoryBuffers;
71
72 COLORREF ColorTable[16];
73
74 ULONG CodePage;
75 HWND Hwnd;
76
77 WCHAR ConsoleTitle[0x100];
78} console_info;
79
80#ifdef HAVE_NO_INFOEX
81/* Console screen buffer information (extended version) */
82typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
83 ULONG cbSize;
84 COORD dwSize;
85 COORD dwCursorPosition;
86 WORD wAttributes;
87 SMALL_RECT srWindow;
88 COORD dwMaximumWindowSize;
89 WORD wPopupAttributes;
90 BOOL bFullscreenSupported;
91 COLORREF ColorTable[16];
92} CONSOLE_SCREEN_BUFFER_INFOEX;
93typedef CONSOLE_SCREEN_BUFFER_INFOEX *PCONSOLE_SCREEN_BUFFER_INFOEX;
94#endif
95
96typedef BOOL (WINAPI *SetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
97 PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
98typedef BOOL (WINAPI *GetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
99 PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
100
101static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
102static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
103
104static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
105static CONSOLE_SCREEN_BUFFER_INFOEX console_infoex;
106
107static LPTOP_LEVEL_EXCEPTION_FILTER xcpt_filter;
108
109static DWORD old_console_mode = 0;
110
111static bool is_nt;
112
113static void _reset_old_colors(void)
114{
115 pdc_oldf = -1;
116 pdc_oldb = -1;
117 pdc_oldu = 0;
118}
119
120static HWND _find_console_handle(void)
121{
122 TCHAR orgtitle[1024], temptitle[1024];
123 HWND wnd;
124
125 GetConsoleTitle(orgtitle, 1024);
126
127 wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
128 SetConsoleTitle(temptitle);
129
130 Sleep(40);
131
132 wnd = FindWindow(NULL, temptitle);
133
134 SetConsoleTitle(orgtitle);
135
136 return wnd;
137}
138
139/* Undocumented console message */
140
141#define WM_SETCONSOLEINFO (WM_USER + 201)
142
143/* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
144 section (file-mapping) object in the context of the process which
145 owns the console, before posting the message. Originally by JB. */
146
147static void _set_console_info(void)
148{
149 CONSOLE_SCREEN_BUFFER_INFO csbi;
150 CONSOLE_CURSOR_INFO cci;
151 DWORD dwConsoleOwnerPid;
152 HANDLE hProcess;
153 HANDLE hSection, hDupSection;
154 PVOID ptrView;
155
156 /* Each-time initialization for console_info */
157
158 GetConsoleCursorInfo(pdc_con_out, &cci);
159 console_info.CursorSize = cci.dwSize;
160
161 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
162 console_info.ScreenBufferSize = csbi.dwSize;
163
164 console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
165 console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
166
167 console_info.WindowPosX = csbi.srWindow.Left;
168 console_info.WindowPosY = csbi.srWindow.Top;
169
170 /* Open the process which "owns" the console */
171
172 GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
173
174 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
175
176 /* Create a SECTION object backed by page-file, then map a view of
177 this section into the owner process so we can write the contents
178 of the CONSOLE_INFO buffer into it */
179
180 hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
181 0, sizeof(console_info), 0);
182
183 /* Copy our console structure into the section-object */
184
185 ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
186 0, 0, sizeof(console_info));
187
188 memcpy(ptrView, &console_info, sizeof(console_info));
189
190 UnmapViewOfFile(ptrView);
191
192 /* Map the memory into owner process */
193
194 DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
195 0, FALSE, DUPLICATE_SAME_ACCESS);
196
197 /* Send console window the "update" message */
198
199 SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
200
201 CloseHandle(hSection);
202 CloseHandle(hProcess);
203}
204
205static int _set_console_infoex(void)
206{
207 if (!pSetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
208 return ERR;
209
210 return OK;
211}
212
213static int _set_colors(void)
214{
215 SetConsoleTextAttribute(pdc_con_out, 7);
216 _reset_old_colors();
217
218 if (pSetConsoleScreenBufferInfoEx)
219 return _set_console_infoex();
220 else
221 {
222 _set_console_info();
223 return OK;
224 }
225}
226
227/* One-time initialization for console_info -- color table and font info
228 from the registry; other values from functions. */
229
230static void _init_console_info(void)
231{
232 DWORD scrnmode, len;
233 HKEY reghnd;
234 int i;
235
236 console_info.Hwnd = _find_console_handle();
237 console_info.Length = sizeof(console_info);
238
239 GetConsoleMode(pdc_con_in, &scrnmode);
240 console_info.QuickEdit = !!(scrnmode & 0x0040);
241 console_info.InsertMode = !!(scrnmode & 0x0020);
242
243 console_info.FullScreen = FALSE;
244 console_info.AutoPosition = 0x10000;
245 console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
246 console_info.PopupColors = 0xf5;
247
248 console_info.HistoryNoDup = FALSE;
249 console_info.HistoryBufferSize = 50;
250 console_info.NumberOfHistoryBuffers = 4;
251
252 console_info.CodePage = GetConsoleOutputCP();
253
254 RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
255 KEY_QUERY_VALUE, &reghnd);
256
257 len = sizeof(DWORD);
258
259 /* Default color table */
260
261 for (i = 0; i < 16; i++)
262 {
263 char tname[13];
264
265 sprintf(tname, "ColorTable%02d", i);
266 RegQueryValueExA(reghnd, tname, NULL, NULL,
267 (LPBYTE)(&(console_info.ColorTable[i])), &len);
268 }
269
270 /* Font info */
271
272 RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
273 (LPBYTE)(&console_info.FontSize), &len);
274 RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
275 (LPBYTE)(&console_info.FontFamily), &len);
276 RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
277 (LPBYTE)(&console_info.FontWeight), &len);
278
279 len = sizeof(WCHAR) * 32;
280 RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
281 (LPBYTE)(console_info.FaceName), &len);
282
283 RegCloseKey(reghnd);
284}
285
286static int _init_console_infoex(void)
287{
288 console_infoex.cbSize = sizeof(console_infoex);
289
290 if (!pGetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
291 return ERR;
292
293 console_infoex.srWindow.Right++;
294 console_infoex.srWindow.Bottom++;
295
296 return OK;
297}
298
299static COLORREF *_get_colors(void)
300{
301 if (pGetConsoleScreenBufferInfoEx)
302 {
303 int status = OK;
304 if (!console_infoex.cbSize)
305 status = _init_console_infoex();
306 return (status == ERR) ? NULL :
307 (COLORREF *)(&(console_infoex.ColorTable));
308 }
309 else
310 {
311 if (!console_info.Hwnd)
312 _init_console_info();
313 return (COLORREF *)(&(console_info.ColorTable));
314 }
315}
316
317/* restore the original console buffer in the event of a crash */
318
319static LONG WINAPI _restore_console(LPEXCEPTION_POINTERS ep)
320{
321 PDC_scr_close();
322
323 return EXCEPTION_CONTINUE_SEARCH;
324}
325
326/* restore the original console buffer on Ctrl+Break (or Ctrl+C,
327 if it gets re-enabled) */
328
329static BOOL WINAPI _ctrl_break(DWORD dwCtrlType)
330{
331 if (dwCtrlType == CTRL_BREAK_EVENT || dwCtrlType == CTRL_C_EVENT)
332 PDC_scr_close();
333
334 return FALSE;
335}
336
337/* close the physical screen -- may restore the screen to its state
338 before PDC_scr_open(); miscellaneous cleanup */
339
340void PDC_scr_close(void)
341{
342 PDC_LOG(("PDC_scr_close() - called\n"));
343
344 if (SP->visibility != 1)
345 curs_set(1);
346
347 PDC_reset_shell_mode();
348
349 /* Position cursor to the bottom left of the screen. */
350
351 if (SP->_restore == PDC_RESTORE_NONE)
352 {
353 SMALL_RECT win;
354
355 win.Left = orig_scr.srWindow.Left;
356 win.Right = orig_scr.srWindow.Right;
357 win.Top = 0;
358 win.Bottom = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top;
359 SetConsoleWindowInfo(pdc_con_out, TRUE, &win);
360 PDC_gotoyx(win.Bottom, 0);
361 }
362}
363
364void PDC_scr_free(void)
365{
366 if (SP)
367 free(SP);
368
369 if (pdc_con_out != std_con_out)
370 {
371 CloseHandle(pdc_con_out);
372 pdc_con_out = std_con_out;
373 }
374
375 SetUnhandledExceptionFilter(xcpt_filter);
376 SetConsoleCtrlHandler(_ctrl_break, FALSE);
377}
378
379/* open the physical screen -- allocate SP, miscellaneous intialization,
380 and may save the existing screen for later restoration */
381
382int PDC_scr_open(int argc, char **argv)
383{
384 const char *str;
385 CONSOLE_SCREEN_BUFFER_INFO csbi;
386 HMODULE h_kernel;
387 BOOL result;
388 int i;
389
390 PDC_LOG(("PDC_scr_open() - called\n"));
391
392 SP = calloc(1, sizeof(SCREEN));
393
394 if (!SP)
395 return ERR;
396
397 for (i = 0; i < 16; i++)
398 {
399 pdc_curstoreal[realtocurs[i]] = i;
400 pdc_curstoansi[ansitocurs[i]] = i;
401 }
402 _reset_old_colors();
403
404 std_con_out =
405 pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
406 pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
407
408 if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
409 {
410 fprintf(stderr, "\nRedirection is not supported.\n");
411 exit(1);
412 }
413
414 is_nt = !(GetVersion() & 0x80000000);
415
416 str = getenv("ConEmuANSI");
417 pdc_conemu = !!str;
418 pdc_ansi = pdc_conemu ? !strcmp(str, "ON") : FALSE;
419
420 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
421 GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
422 GetConsoleMode(pdc_con_in, &old_console_mode);
423
424 /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
425 the mouse is not enabled -- other console input settings are
426 cleared */
427
428 pdc_quick_edit = old_console_mode & 0x0040;
429
430 SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows();
431 SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns();
432
433 SP->mouse_wait = PDC_CLICK_PERIOD;
434 SP->audible = TRUE;
435
436 SP->termattrs = A_COLOR | A_REVERSE;
437 if (pdc_ansi)
438 SP->termattrs |= A_UNDERLINE | A_ITALIC;
439
440 if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y)
441 {
442 fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n",
443 csbi.dwMaximumWindowSize.Y, SP->lines);
444
445 return ERR;
446 }
447
448 if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X)
449 {
450 fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n",
451 csbi.dwMaximumWindowSize.X, SP->cols);
452
453 return ERR;
454 }
455
456 SP->orig_fore = csbi.wAttributes & 0x0f;
457 SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
458
459 SP->orig_attr = TRUE;
460
461 SP->_restore = PDC_RESTORE_NONE;
462
463 if ((str = getenv("PDC_RESTORE_SCREEN")) == NULL || *str != '0')
464 {
465 /* Create a new console buffer */
466
467 pdc_con_out =
468 CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
469 FILE_SHARE_READ | FILE_SHARE_WRITE,
470 NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
471
472 if (pdc_con_out == INVALID_HANDLE_VALUE)
473 {
474 PDC_LOG(("PDC_scr_open() - screen buffer failure\n"));
475
476 pdc_con_out = std_con_out;
477 }
478 else
479 SP->_restore = PDC_RESTORE_BUFFER;
480 }
481
482 xcpt_filter = SetUnhandledExceptionFilter(_restore_console);
483 SetConsoleCtrlHandler(_ctrl_break, TRUE);
484
485 SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
486
487 /* ENABLE_LVB_GRID_WORLDWIDE */
488 result = SetConsoleMode(pdc_con_out, 0x0010);
489 if (result)
490 SP->termattrs |= A_UNDERLINE | A_LEFT | A_RIGHT;
491
492 PDC_reset_prog_mode();
493
494 SP->mono = FALSE;
495
496 h_kernel = GetModuleHandleA("kernel32.dll");
497 pGetConsoleScreenBufferInfoEx =
498 (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
499 "GetConsoleScreenBufferInfoEx");
500 pSetConsoleScreenBufferInfoEx =
501 (SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
502 "SetConsoleScreenBufferInfoEx");
503
504 return OK;
505}
506
507 /* Calls SetConsoleWindowInfo with the given parameters, but fits them
508 if a scoll bar shrinks the maximum possible value. The rectangle
509 must at least fit in a half-sized window. */
510
511static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
512{
513 SMALL_RECT run;
514 SHORT mx, my;
515
516 if (SetConsoleWindowInfo(con_out, TRUE, rect))
517 return TRUE;
518
519 run = *rect;
520 run.Right /= 2;
521 run.Bottom /= 2;
522
523 mx = run.Right;
524 my = run.Bottom;
525
526 if (!SetConsoleWindowInfo(con_out, TRUE, &run))
527 return FALSE;
528
529 for (run.Right = rect->Right; run.Right >= mx; run.Right--)
530 if (SetConsoleWindowInfo(con_out, TRUE, &run))
531 break;
532
533 if (run.Right < mx)
534 return FALSE;
535
536 for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
537 if (SetConsoleWindowInfo(con_out, TRUE, &run))
538 return TRUE;
539
540 return FALSE;
541}
542
543/* the core of resize_term() */
544
545int PDC_resize_screen(int nlines, int ncols)
546{
547 SMALL_RECT rect;
548 COORD size, max;
549
550 bool prog_resize = nlines || ncols;
551
552 if (!prog_resize)
553 {
554 nlines = PDC_get_rows();
555 ncols = PDC_get_columns();
556 }
557
558 if (nlines < 2 || ncols < 2)
559 return ERR;
560
561 max = GetLargestConsoleWindowSize(pdc_con_out);
562
563 rect.Left = rect.Top = 0;
564 rect.Right = ncols - 1;
565
566 if (rect.Right > max.X)
567 rect.Right = max.X;
568
569 rect.Bottom = nlines - 1;
570
571 if (rect.Bottom > max.Y)
572 rect.Bottom = max.Y;
573
574 size.X = rect.Right + 1;
575 size.Y = rect.Bottom + 1;
576
577 _fit_console_window(pdc_con_out, &rect);
578 SetConsoleScreenBufferSize(pdc_con_out, size);
579
580 if (prog_resize)
581 {
582 _fit_console_window(pdc_con_out, &rect);
583 SetConsoleScreenBufferSize(pdc_con_out, size);
584 }
585 SetConsoleActiveScreenBuffer(pdc_con_out);
586
587 PDC_flushinp();
588
589 SP->resized = FALSE;
590 SP->cursrow = SP->curscol = 0;
591
592 return OK;
593}
594
595void PDC_reset_prog_mode(void)
596{
597 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
598
599 if (pdc_con_out != std_con_out)
600 SetConsoleActiveScreenBuffer(pdc_con_out);
601 else if (is_nt)
602 {
603 COORD bufsize;
604 SMALL_RECT rect;
605
606 bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
607 bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
608
609 rect.Top = rect.Left = 0;
610 rect.Bottom = bufsize.Y - 1;
611 rect.Right = bufsize.X - 1;
612
613 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
614 SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
615 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
616 SetConsoleActiveScreenBuffer(pdc_con_out);
617 }
618
619 PDC_mouse_set();
620}
621
622void PDC_reset_shell_mode(void)
623{
624 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
625
626 if (pdc_con_out != std_con_out)
627 SetConsoleActiveScreenBuffer(std_con_out);
628 else if (is_nt)
629 {
630 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
631 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
632 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
633 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
634 SetConsoleActiveScreenBuffer(pdc_con_out);
635 }
636
637 SetConsoleMode(pdc_con_in, old_console_mode | 0x0080);
638}
639
640void PDC_restore_screen_mode(int i)
641{
642}
643
644void PDC_save_screen_mode(int i)
645{
646}
647
648void PDC_init_pair(short pair, short fg, short bg)
649{
650 atrtab[pair].f = fg;
651 atrtab[pair].b = bg;
652}
653
654int PDC_pair_content(short pair, short *fg, short *bg)
655{
656 *fg = atrtab[pair].f;
657 *bg = atrtab[pair].b;
658
659 return OK;
660}
661
662bool PDC_can_change_color(void)
663{
664 return is_nt;
665}
666
667int PDC_color_content(short color, short *red, short *green, short *blue)
668{
669 if (color < 16 && !pdc_conemu)
670 {
671 COLORREF *color_table = _get_colors();
672
673 if (color_table)
674 {
675 DWORD col = color_table[pdc_curstoreal[color]];
676
677 *red = DIVROUND(GetRValue(col) * 1000, 255);
678 *green = DIVROUND(GetGValue(col) * 1000, 255);
679 *blue = DIVROUND(GetBValue(col) * 1000, 255);
680 }
681 else
682 return ERR;
683 }
684 else
685 {
686 if (!pdc_color[color].mapped)
687 {
688 *red = *green = *blue = -1;
689 return ERR;
690 }
691
692 *red = pdc_color[color].r;
693 *green = pdc_color[color].g;
694 *blue = pdc_color[color].b;
695 }
696
697 return OK;
698}
699
700int PDC_init_color(short color, short red, short green, short blue)
701{
702 if (red == -1 && green == -1 && blue == -1)
703 {
704 pdc_color[color].mapped = FALSE;
705 return OK;
706 }
707
708 if (color < 16 && !pdc_conemu)
709 {
710 COLORREF *color_table = _get_colors();
711
712 if (color_table)
713 {
714 color_table[pdc_curstoreal[color]] =
715 RGB(DIVROUND(red * 255, 1000),
716 DIVROUND(green * 255, 1000),
717 DIVROUND(blue * 255, 1000));
718
719 return _set_colors();
720 }
721
722 return ERR;
723 }
724 else
725 {
726 pdc_color[color].r = red;
727 pdc_color[color].g = green;
728 pdc_color[color].b = blue;
729 pdc_color[color].mapped = TRUE;
730 }
731
732 return OK;
733}
diff --git a/scripts/kconfig/libcurses/pdcsetsc.c b/scripts/kconfig/libcurses/pdcsetsc.c
new file mode 100644
index 000000000..a2d1b6dc3
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcsetsc.c
@@ -0,0 +1,130 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5/*man-start**************************************************************
6
7pdcsetsc
8--------
9
10### Synopsis
11
12 int PDC_set_blink(bool blinkon);
13 int PDC_set_bold(bool boldon);
14 void PDC_set_title(const char *title);
15
16### Description
17
18 PDC_set_blink() toggles whether the A_BLINK attribute sets an actual
19 blink mode (TRUE), or sets the background color to high intensity
20 (FALSE). The default is platform-dependent (FALSE in most cases). It
21 returns OK if it could set the state to match the given parameter,
22 ERR otherwise.
23
24 PDC_set_bold() toggles whether the A_BOLD attribute selects an actual
25 bold font (TRUE), or sets the foreground color to high intensity
26 (FALSE). It returns OK if it could set the state to match the given
27 parameter, ERR otherwise.
28
29 PDC_set_title() sets the title of the window in which the curses
30 program is running. This function may not do anything on some
31 platforms.
32
33### Portability
34 X/Open ncurses NetBSD
35 PDC_set_blink - - -
36 PDC_set_title - - -
37
38**man-end****************************************************************/
39
40int PDC_curs_set(int visibility)
41{
42 CONSOLE_CURSOR_INFO cci;
43 int ret_vis;
44
45 PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
46
47 ret_vis = SP->visibility;
48
49 if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
50 return ERR;
51
52 switch(visibility)
53 {
54 case 0: /* invisible */
55 cci.bVisible = FALSE;
56 break;
57 case 2: /* highly visible */
58 cci.bVisible = TRUE;
59 cci.dwSize = 95;
60 break;
61 default: /* normal visibility */
62 cci.bVisible = TRUE;
63 cci.dwSize = SP->orig_cursor;
64 break;
65 }
66
67 if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
68 return ERR;
69
70 SP->visibility = visibility;
71 return ret_vis;
72}
73
74void PDC_set_title(const char *title)
75{
76#ifdef PDC_WIDE
77 wchar_t wtitle[512];
78#endif
79 PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
80
81#ifdef PDC_WIDE
82 PDC_mbstowcs(wtitle, title, 511);
83 SetConsoleTitleW(wtitle);
84#else
85 SetConsoleTitleA(title);
86#endif
87}
88
89int PDC_set_blink(bool blinkon)
90{
91 if (!SP)
92 return ERR;
93
94 if (SP->color_started)
95 {
96 COLORS = 16;
97 if (PDC_can_change_color()) /* is_nt */
98 {
99 if (pdc_conemu || SetConsoleMode(pdc_con_out, 0x0004)) /* VT */
100 COLORS = PDC_MAXCOL;
101
102 if (!pdc_conemu)
103 SetConsoleMode(pdc_con_out, 0x0010); /* LVB */
104 }
105 }
106
107 if (blinkon)
108 {
109 if (!(SP->termattrs & A_BLINK))
110 {
111 SP->termattrs |= A_BLINK;
112 pdc_last_blink = GetTickCount();
113 }
114 }
115 else
116 {
117 if (SP->termattrs & A_BLINK)
118 {
119 SP->termattrs &= ~A_BLINK;
120 PDC_blink_text();
121 }
122 }
123
124 return OK;
125}
126
127int PDC_set_bold(bool boldon)
128{
129 return boldon ? ERR : OK;
130}
diff --git a/scripts/kconfig/libcurses/pdcutil.c b/scripts/kconfig/libcurses/pdcutil.c
new file mode 100644
index 000000000..a40cf4518
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcutil.c
@@ -0,0 +1,26 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5void PDC_beep(void)
6{
7 PDC_LOG(("PDC_beep() - called\n"));
8
9/* MessageBeep(MB_OK); */
10 MessageBeep(0XFFFFFFFF);
11}
12
13void PDC_napms(int ms)
14{
15 PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
16
17 if ((SP->termattrs & A_BLINK) && (GetTickCount() >= pdc_last_blink + 500))
18 PDC_blink_text();
19
20 Sleep(ms);
21}
22
23const char *PDC_sysname(void)
24{
25 return "Windows";
26}
diff --git a/scripts/kconfig/libcurses/pdcwin.h b/scripts/kconfig/libcurses/pdcwin.h
new file mode 100644
index 000000000..f23a71fd1
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcwin.h
@@ -0,0 +1,27 @@
1/* PDCurses */
2
3#if defined(PDC_WIDE) && !defined(UNICODE)
4# define UNICODE
5#endif
6
7#define WIN32_LEAN_AND_MEAN
8#include <windows.h>
9#undef MOUSE_MOVED
10#include "curspriv.h"
11
12#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
13# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */
14#endif
15
16typedef struct {short r, g, b; bool mapped;} PDCCOLOR;
17
18extern PDCCOLOR pdc_color[PDC_MAXCOL];
19
20extern HANDLE pdc_con_out, pdc_con_in;
21extern DWORD pdc_quick_edit;
22extern DWORD pdc_last_blink;
23extern short pdc_curstoreal[16], pdc_curstoansi[16];
24extern short pdc_oldf, pdc_oldb, pdc_oldu;
25extern bool pdc_conemu, pdc_ansi;
26
27extern void PDC_blink_text(void);
diff --git a/scripts/kconfig/libcurses/printw.c b/scripts/kconfig/libcurses/printw.c
new file mode 100644
index 000000000..38e7fd112
--- /dev/null
+++ b/scripts/kconfig/libcurses/printw.c
@@ -0,0 +1,129 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7printw
8------
9
10### Synopsis
11
12 int printw(const char *fmt, ...);
13 int wprintw(WINDOW *win, const char *fmt, ...);
14 int mvprintw(int y, int x, const char *fmt, ...);
15 int mvwprintw(WINDOW *win, int y, int x, const char *fmt,...);
16 int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
17 int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
18
19### Description
20
21 The printw() functions add a formatted string to the window at the
22 current or specified cursor position. The format strings are the same
23 as used in the standard C library's printf(). (printw() can be used
24 as a drop-in replacement for printf().)
25
26 The duplication between vwprintw() and vw_printw() is for historic
27 reasons. In PDCurses, they're the same.
28
29### Return Value
30
31 All functions return the number of characters printed, or ERR on
32 error.
33
34### Portability
35 X/Open ncurses NetBSD
36 printw Y Y Y
37 wprintw Y Y Y
38 mvprintw Y Y Y
39 mvwprintw Y Y Y
40 vwprintw Y Y Y
41 vw_printw Y Y Y
42
43**man-end****************************************************************/
44
45#include <string.h>
46
47int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
48{
49 char printbuf[513];
50 int len;
51
52 PDC_LOG(("vwprintw() - called\n"));
53
54#ifdef HAVE_VSNPRINTF
55 len = vsnprintf(printbuf, 512, fmt, varglist);
56#else
57 len = vsprintf(printbuf, fmt, varglist);
58#endif
59 return (waddstr(win, printbuf) == ERR) ? ERR : len;
60}
61
62int printw(const char *fmt, ...)
63{
64 va_list args;
65 int retval;
66
67 PDC_LOG(("printw() - called\n"));
68
69 va_start(args, fmt);
70 retval = vwprintw(stdscr, fmt, args);
71 va_end(args);
72
73 return retval;
74}
75
76int wprintw(WINDOW *win, const char *fmt, ...)
77{
78 va_list args;
79 int retval;
80
81 PDC_LOG(("wprintw() - called\n"));
82
83 va_start(args, fmt);
84 retval = vwprintw(win, fmt, args);
85 va_end(args);
86
87 return retval;
88}
89
90int mvprintw(int y, int x, const char *fmt, ...)
91{
92 va_list args;
93 int retval;
94
95 PDC_LOG(("mvprintw() - called\n"));
96
97 if (move(y, x) == ERR)
98 return ERR;
99
100 va_start(args, fmt);
101 retval = vwprintw(stdscr, fmt, args);
102 va_end(args);
103
104 return retval;
105}
106
107int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
108{
109 va_list args;
110 int retval;
111
112 PDC_LOG(("mvwprintw() - called\n"));
113
114 if (wmove(win, y, x) == ERR)
115 return ERR;
116
117 va_start(args, fmt);
118 retval = vwprintw(win, fmt, args);
119 va_end(args);
120
121 return retval;
122}
123
124int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
125{
126 PDC_LOG(("vw_printw() - called\n"));
127
128 return vwprintw(win, fmt, varglist);
129}
diff --git a/scripts/kconfig/libcurses/refresh.c b/scripts/kconfig/libcurses/refresh.c
new file mode 100644
index 000000000..c7122332e
--- /dev/null
+++ b/scripts/kconfig/libcurses/refresh.c
@@ -0,0 +1,277 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7refresh
8-------
9
10### Synopsis
11
12 int refresh(void);
13 int wrefresh(WINDOW *win);
14 int wnoutrefresh(WINDOW *win);
15 int doupdate(void);
16 int redrawwin(WINDOW *win);
17 int wredrawln(WINDOW *win, int beg_line, int num_lines);
18
19### Description
20
21 wrefresh() copies the named window to the physical terminal screen,
22 taking into account what is already there in order to optimize cursor
23 movement. refresh() does the same, using stdscr. These routines must
24 be called to get any output on the terminal, as other routines only
25 manipulate data structures. Unless leaveok() has been enabled, the
26 physical cursor of the terminal is left at the location of the
27 window's cursor.
28
29 wnoutrefresh() and doupdate() allow multiple updates with more
30 efficiency than wrefresh() alone. wrefresh() works by first calling
31 wnoutrefresh(), which copies the named window to the virtual screen.
32 It then calls doupdate(), which compares the virtual screen to the
33 physical screen and does the actual update. A series of calls to
34 wrefresh() will result in alternating calls to wnoutrefresh() and
35 doupdate(), causing several bursts of output to the screen. By first
36 calling wnoutrefresh() for each window, it is then possible to call
37 doupdate() only once.
38
39 In PDCurses, redrawwin() is equivalent to touchwin(), and wredrawln()
40 is the same as touchline(). In some other curses implementations,
41 there's a subtle distinction, but it has no meaning in PDCurses.
42
43### Return Value
44
45 All functions return OK on success and ERR on error.
46
47### Portability
48 X/Open ncurses NetBSD
49 refresh Y Y Y
50 wrefresh Y Y Y
51 wnoutrefresh Y Y Y
52 doupdate Y Y Y
53 redrawwin Y Y Y
54 wredrawln Y Y Y
55
56**man-end****************************************************************/
57
58#include <string.h>
59
60int wnoutrefresh(WINDOW *win)
61{
62 int begy, begx; /* window's place on screen */
63 int i, j;
64
65 PDC_LOG(("wnoutrefresh() - called: win=%p\n", win));
66
67 if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
68 return ERR;
69
70 begy = win->_begy;
71 begx = win->_begx;
72
73 for (i = 0, j = begy; i < win->_maxy; i++, j++)
74 {
75 if (win->_firstch[i] != _NO_CHANGE)
76 {
77 chtype *src = win->_y[i];
78 chtype *dest = curscr->_y[j] + begx;
79
80 int first = win->_firstch[i]; /* first changed */
81 int last = win->_lastch[i]; /* last changed */
82
83 /* ignore areas on the outside that are marked as changed,
84 but really aren't */
85
86 while (first <= last && src[first] == dest[first])
87 first++;
88
89 while (last >= first && src[last] == dest[last])
90 last--;
91
92 /* if any have really changed... */
93
94 if (first <= last)
95 {
96 memcpy(dest + first, src + first,
97 (last - first + 1) * sizeof(chtype));
98
99 first += begx;
100 last += begx;
101
102 if (first < curscr->_firstch[j] ||
103 curscr->_firstch[j] == _NO_CHANGE)
104 curscr->_firstch[j] = first;
105
106 if (last > curscr->_lastch[j])
107 curscr->_lastch[j] = last;
108 }
109
110 win->_firstch[i] = _NO_CHANGE; /* updated now */
111 }
112
113 win->_lastch[i] = _NO_CHANGE; /* updated now */
114 }
115
116 if (win->_clear)
117 win->_clear = FALSE;
118
119 if (!win->_leaveit)
120 {
121 curscr->_cury = win->_cury + begy;
122 curscr->_curx = win->_curx + begx;
123 }
124
125 return OK;
126}
127
128int doupdate(void)
129{
130 int y;
131 bool clearall;
132
133 PDC_LOG(("doupdate() - called\n"));
134
135 if (!SP || !curscr)
136 return ERR;
137
138 if (isendwin()) /* coming back after endwin() called */
139 {
140 reset_prog_mode();
141 clearall = TRUE;
142 SP->alive = TRUE; /* so isendwin() result is correct */
143 }
144 else
145 clearall = curscr->_clear;
146
147 for (y = 0; y < SP->lines; y++)
148 {
149 PDC_LOG(("doupdate() - Transforming line %d of %d: %s\n",
150 y, SP->lines, (curscr->_firstch[y] != _NO_CHANGE) ?
151 "Yes" : "No"));
152
153 if (clearall || curscr->_firstch[y] != _NO_CHANGE)
154 {
155 int first, last;
156
157 chtype *src = curscr->_y[y];
158 chtype *dest = SP->lastscr->_y[y];
159
160 if (clearall)
161 {
162 first = 0;
163 last = COLS - 1;
164 }
165 else
166 {
167 first = curscr->_firstch[y];
168 last = curscr->_lastch[y];
169 }
170
171 while (first <= last)
172 {
173 int len = 0;
174
175 /* build up a run of changed cells; if two runs are
176 separated by a single unchanged cell, ignore the
177 break */
178
179 if (clearall)
180 len = last - first + 1;
181 else
182 while (first + len <= last &&
183 (src[first + len] != dest[first + len] ||
184 (len && first + len < last &&
185 src[first + len + 1] != dest[first + len + 1])
186 )
187 )
188 len++;
189
190 /* update the screen, and SP->lastscr */
191
192 if (len)
193 {
194 PDC_transform_line(y, first, len, src + first);
195 memcpy(dest + first, src + first, len * sizeof(chtype));
196 first += len;
197 }
198
199 /* skip over runs of unchanged cells */
200
201 while (first <= last && src[first] == dest[first])
202 first++;
203 }
204
205 curscr->_firstch[y] = _NO_CHANGE;
206 curscr->_lastch[y] = _NO_CHANGE;
207 }
208 }
209
210 curscr->_clear = FALSE;
211
212 if (SP->visibility)
213 PDC_gotoyx(curscr->_cury, curscr->_curx);
214
215 SP->cursrow = curscr->_cury;
216 SP->curscol = curscr->_curx;
217
218 return OK;
219}
220
221int wrefresh(WINDOW *win)
222{
223 bool save_clear;
224
225 PDC_LOG(("wrefresh() - called\n"));
226
227 if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
228 return ERR;
229
230 save_clear = win->_clear;
231
232 if (win == curscr)
233 curscr->_clear = TRUE;
234 else
235 wnoutrefresh(win);
236
237 if (save_clear && win->_maxy == SP->lines && win->_maxx == SP->cols)
238 curscr->_clear = TRUE;
239
240 return doupdate();
241}
242
243int refresh(void)
244{
245 PDC_LOG(("refresh() - called\n"));
246
247 return wrefresh(stdscr);
248}
249
250int wredrawln(WINDOW *win, int start, int num)
251{
252 int i;
253
254 PDC_LOG(("wredrawln() - called: win=%p start=%d num=%d\n",
255 win, start, num));
256
257 if (!win || start > win->_maxy || start + num > win->_maxy)
258 return ERR;
259
260 for (i = start; i < start + num; i++)
261 {
262 win->_firstch[i] = 0;
263 win->_lastch[i] = win->_maxx - 1;
264 }
265
266 return OK;
267}
268
269int redrawwin(WINDOW *win)
270{
271 PDC_LOG(("redrawwin() - called: win=%p\n", win));
272
273 if (!win)
274 return ERR;
275
276 return wredrawln(win, 0, win->_maxy);
277}
diff --git a/scripts/kconfig/libcurses/scroll.c b/scripts/kconfig/libcurses/scroll.c
new file mode 100644
index 000000000..d2f3d1704
--- /dev/null
+++ b/scripts/kconfig/libcurses/scroll.c
@@ -0,0 +1,101 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7scroll
8------
9
10### Synopsis
11
12 int scroll(WINDOW *win);
13 int scrl(int n);
14 int wscrl(WINDOW *win, int n);
15
16### Description
17
18 scroll() causes the window to scroll up one line. This involves
19 moving the lines in the window data strcture.
20
21 With a positive n, scrl() and wscrl() scroll the window up n lines
22 (line i + n becomes i); otherwise they scroll the window down n
23 lines.
24
25 For these functions to work, scrolling must be enabled via
26 scrollok(). Note also that scrolling is not allowed if the supplied
27 window is a pad.
28
29### Return Value
30
31 All functions return OK on success and ERR on error.
32
33### Portability
34 X/Open ncurses NetBSD
35 scroll Y Y Y
36 scrl Y Y Y
37 wscrl Y Y Y
38
39**man-end****************************************************************/
40
41int wscrl(WINDOW *win, int n)
42{
43 int i, l, dir, start, end;
44 chtype blank, *temp;
45
46 /* Check if window scrolls. Valid for window AND pad */
47
48 if (!win || !win->_scroll || !n)
49 return ERR;
50
51 blank = win->_bkgd;
52
53 if (n > 0)
54 {
55 start = win->_tmarg;
56 end = win->_bmarg;
57 dir = 1;
58 }
59 else
60 {
61 start = win->_bmarg;
62 end = win->_tmarg;
63 dir = -1;
64 }
65
66 for (l = 0; l < (n * dir); l++)
67 {
68 temp = win->_y[start];
69
70 /* re-arrange line pointers */
71
72 for (i = start; i != end; i += dir)
73 win->_y[i] = win->_y[i + dir];
74
75 win->_y[end] = temp;
76
77 /* make a blank line */
78
79 for (i = 0; i < win->_maxx; i++)
80 *temp++ = blank;
81 }
82
83 touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
84
85 PDC_sync(win);
86 return OK;
87}
88
89int scrl(int n)
90{
91 PDC_LOG(("scrl() - called\n"));
92
93 return wscrl(stdscr, n);
94}
95
96int scroll(WINDOW *win)
97{
98 PDC_LOG(("scroll() - called\n"));
99
100 return wscrl(win, 1);
101}
diff --git a/scripts/kconfig/libcurses/slk.c b/scripts/kconfig/libcurses/slk.c
new file mode 100644
index 000000000..a9fca13d3
--- /dev/null
+++ b/scripts/kconfig/libcurses/slk.c
@@ -0,0 +1,671 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7slk
8---
9
10### Synopsis
11
12 int slk_init(int fmt);
13 int slk_set(int labnum, const char *label, int justify);
14 int slk_refresh(void);
15 int slk_noutrefresh(void);
16 char *slk_label(int labnum);
17 int slk_clear(void);
18 int slk_restore(void);
19 int slk_touch(void);
20 int slk_attron(const chtype attrs);
21 int slk_attr_on(const attr_t attrs, void *opts);
22 int slk_attrset(const chtype attrs);
23 int slk_attr_set(const attr_t attrs, short color_pair, void *opts);
24 int slk_attroff(const chtype attrs);
25 int slk_attr_off(const attr_t attrs, void *opts);
26 int slk_color(short color_pair);
27
28 int slk_wset(int labnum, const wchar_t *label, int justify);
29
30 int PDC_mouse_in_slk(int y, int x);
31 void PDC_slk_free(void);
32 void PDC_slk_initialize(void);
33
34 wchar_t *slk_wlabel(int labnum)
35
36### Description
37
38 These functions manipulate a window that contain Soft Label Keys
39 (SLK). To use the SLK functions, a call to slk_init() must be made
40 BEFORE initscr() or newterm(). slk_init() removes 1 or 2 lines from
41 the useable screen, depending on the format selected.
42
43 The line(s) removed from the screen are used as a separate window, in
44 which SLKs are displayed.
45
46 slk_init() requires a single parameter which describes the format of
47 the SLKs as follows:
48
49 0 3-2-3 format
50 1 4-4 format
51 2 4-4-4 format (ncurses extension)
52 3 4-4-4 format with index line (ncurses extension)
53 2 lines used
54 55 5-5 format (pdcurses format)
55
56 slk_refresh(), slk_noutrefresh() and slk_touch() are analogous to
57 refresh(), noutrefresh() and touch().
58
59### Return Value
60
61 All functions return OK on success and ERR on error.
62
63### Portability
64 X/Open ncurses NetBSD
65 slk_init Y Y Y
66 slk_set Y Y Y
67 slk_refresh Y Y Y
68 slk_noutrefresh Y Y Y
69 slk_label Y Y Y
70 slk_clear Y Y Y
71 slk_restore Y Y Y
72 slk_touch Y Y Y
73 slk_attron Y Y Y
74 slk_attrset Y Y Y
75 slk_attroff Y Y Y
76 slk_attr_on Y Y Y
77 slk_attr_set Y Y Y
78 slk_attr_off Y Y Y
79 slk_wset Y Y Y
80 PDC_mouse_in_slk - - -
81 PDC_slk_free - - -
82 PDC_slk_initialize - - -
83 slk_wlabel - - -
84
85**man-end****************************************************************/
86
87#include <stdlib.h>
88
89enum { LABEL_NORMAL = 8, LABEL_EXTENDED = 10, LABEL_NCURSES_EXTENDED = 12 };
90
91static int label_length = 0;
92static int labels = 0;
93static int label_fmt = 0;
94static int label_line = 0;
95static bool hidden = FALSE;
96
97static struct SLK {
98 chtype label[32];
99 int len;
100 int format;
101 int start_col;
102} *slk = (struct SLK *)NULL;
103
104/* slk_init() is the slk initialization routine.
105 This must be called before initscr().
106
107 label_fmt = 0, 1 or 55.
108 0 = 3-2-3 format
109 1 = 4 - 4 format
110 2 = 4-4-4 format (ncurses extension for PC 12 function keys)
111 3 = 4-4-4 format (ncurses extension for PC 12 function keys -
112 with index line)
113 55 = 5 - 5 format (extended for PC, 10 function keys) */
114
115int slk_init(int fmt)
116{
117 PDC_LOG(("slk_init() - called\n"));
118
119 if (SP)
120 return ERR;
121
122 switch (fmt)
123 {
124 case 0: /* 3 - 2 - 3 */
125 labels = LABEL_NORMAL;
126 break;
127
128 case 1: /* 4 - 4 */
129 labels = LABEL_NORMAL;
130 break;
131
132 case 2: /* 4 4 4 */
133 labels = LABEL_NCURSES_EXTENDED;
134 break;
135
136 case 3: /* 4 4 4 with index */
137 labels = LABEL_NCURSES_EXTENDED;
138 break;
139
140 case 55: /* 5 - 5 */
141 labels = LABEL_EXTENDED;
142 break;
143
144 default:
145 return ERR;
146 }
147
148 label_fmt = fmt;
149
150 slk = calloc(labels, sizeof(struct SLK));
151
152 if (!slk)
153 labels = 0;
154
155 return slk ? OK : ERR;
156}
157
158/* draw a single button */
159
160static void _drawone(int num)
161{
162 int i, col, slen;
163
164 if (hidden)
165 return;
166
167 slen = slk[num].len;
168
169 switch (slk[num].format)
170 {
171 case 0: /* LEFT */
172 col = 0;
173 break;
174
175 case 1: /* CENTER */
176 col = (label_length - slen) / 2;
177
178 if (col + slen > label_length)
179 --col;
180 break;
181
182 default: /* RIGHT */
183 col = label_length - slen;
184 }
185
186 wmove(SP->slk_winptr, label_line, slk[num].start_col);
187
188 for (i = 0; i < label_length; ++i)
189 waddch(SP->slk_winptr, (i >= col && i < (col + slen)) ?
190 slk[num].label[i - col] : ' ');
191}
192
193/* redraw each button */
194
195static void _redraw(void)
196{
197 int i;
198
199 for (i = 0; i < labels; ++i)
200 _drawone(i);
201}
202
203/* slk_set() Used to set a slk label to a string.
204
205 labnum = 1 - 8 (or 10) (number of the label)
206 label = string (8 or 7 bytes total), or NULL
207 justify = 0 : left, 1 : center, 2 : right */
208
209int slk_set(int labnum, const char *label, int justify)
210{
211#ifdef PDC_WIDE
212 wchar_t wlabel[32];
213
214 PDC_mbstowcs(wlabel, label, 31);
215 return slk_wset(labnum, wlabel, justify);
216#else
217 PDC_LOG(("slk_set() - called\n"));
218
219 if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
220 return ERR;
221
222 labnum--;
223
224 if (!label || !(*label))
225 {
226 /* Clear the label */
227
228 *slk[labnum].label = 0;
229 slk[labnum].format = 0;
230 slk[labnum].len = 0;
231 }
232 else
233 {
234 int i, j = 0;
235
236 /* Skip leading spaces */
237
238 while (label[j] == ' ')
239 j++;
240
241 /* Copy it */
242
243 for (i = 0; i < label_length; i++)
244 {
245 chtype ch = label[i + j];
246
247 slk[labnum].label[i] = ch;
248
249 if (!ch)
250 break;
251 }
252
253 /* Drop trailing spaces */
254
255 while ((i + j) && (label[i + j - 1] == ' '))
256 i--;
257
258 slk[labnum].label[i] = 0;
259 slk[labnum].format = justify;
260 slk[labnum].len = i;
261 }
262
263 _drawone(labnum);
264
265 return OK;
266#endif
267}
268
269int slk_refresh(void)
270{
271 PDC_LOG(("slk_refresh() - called\n"));
272
273 return (slk_noutrefresh() == ERR) ? ERR : doupdate();
274}
275
276int slk_noutrefresh(void)
277{
278 PDC_LOG(("slk_noutrefresh() - called\n"));
279
280 if (!SP)
281 return ERR;
282
283 return wnoutrefresh(SP->slk_winptr);
284}
285
286char *slk_label(int labnum)
287{
288 static char temp[33];
289#ifdef PDC_WIDE
290 wchar_t *wtemp = slk_wlabel(labnum);
291
292 PDC_wcstombs(temp, wtemp, 32);
293#else
294 chtype *p;
295 int i;
296
297 PDC_LOG(("slk_label() - called\n"));
298
299 if (labnum < 1 || labnum > labels)
300 return (char *)0;
301
302 for (i = 0, p = slk[labnum - 1].label; *p; i++)
303 temp[i] = *p++;
304
305 temp[i] = '\0';
306#endif
307 return temp;
308}
309
310int slk_clear(void)
311{
312 PDC_LOG(("slk_clear() - called\n"));
313
314 if (!SP)
315 return ERR;
316
317 hidden = TRUE;
318 werase(SP->slk_winptr);
319 return wrefresh(SP->slk_winptr);
320}
321
322int slk_restore(void)
323{
324 PDC_LOG(("slk_restore() - called\n"));
325
326 if (!SP)
327 return ERR;
328
329 hidden = FALSE;
330 _redraw();
331 return wrefresh(SP->slk_winptr);
332}
333
334int slk_touch(void)
335{
336 PDC_LOG(("slk_touch() - called\n"));
337
338 if (!SP)
339 return ERR;
340
341 return touchwin(SP->slk_winptr);
342}
343
344int slk_attron(const chtype attrs)
345{
346 int rc;
347
348 PDC_LOG(("slk_attron() - called\n"));
349
350 if (!SP)
351 return ERR;
352
353 rc = wattron(SP->slk_winptr, attrs);
354 _redraw();
355
356 return rc;
357}
358
359int slk_attr_on(const attr_t attrs, void *opts)
360{
361 PDC_LOG(("slk_attr_on() - called\n"));
362
363 return slk_attron(attrs);
364}
365
366int slk_attroff(const chtype attrs)
367{
368 int rc;
369
370 PDC_LOG(("slk_attroff() - called\n"));
371
372 if (!SP)
373 return ERR;
374
375 rc = wattroff(SP->slk_winptr, attrs);
376 _redraw();
377
378 return rc;
379}
380
381int slk_attr_off(const attr_t attrs, void *opts)
382{
383 PDC_LOG(("slk_attr_off() - called\n"));
384
385 return slk_attroff(attrs);
386}
387
388int slk_attrset(const chtype attrs)
389{
390 int rc;
391
392 PDC_LOG(("slk_attrset() - called\n"));
393
394 if (!SP)
395 return ERR;
396
397 rc = wattrset(SP->slk_winptr, attrs);
398 _redraw();
399
400 return rc;
401}
402
403int slk_color(short color_pair)
404{
405 int rc;
406
407 PDC_LOG(("slk_color() - called\n"));
408
409 if (!SP)
410 return ERR;
411
412 rc = wcolor_set(SP->slk_winptr, color_pair, NULL);
413 _redraw();
414
415 return rc;
416}
417
418int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
419{
420 PDC_LOG(("slk_attr_set() - called\n"));
421
422 return slk_attrset(attrs | COLOR_PAIR(color_pair));
423}
424
425static void _slk_calc(void)
426{
427 int i, center, col = 0;
428 label_length = COLS / labels;
429
430 if (label_length > 31)
431 label_length = 31;
432
433 switch (label_fmt)
434 {
435 case 0: /* 3 - 2 - 3 F-Key layout */
436
437 --label_length;
438
439 slk[0].start_col = col;
440 slk[1].start_col = (col += label_length);
441 slk[2].start_col = (col += label_length);
442
443 center = COLS / 2;
444
445 slk[3].start_col = center - label_length + 1;
446 slk[4].start_col = center + 1;
447
448 col = COLS - (label_length * 3) + 1;
449
450 slk[5].start_col = col;
451 slk[6].start_col = (col += label_length);
452 slk[7].start_col = (col += label_length);
453 break;
454
455 case 1: /* 4 - 4 F-Key layout */
456
457 for (i = 0; i < 8; i++)
458 {
459 slk[i].start_col = col;
460 col += label_length;
461
462 if (i == 3)
463 col = COLS - (label_length * 4) + 1;
464 }
465
466 break;
467
468 case 2: /* 4 4 4 F-Key layout */
469 case 3: /* 4 4 4 F-Key layout with index */
470
471 for (i = 0; i < 4; i++)
472 {
473 slk[i].start_col = col;
474 col += label_length;
475 }
476
477 center = COLS / 2;
478
479 slk[4].start_col = center - (label_length * 2) + 1;
480 slk[5].start_col = center - label_length + 1;
481 slk[6].start_col = center + 1;
482 slk[7].start_col = center + label_length + 1;
483
484 col = COLS - (label_length * 4) + 1;
485
486 for (i = 8; i < 12; i++)
487 {
488 slk[i].start_col = col;
489 col += label_length;
490 }
491
492 break;
493
494 default: /* 5 - 5 F-Key layout */
495
496 for (i = 0; i < 10; i++)
497 {
498 slk[i].start_col = col;
499 col += label_length;
500
501 if (i == 4)
502 col = COLS - (label_length * 5) + 1;
503 }
504 }
505
506 --label_length;
507
508 /* make sure labels are all in window */
509
510 _redraw();
511}
512
513void PDC_slk_initialize(void)
514{
515 if (slk)
516 {
517 if (label_fmt == 3)
518 {
519 SP->slklines = 2;
520 label_line = 1;
521 }
522 else
523 SP->slklines = 1;
524
525 if (!SP->slk_winptr)
526 {
527 SP->slk_winptr = newwin(SP->slklines, COLS,
528 LINES - SP->slklines, 0);
529 if (!SP->slk_winptr)
530 return;
531
532 wattrset(SP->slk_winptr, A_REVERSE);
533 }
534
535 _slk_calc();
536
537 /* if we have an index line, display it now */
538
539 if (label_fmt == 3)
540 {
541 chtype save_attr;
542 int i;
543
544 save_attr = SP->slk_winptr->_attrs;
545 wattrset(SP->slk_winptr, A_NORMAL);
546 wmove(SP->slk_winptr, 0, 0);
547 whline(SP->slk_winptr, 0, COLS);
548
549 for (i = 0; i < labels; i++)
550 mvwprintw(SP->slk_winptr, 0, slk[i].start_col, "F%d", i + 1);
551
552 SP->slk_winptr->_attrs = save_attr;
553 }
554
555 touchwin(SP->slk_winptr);
556 }
557}
558
559void PDC_slk_free(void)
560{
561 if (slk)
562 {
563 if (SP->slk_winptr)
564 {
565 delwin(SP->slk_winptr);
566 SP->slk_winptr = (WINDOW *)NULL;
567 }
568
569 free(slk);
570 slk = (struct SLK *)NULL;
571
572 label_length = 0;
573 labels = 0;
574 label_fmt = 0;
575 label_line = 0;
576 hidden = FALSE;
577 }
578}
579
580int PDC_mouse_in_slk(int y, int x)
581{
582 int i;
583
584 PDC_LOG(("PDC_mouse_in_slk() - called: y->%d x->%d\n", y, x));
585
586 /* If the line on which the mouse was clicked is NOT the last line
587 of the screen, we are not interested in it. */
588
589 if (!slk || !SP->slk_winptr || (y != SP->slk_winptr->_begy + label_line))
590 return 0;
591
592 for (i = 0; i < labels; i++)
593 if (x >= slk[i].start_col && x < (slk[i].start_col + label_length))
594 return i + 1;
595
596 return 0;
597}
598
599#ifdef PDC_WIDE
600int slk_wset(int labnum, const wchar_t *label, int justify)
601{
602 PDC_LOG(("slk_wset() - called\n"));
603
604 if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
605 return ERR;
606
607 labnum--;
608
609 if (!label || !(*label))
610 {
611 /* Clear the label */
612
613 *slk[labnum].label = 0;
614 slk[labnum].format = 0;
615 slk[labnum].len = 0;
616 }
617 else
618 {
619 int i, j = 0;
620
621 /* Skip leading spaces */
622
623 while (label[j] == L' ')
624 j++;
625
626 /* Copy it */
627
628 for (i = 0; i < label_length; i++)
629 {
630 chtype ch = label[i + j];
631
632 slk[labnum].label[i] = ch;
633
634 if (!ch)
635 break;
636 }
637
638 /* Drop trailing spaces */
639
640 while ((i + j) && (label[i + j - 1] == L' '))
641 i--;
642
643 slk[labnum].label[i] = 0;
644 slk[labnum].format = justify;
645 slk[labnum].len = i;
646 }
647
648 _drawone(labnum);
649
650 return OK;
651}
652
653wchar_t *slk_wlabel(int labnum)
654{
655 static wchar_t temp[33];
656 chtype *p;
657 int i;
658
659 PDC_LOG(("slk_wlabel() - called\n"));
660
661 if (labnum < 1 || labnum > labels)
662 return (wchar_t *)0;
663
664 for (i = 0, p = slk[labnum - 1].label; *p; i++)
665 temp[i] = *p++;
666
667 temp[i] = '\0';
668
669 return temp;
670}
671#endif
diff --git a/scripts/kconfig/libcurses/touch.c b/scripts/kconfig/libcurses/touch.c
new file mode 100644
index 000000000..619fbc6e1
--- /dev/null
+++ b/scripts/kconfig/libcurses/touch.c
@@ -0,0 +1,199 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7touch
8-----
9
10### Synopsis
11
12 int touchwin(WINDOW *win);
13 int touchline(WINDOW *win, int start, int count);
14 int untouchwin(WINDOW *win);
15 int wtouchln(WINDOW *win, int y, int n, int changed);
16 bool is_linetouched(WINDOW *win, int line);
17 bool is_wintouched(WINDOW *win);
18
19 int touchoverlap(const WINDOW *win1, WINDOW *win2);
20
21### Description
22
23 touchwin() and touchline() throw away all information about which
24 parts of the window have been touched, pretending that the entire
25 window has been drawn on. This is sometimes necessary when using
26 overlapping windows, since a change to one window will affect the
27 other window, but the records of which lines have been changed in the
28 other window will not reflect the change.
29
30 untouchwin() marks all lines in the window as unchanged since the
31 last call to wrefresh().
32
33 wtouchln() makes n lines in the window, starting at line y, look as
34 if they have (changed == 1) or have not (changed == 0) been changed
35 since the last call to wrefresh().
36
37 is_linetouched() returns TRUE if the specified line in the specified
38 window has been changed since the last call to wrefresh().
39
40 is_wintouched() returns TRUE if the specified window has been changed
41 since the last call to wrefresh().
42
43 touchoverlap(win1, win2) marks the portion of win2 which overlaps
44 with win1 as modified.
45
46### Return Value
47
48 All functions return OK on success and ERR on error except
49 is_wintouched() and is_linetouched().
50
51### Portability
52 X/Open ncurses NetBSD
53 touchwin Y Y Y
54 touchline Y Y Y
55 untouchwin Y Y Y
56 wtouchln Y Y Y
57 is_linetouched Y Y Y
58 is_wintouched Y Y Y
59 touchoverlap - - Y
60
61**man-end****************************************************************/
62
63int touchwin(WINDOW *win)
64{
65 int i;
66
67 PDC_LOG(("touchwin() - called: Win=%x\n", win));
68
69 if (!win)
70 return ERR;
71
72 for (i = 0; i < win->_maxy; i++)
73 {
74 win->_firstch[i] = 0;
75 win->_lastch[i] = win->_maxx - 1;
76 }
77
78 return OK;
79}
80
81int touchline(WINDOW *win, int start, int count)
82{
83 int i;
84
85 PDC_LOG(("touchline() - called: win=%p start %d count %d\n",
86 win, start, count));
87
88 if (!win || start > win->_maxy || start + count > win->_maxy)
89 return ERR;
90
91 for (i = start; i < start + count; i++)
92 {
93 win->_firstch[i] = 0;
94 win->_lastch[i] = win->_maxx - 1;
95 }
96
97 return OK;
98}
99
100int untouchwin(WINDOW *win)
101{
102 int i;
103
104 PDC_LOG(("untouchwin() - called: win=%p", win));
105
106 if (!win)
107 return ERR;
108
109 for (i = 0; i < win->_maxy; i++)
110 {
111 win->_firstch[i] = _NO_CHANGE;
112 win->_lastch[i] = _NO_CHANGE;
113 }
114
115 return OK;
116}
117
118int wtouchln(WINDOW *win, int y, int n, int changed)
119{
120 int i;
121
122 PDC_LOG(("wtouchln() - called: win=%p y=%d n=%d changed=%d\n",
123 win, y, n, changed));
124
125 if (!win || y > win->_maxy || y + n > win->_maxy)
126 return ERR;
127
128 for (i = y; i < y + n; i++)
129 {
130 if (changed)
131 {
132 win->_firstch[i] = 0;
133 win->_lastch[i] = win->_maxx - 1;
134 }
135 else
136 {
137 win->_firstch[i] = _NO_CHANGE;
138 win->_lastch[i] = _NO_CHANGE;
139 }
140 }
141
142 return OK;
143}
144
145bool is_linetouched(WINDOW *win, int line)
146{
147 PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line));
148
149 if (!win || line > win->_maxy || line < 0)
150 return FALSE;
151
152 return (win->_firstch[line] != _NO_CHANGE) ? TRUE : FALSE;
153}
154
155bool is_wintouched(WINDOW *win)
156{
157 int i;
158
159 PDC_LOG(("is_wintouched() - called: win=%p\n", win));
160
161 if (win)
162 for (i = 0; i < win->_maxy; i++)
163 if (win->_firstch[i] != _NO_CHANGE)
164 return TRUE;
165
166 return FALSE;
167}
168
169int touchoverlap(const WINDOW *win1, WINDOW *win2)
170{
171 int y, endy, endx, starty, startx;
172
173 PDC_LOG(("touchoverlap() - called: win1=%p win2=%p\n", win1, win2));
174
175 if (!win1 || !win2)
176 return ERR;
177
178 starty = max(win1->_begy, win2->_begy);
179 startx = max(win1->_begx, win2->_begx);
180 endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy);
181 endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
182
183 if (starty >= endy || startx >= endx)
184 return OK;
185
186 starty -= win2->_begy;
187 startx -= win2->_begx;
188 endy -= win2->_begy;
189 endx -= win2->_begx;
190 endx -= 1;
191
192 for (y = starty; y < endy; y++)
193 {
194 win2->_firstch[y] = startx;
195 win2->_lastch[y] = endx;
196 }
197
198 return OK;
199}
diff --git a/scripts/kconfig/libcurses/window.c b/scripts/kconfig/libcurses/window.c
new file mode 100644
index 000000000..495d7dbea
--- /dev/null
+++ b/scripts/kconfig/libcurses/window.c
@@ -0,0 +1,581 @@
1/* PDCurses */
2
3#include "curspriv.h"
4
5/*man-start**************************************************************
6
7window
8------
9
10### Synopsis
11
12 WINDOW *newwin(int nlines, int ncols, int begy, int begx);
13 WINDOW *derwin(WINDOW* orig, int nlines, int ncols,
14 int begy, int begx);
15 WINDOW *subwin(WINDOW* orig, int nlines, int ncols,
16 int begy, int begx);
17 WINDOW *dupwin(WINDOW *win);
18 int delwin(WINDOW *win);
19 int mvwin(WINDOW *win, int y, int x);
20 int mvderwin(WINDOW *win, int pary, int parx);
21 int syncok(WINDOW *win, bool bf);
22 void wsyncup(WINDOW *win);
23 void wcursyncup(WINDOW *win);
24 void wsyncdown(WINDOW *win);
25
26 WINDOW *resize_window(WINDOW *win, int nlines, int ncols);
27 int wresize(WINDOW *win, int nlines, int ncols);
28 WINDOW *PDC_makelines(WINDOW *win);
29 WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx);
30 void PDC_sync(WINDOW *win);
31
32### Description
33
34 newwin() creates a new window with the given number of lines, nlines
35 and columns, ncols. The upper left corner of the window is at line
36 begy, column begx. If nlines is zero, it defaults to LINES - begy;
37 ncols to COLS - begx. Create a new full-screen window by calling
38 newwin(0, 0, 0, 0).
39
40 delwin() deletes the named window, freeing all associated memory. In
41 the case of overlapping windows, subwindows should be deleted before
42 the main window.
43
44 mvwin() moves the window so that the upper left-hand corner is at
45 position (y,x). If the move would cause the window to be off the
46 screen, it is an error and the window is not moved. Moving subwindows
47 is allowed.
48
49 subwin() creates a new subwindow within a window. The dimensions of
50 the subwindow are nlines lines and ncols columns. The subwindow is at
51 position (begy, begx) on the screen. This position is relative to the
52 screen, and not to the window orig. Changes made to either window
53 will affect both. When using this routine, you will often need to
54 call touchwin() before calling wrefresh().
55
56 derwin() is the same as subwin(), except that begy and begx are
57 relative to the origin of the window orig rather than the screen.
58 There is no difference between subwindows and derived windows.
59
60 mvderwin() moves a derived window (or subwindow) inside its parent
61 window. The screen-relative parameters of the window are not changed.
62 This routine is used to display different parts of the parent window
63 at the same physical position on the screen.
64
65 dupwin() creates an exact duplicate of the window win.
66
67 wsyncup() causes a touchwin() of all of the window's parents.
68
69 If wsyncok() is called with a second argument of TRUE, this causes a
70 wsyncup() to be called every time the window is changed.
71
72 wcursyncup() causes the current cursor position of all of a window's
73 ancestors to reflect the current cursor position of the current
74 window.
75
76 wsyncdown() causes a touchwin() of the current window if any of its
77 parent's windows have been touched.
78
79 resize_window() allows the user to resize an existing window. It
80 returns the pointer to the new window, or NULL on failure.
81
82 wresize() is an ncurses-compatible wrapper for resize_window(). Note
83 that, unlike ncurses, it will NOT process any subwindows of the
84 window. (However, you still can call it _on_ subwindows.) It returns
85 OK or ERR.
86
87 PDC_makenew() allocates all data for a new WINDOW * except the actual
88 lines themselves. If it's unable to allocate memory for the window
89 structure, it will free all allocated memory and return a NULL
90 pointer.
91
92 PDC_makelines() allocates the memory for the lines.
93
94 PDC_sync() handles wrefresh() and wsyncup() calls when a window is
95 changed.
96
97### Return Value
98
99 newwin(), subwin(), derwin() and dupwin() return a pointer to the new
100 window, or NULL on failure. delwin(), mvwin(), mvderwin() and
101 syncok() return OK or ERR. wsyncup(), wcursyncup() and wsyncdown()
102 return nothing.
103
104### Errors
105
106 It is an error to call resize_window() before calling initscr().
107 Also, an error will be generated if we fail to create a newly sized
108 replacement window for curscr, or stdscr. This could happen when
109 increasing the window size. NOTE: If this happens, the previously
110 successfully allocated windows are left alone; i.e., the resize is
111 NOT cancelled for those windows.
112
113### Portability
114 X/Open ncurses NetBSD
115 newwin Y Y Y
116 delwin Y Y Y
117 mvwin Y Y Y
118 subwin Y Y Y
119 derwin Y Y Y
120 mvderwin Y Y Y
121 dupwin Y Y Y
122 wsyncup Y Y Y
123 syncok Y Y Y
124 wcursyncup Y Y Y
125 wsyncdown Y Y Y
126 wresize - Y Y
127 resize_window - - -
128 PDC_makelines - - -
129 PDC_makenew - - -
130 PDC_sync - - -
131
132**man-end****************************************************************/
133
134#include <stdlib.h>
135
136WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
137{
138 WINDOW *win;
139
140 PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
141 nlines, ncols, begy, begx));
142
143 /* allocate the window structure itself */
144
145 win = calloc(1, sizeof(WINDOW));
146 if (!win)
147 return win;
148
149 /* allocate the line pointer array */
150
151 win->_y = malloc(nlines * sizeof(chtype *));
152 if (!win->_y)
153 {
154 free(win);
155 return (WINDOW *)NULL;
156 }
157
158 /* allocate the minchng and maxchng arrays */
159
160 win->_firstch = malloc(nlines * sizeof(int));
161 if (!win->_firstch)
162 {
163 free(win->_y);
164 free(win);
165 return (WINDOW *)NULL;
166 }
167
168 win->_lastch = malloc(nlines * sizeof(int));
169 if (!win->_lastch)
170 {
171 free(win->_firstch);
172 free(win->_y);
173 free(win);
174 return (WINDOW *)NULL;
175 }
176
177 /* initialize window variables */
178
179 win->_maxy = nlines; /* real max screen size */
180 win->_maxx = ncols; /* real max screen size */
181 win->_begy = begy;
182 win->_begx = begx;
183 win->_bkgd = ' '; /* wrs 4/10/93 -- initialize background to blank */
184 win->_clear = (bool) ((nlines == LINES) && (ncols == COLS));
185 win->_bmarg = nlines - 1;
186 win->_parx = win->_pary = -1;
187
188 /* init to say window all changed */
189
190 touchwin(win);
191
192 return win;
193}
194
195WINDOW *PDC_makelines(WINDOW *win)
196{
197 int i, j, nlines, ncols;
198
199 PDC_LOG(("PDC_makelines() - called\n"));
200
201 if (!win)
202 return (WINDOW *)NULL;
203
204 nlines = win->_maxy;
205 ncols = win->_maxx;
206
207 for (i = 0; i < nlines; i++)
208 {
209 win->_y[i] = malloc(ncols * sizeof(chtype));
210 if (!win->_y[i])
211 {
212 /* if error, free all the data */
213
214 for (j = 0; j < i; j++)
215 free(win->_y[j]);
216
217 free(win->_firstch);
218 free(win->_lastch);
219 free(win->_y);
220 free(win);
221
222 return (WINDOW *)NULL;
223 }
224 }
225
226 return win;
227}
228
229void PDC_sync(WINDOW *win)
230{
231 PDC_LOG(("PDC_sync() - called:\n"));
232
233 if (win->_immed)
234 wrefresh(win);
235 if (win->_sync)
236 wsyncup(win);
237}
238
239WINDOW *newwin(int nlines, int ncols, int begy, int begx)
240{
241 WINDOW *win;
242
243 PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
244 nlines, ncols, begy, begx));
245
246 if (!nlines)
247 nlines = LINES - begy;
248 if (!ncols)
249 ncols = COLS - begx;
250
251 if (!SP || begy + nlines > SP->lines || begx + ncols > SP->cols)
252 return (WINDOW *)NULL;
253
254 win = PDC_makenew(nlines, ncols, begy, begx);
255 if (win)
256 win = PDC_makelines(win);
257
258 if (win)
259 werase(win);
260
261 return win;
262}
263
264int delwin(WINDOW *win)
265{
266 int i;
267
268 PDC_LOG(("delwin() - called\n"));
269
270 if (!win)
271 return ERR;
272
273 /* subwindows use parents' lines */
274
275 if (!(win->_flags & (_SUBWIN|_SUBPAD)))
276 for (i = 0; i < win->_maxy && win->_y[i]; i++)
277 if (win->_y[i])
278 free(win->_y[i]);
279
280 free(win->_firstch);
281 free(win->_lastch);
282 free(win->_y);
283 free(win);
284
285 return OK;
286}
287
288int mvwin(WINDOW *win, int y, int x)
289{
290 PDC_LOG(("mvwin() - called\n"));
291
292 if (!win || (y + win->_maxy > LINES || y < 0)
293 || (x + win->_maxx > COLS || x < 0))
294 return ERR;
295
296 win->_begy = y;
297 win->_begx = x;
298 touchwin(win);
299
300 return OK;
301}
302
303WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
304{
305 WINDOW *win;
306 int i, j, k;
307
308 PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
309 nlines, ncols, begy, begx));
310
311 /* make sure window fits inside the original one */
312
313 if (!orig || (begy < orig->_begy) || (begx < orig->_begx) ||
314 (begy + nlines) > (orig->_begy + orig->_maxy) ||
315 (begx + ncols) > (orig->_begx + orig->_maxx))
316 return (WINDOW *)NULL;
317
318 j = begy - orig->_begy;
319 k = begx - orig->_begx;
320
321 if (!nlines)
322 nlines = orig->_maxy - 1 - j;
323 if (!ncols)
324 ncols = orig->_maxx - 1 - k;
325
326 win = PDC_makenew(nlines, ncols, begy, begx);
327 if (!win)
328 return (WINDOW *)NULL;
329
330 /* initialize window variables */
331
332 win->_attrs = orig->_attrs;
333 win->_bkgd = orig->_bkgd;
334 win->_leaveit = orig->_leaveit;
335 win->_scroll = orig->_scroll;
336 win->_nodelay = orig->_nodelay;
337 win->_delayms = orig->_delayms;
338 win->_use_keypad = orig->_use_keypad;
339 win->_immed = orig->_immed;
340 win->_sync = orig->_sync;
341 win->_pary = j;
342 win->_parx = k;
343 win->_parent = orig;
344
345 for (i = 0; i < nlines; i++, j++)
346 win->_y[i] = orig->_y[j] + k;
347
348 win->_flags |= _SUBWIN;
349
350 return win;
351}
352
353WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
354{
355 return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx);
356}
357
358int mvderwin(WINDOW *win, int pary, int parx)
359{
360 int i, j;
361 WINDOW *mypar;
362
363 if (!win || !(win->_parent))
364 return ERR;
365
366 mypar = win->_parent;
367
368 if (pary < 0 || parx < 0 || (pary + win->_maxy) > mypar->_maxy ||
369 (parx + win->_maxx) > mypar->_maxx)
370 return ERR;
371
372 j = pary;
373
374 for (i = 0; i < win->_maxy; i++)
375 win->_y[i] = (mypar->_y[j++]) + parx;
376
377 win->_pary = pary;
378 win->_parx = parx;
379
380 return OK;
381}
382
383WINDOW *dupwin(WINDOW *win)
384{
385 WINDOW *new;
386 chtype *ptr, *ptr1;
387 int nlines, ncols, begy, begx, i;
388
389 if (!win)
390 return (WINDOW *)NULL;
391
392 nlines = win->_maxy;
393 ncols = win->_maxx;
394 begy = win->_begy;
395 begx = win->_begx;
396
397 new = PDC_makenew(nlines, ncols, begy, begx);
398 if (new)
399 new = PDC_makelines(new);
400
401 if (!new)
402 return (WINDOW *)NULL;
403
404 /* copy the contents of win into new */
405
406 for (i = 0; i < nlines; i++)
407 {
408 for (ptr = new->_y[i], ptr1 = win->_y[i];
409 ptr < new->_y[i] + ncols; ptr++, ptr1++)
410 *ptr = *ptr1;
411
412 new->_firstch[i] = 0;
413 new->_lastch[i] = ncols - 1;
414 }
415
416 new->_curx = win->_curx;
417 new->_cury = win->_cury;
418 new->_maxy = win->_maxy;
419 new->_maxx = win->_maxx;
420 new->_begy = win->_begy;
421 new->_begx = win->_begx;
422 new->_flags = win->_flags;
423 new->_attrs = win->_attrs;
424 new->_clear = win->_clear;
425 new->_leaveit = win->_leaveit;
426 new->_scroll = win->_scroll;
427 new->_nodelay = win->_nodelay;
428 new->_delayms = win->_delayms;
429 new->_use_keypad = win->_use_keypad;
430 new->_tmarg = win->_tmarg;
431 new->_bmarg = win->_bmarg;
432 new->_parx = win->_parx;
433 new->_pary = win->_pary;
434 new->_parent = win->_parent;
435 new->_bkgd = win->_bkgd;
436 new->_flags = win->_flags;
437
438 return new;
439}
440
441WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
442{
443 WINDOW *new;
444 int i, save_cury, save_curx, new_begy, new_begx;
445
446 PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
447 nlines, ncols));
448
449 if (!win || !SP)
450 return (WINDOW *)NULL;
451
452 if (win->_flags & _SUBPAD)
453 {
454 new = subpad(win->_parent, nlines, ncols, win->_begy, win->_begx);
455 if (!new)
456 return (WINDOW *)NULL;
457 }
458 else if (win->_flags & _SUBWIN)
459 {
460 new = subwin(win->_parent, nlines, ncols, win->_begy, win->_begx);
461 if (!new)
462 return (WINDOW *)NULL;
463 }
464 else
465 {
466 if (win == SP->slk_winptr)
467 {
468 new_begy = SP->lines - SP->slklines;
469 new_begx = 0;
470 }
471 else
472 {
473 new_begy = win->_begy;
474 new_begx = win->_begx;
475 }
476
477 new = PDC_makenew(nlines, ncols, new_begy, new_begx);
478 if (!new)
479 return (WINDOW *)NULL;
480 }
481
482 save_curx = min(win->_curx, (new->_maxx - 1));
483 save_cury = min(win->_cury, (new->_maxy - 1));
484
485 if (!(win->_flags & (_SUBPAD|_SUBWIN)))
486 {
487 new = PDC_makelines(new);
488 if (!new)
489 return (WINDOW *)NULL;
490
491 werase(new);
492
493 copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1,
494 min(win->_maxx, new->_maxx) - 1, FALSE);
495
496 for (i = 0; i < win->_maxy && win->_y[i]; i++)
497 if (win->_y[i])
498 free(win->_y[i]);
499 }
500
501 new->_flags = win->_flags;
502 new->_attrs = win->_attrs;
503 new->_clear = win->_clear;
504 new->_leaveit = win->_leaveit;
505 new->_scroll = win->_scroll;
506 new->_nodelay = win->_nodelay;
507 new->_delayms = win->_delayms;
508 new->_use_keypad = win->_use_keypad;
509 new->_tmarg = (win->_tmarg > new->_maxy - 1) ? 0 : win->_tmarg;
510 new->_bmarg = (win->_bmarg == win->_maxy - 1) ?
511 new->_maxy - 1 : min(win->_bmarg, (new->_maxy - 1));
512 new->_parent = win->_parent;
513 new->_immed = win->_immed;
514 new->_sync = win->_sync;
515 new->_bkgd = win->_bkgd;
516
517 new->_curx = save_curx;
518 new->_cury = save_cury;
519
520 free(win->_firstch);
521 free(win->_lastch);
522 free(win->_y);
523
524 *win = *new;
525 free(new);
526
527 return win;
528}
529
530int wresize(WINDOW *win, int nlines, int ncols)
531{
532 return (resize_window(win, nlines, ncols) ? OK : ERR);
533}
534
535void wsyncup(WINDOW *win)
536{
537 WINDOW *tmp;
538
539 PDC_LOG(("wsyncup() - called\n"));
540
541 for (tmp = win; tmp; tmp = tmp->_parent)
542 touchwin(tmp);
543}
544
545int syncok(WINDOW *win, bool bf)
546{
547 PDC_LOG(("syncok() - called\n"));
548
549 if (!win)
550 return ERR;
551
552 win->_sync = bf;
553
554 return OK;
555}
556
557void wcursyncup(WINDOW *win)
558{
559 WINDOW *tmp;
560
561 PDC_LOG(("wcursyncup() - called\n"));
562
563 for (tmp = win; tmp && tmp->_parent; tmp = tmp->_parent)
564 wmove(tmp->_parent, tmp->_pary + tmp->_cury, tmp->_parx + tmp->_curx);
565}
566
567void wsyncdown(WINDOW *win)
568{
569 WINDOW *tmp;
570
571 PDC_LOG(("wsyncdown() - called\n"));
572
573 for (tmp = win; tmp; tmp = tmp->_parent)
574 {
575 if (is_wintouched(tmp))
576 {
577 touchwin(win);
578 break;
579 }
580 }
581}
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 5075ebf2d..3b401d86a 100755
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -6,6 +6,10 @@ ldflags()
6{ 6{
7 pkg-config --libs ncursesw 2>/dev/null && exit 7 pkg-config --libs ncursesw 2>/dev/null && exit
8 pkg-config --libs ncurses 2>/dev/null && exit 8 pkg-config --libs ncurses 2>/dev/null && exit
9 if [ -n "$W64DEVKIT" ]
10 then
11 echo "./scripts/kconfig/libcurses/lib.a" && exit
12 fi
9 for ext in so a dll.a dylib ; do 13 for ext in so a dll.a dylib ; do
10 for lib in ncursesw ncurses curses ; do 14 for lib in ncursesw ncurses curses ; do
11 $cc -print-file-name=lib${lib}.${ext} | grep -q / 15 $cc -print-file-name=lib${lib}.${ext} | grep -q /
@@ -34,6 +38,8 @@ ccflags()
34 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"' 38 echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
35 elif [ -f /usr/include/ncurses.h ]; then 39 elif [ -f /usr/include/ncurses.h ]; then
36 echo '-DCURSES_LOC="<ncurses.h>"' 40 echo '-DCURSES_LOC="<ncurses.h>"'
41 elif [ -n "$W64DEVKIT" ]; then
42 echo '-I./scripts/kconfig/libcurses -DCURSES_LOC="<curses.h>"'
37 else 43 else
38 echo '-DCURSES_LOC="<curses.h>"' 44 echo '-DCURSES_LOC="<curses.h>"'
39 fi 45 fi