aboutsummaryrefslogtreecommitdiff
path: root/scripts/kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/.gitignore1
-rw-r--r--scripts/kconfig/Makefile14
-rw-r--r--scripts/kconfig/conf.c15
-rw-r--r--scripts/kconfig/confdata.c9
-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.c362
-rw-r--r--scripts/kconfig/libcurses/curses.h1440
-rw-r--r--scripts/kconfig/libcurses/curspriv.h133
-rw-r--r--scripts/kconfig/libcurses/getch.c589
-rw-r--r--scripts/kconfig/libcurses/getyx.c142
-rw-r--r--scripts/kconfig/libcurses/inch.c126
-rw-r--r--scripts/kconfig/libcurses/initscr.c431
-rw-r--r--scripts/kconfig/libcurses/inopts.c408
-rw-r--r--scripts/kconfig/libcurses/kernel.c297
-rw-r--r--scripts/kconfig/libcurses/move.c77
-rw-r--r--scripts/kconfig/libcurses/outopts.c260
-rw-r--r--scripts/kconfig/libcurses/overlay.c214
-rw-r--r--scripts/kconfig/libcurses/pad.c274
-rw-r--r--scripts/kconfig/libcurses/pdcclip.c149
-rw-r--r--scripts/kconfig/libcurses/pdcdisp.c329
-rw-r--r--scripts/kconfig/libcurses/pdcgetsc.c42
-rw-r--r--scripts/kconfig/libcurses/pdckbd.c693
-rw-r--r--scripts/kconfig/libcurses/pdcscrn.c686
-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.c287
-rw-r--r--scripts/kconfig/libcurses/scroll.c101
-rw-r--r--scripts/kconfig/libcurses/slk.c671
-rw-r--r--scripts/kconfig/libcurses/touch.c208
-rw-r--r--scripts/kconfig/libcurses/window.c637
-rw-r--r--scripts/kconfig/lkc.h6
-rwxr-xr-xscripts/kconfig/lxdialog/check-lxdialog.sh8
-rw-r--r--scripts/kconfig/lxdialog/dialog.h1
-rw-r--r--scripts/kconfig/lxdialog/util.c3
-rw-r--r--scripts/kconfig/mconf.c242
-rw-r--r--scripts/kconfig/symbol.c31
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped60
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped1
50 files changed, 11294 insertions, 35 deletions
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index b49584c93..aa9c7d637 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -17,3 +17,4 @@ mconf
17qconf 17qconf
18gconf 18gconf
19kxgettext 19kxgettext
20/conf.exe
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 38bae809a..ed07c4c62 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,6 +2,17 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5# If w64devkit isn't run via w64devkit.exe W64DEVKIT won't be
6# defined. If HOSTCC targets the mingw32 platform set W64DEVKIT.
7ifndef W64DEVKIT
8 host_target := $(shell $(HOSTCC) -v 2>&1 | grep ^Target:)
9 host_platform := $(lastword $(subst -, ,$(host_target)))
10 ifeq ($(host_platform),mingw32)
11 W64DEVKIT := 1
12 export W64DEVKIT
13 endif
14endif
15
5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 16PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 17
7xconfig: $(obj)/qconf 18xconfig: $(obj)/qconf
@@ -11,6 +22,9 @@ gconfig: $(obj)/gconf
11 $< Config.in 22 $< Config.in
12 23
13menuconfig: $(obj)/mconf 24menuconfig: $(obj)/mconf
25ifdef W64DEVKIT
26 $(Q)$(MAKE) $(build)=scripts/kconfig/libcurses
27endif
14 $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog 28 $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog
15 $< Config.in 29 $< Config.in
16 30
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 39ec1cdb6..4680932d7 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -193,9 +193,14 @@ static void conf_askvalue(struct symbol *sym, const char *def)
193 break; 193 break;
194 } 194 }
195 case set_random: 195 case set_random:
196#ifdef __MINGW32__
197 fprintf(stderr, "set_random not supported\n");
198 exit(1);
199#else
196 do { 200 do {
197 val = (tristate)(random() % 3); 201 val = (tristate)(random() % 3);
198 } while (!sym_tristate_within_range(sym, val)); 202 } while (!sym_tristate_within_range(sym, val));
203#endif
199 switch (val) { 204 switch (val) {
200 case no: line[0] = 'n'; break; 205 case no: line[0] = 'n'; break;
201 case mod: line[0] = 'm'; break; 206 case mod: line[0] = 'm'; break;
@@ -407,7 +412,12 @@ static int conf_choice(struct menu *menu)
407 continue; 412 continue;
408 break; 413 break;
409 case set_random: 414 case set_random:
415#ifdef __MINGW32__
416 fprintf(stderr, "set_random not supported\n");
417 exit(1);
418#else
410 def = (random() % cnt) + 1; 419 def = (random() % cnt) + 1;
420#endif
411 case set_default: 421 case set_default:
412 case set_yes: 422 case set_yes:
413 case set_mod: 423 case set_mod:
@@ -563,8 +573,13 @@ int main(int ac, char **av)
563 input_mode = set_yes; 573 input_mode = set_yes;
564 break; 574 break;
565 case 'r': 575 case 'r':
576#ifdef __MINGW32__
577 fprintf(stderr, "set_random not supported\n");
578 exit(1);
579#else
566 input_mode = set_random; 580 input_mode = set_random;
567 srandom(time(NULL)); 581 srandom(time(NULL));
582#endif
568 break; 583 break;
569 case 'h': 584 case 'h':
570 case '?': 585 case '?':
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 249a3195e..2f7fa6618 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -584,15 +584,24 @@ int conf_write(const char *name)
584 fclose(out); 584 fclose(out);
585 if (out_h) { 585 if (out_h) {
586 fclose(out_h); 586 fclose(out_h);
587#ifdef __MINGW32__
588 unlink("include/autoconf.h");
589#endif
587 rename(".tmpconfig.h", "include/autoconf.h"); 590 rename(".tmpconfig.h", "include/autoconf.h");
588 } 591 }
589 if (!name || basename != conf_def_filename) { 592 if (!name || basename != conf_def_filename) {
590 if (!name) 593 if (!name)
591 name = conf_def_filename; 594 name = conf_def_filename;
592 sprintf(tmpname, "%s.old", name); 595 sprintf(tmpname, "%s.old", name);
596#ifdef __MINGW32__
597 unlink(tmpname);
598#endif
593 rename(name, tmpname); 599 rename(name, tmpname);
594 } 600 }
595 sprintf(tmpname, "%s%s", dirname, basename); 601 sprintf(tmpname, "%s%s", dirname, basename);
602#ifdef __MINGW32__
603 unlink(tmpname);
604#endif
596 if (rename(newname, tmpname)) 605 if (rename(newname, tmpname))
597 return 1; 606 return 1;
598 607
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..81f5b2cbe
--- /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
10Acknowledgements
11----------------
12
13Windows console port was originally provided by Chris Szurgot
14<szurgot@itribe.net>
15
16
17Distribution Status
18-------------------
19
20The files in this directory are released to the public domain.
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..3335ae082
--- /dev/null
+++ b/scripts/kconfig/libcurses/color.c
@@ -0,0 +1,362 @@
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 alloc_pair(int fg, int bg);
21 int assume_default_colors(int f, int b);
22 int find_pair(int fg, int bg);
23 int free_pair(int pair);
24 int use_default_colors(void);
25
26 int PDC_set_line_color(short color);
27
28### Description
29
30 To use these routines, first, call start_color(). Colors are always
31 used in pairs, referred to as color-pairs. A color-pair is created by
32 init_pair(), and consists of a foreground color and a background
33 color. After initialization, COLOR_PAIR(n) can be used like any other
34 video attribute.
35
36 has_colors() reports whether the terminal supports color.
37
38 start_color() initializes eight basic colors (black, red, green,
39 yellow, blue, magenta, cyan, and white), and two global variables:
40 COLORS and COLOR_PAIRS (respectively defining the maximum number of
41 colors and color-pairs the terminal is capable of displaying).
42
43 init_pair() changes the definition of a color-pair. It takes three
44 arguments: the number of the color-pair to be redefined, and the new
45 values of the foreground and background colors. The pair number must
46 be between 0 and COLOR_PAIRS - 1, inclusive. The foreground and
47 background must be between 0 and COLORS - 1, inclusive. If the color
48 pair was previously initialized, the screen is refreshed, and all
49 occurrences of that color-pair are changed to the new definition.
50
51 pair_content() is used to determine what the colors of a given color-
52 pair consist of.
53
54 can_change_color() indicates if the terminal has the capability to
55 change the definition of its colors.
56
57 init_color() is used to redefine a color, if possible. Each of the
58 components -- red, green, and blue -- is specified in a range from 0
59 to 1000, inclusive.
60
61 color_content() reports the current definition of a color in the same
62 format as used by init_color().
63
64 assume_default_colors() and use_default_colors() emulate the ncurses
65 extensions of the same names. assume_default_colors(f, b) is
66 essentially the same as init_pair(0, f, b) (which isn't allowed); it
67 redefines the default colors. use_default_colors() allows the use of
68 -1 as a foreground or background color with init_pair(), and calls
69 assume_default_colors(-1, -1); -1 represents the foreground or
70 background color that the terminal had at startup. If the environment
71 variable PDC_ORIGINAL_COLORS is set at the time start_color() is
72 called, that's equivalent to calling use_default_colors().
73
74 alloc_pair(), find_pair() and free_pair() are also from ncurses.
75 free_pair() marks a pair as unused; find_pair() returns an existing
76 pair with the specified foreground and background colors, if one
77 exists. And alloc_pair() returns such a pair whether or not it was
78 previously set, overwriting the oldest initialized pair if there are
79 no free pairs.
80
81 PDC_set_line_color() is used to set the color, globally, for the
82 color of the lines drawn for the attributes: A_UNDERLINE, A_LEFT and
83 A_RIGHT. A value of -1 (the default) indicates that the current
84 foreground color should be used.
85
86 NOTE: COLOR_PAIR() and PAIR_NUMBER() are implemented as macros.
87
88### Return Value
89
90 Most functions return OK on success and ERR on error. has_colors()
91 and can_change_colors() return TRUE or FALSE. alloc_pair() and
92 find_pair() return a pair number, or -1 on error.
93
94### Portability
95 X/Open ncurses NetBSD
96 has_colors Y Y Y
97 start_color Y Y Y
98 init_pair Y Y Y
99 pair_content Y Y Y
100 can_change_color Y Y Y
101 init_color Y Y Y
102 color_content Y Y Y
103 alloc_pair - Y -
104 assume_default_colors - Y Y
105 find_pair - Y -
106 free_pair - Y -
107 use_default_colors - Y Y
108 PDC_set_line_color - - -
109
110**man-end****************************************************************/
111
112#include <stdlib.h>
113#include <string.h>
114
115int COLORS = 0;
116int COLOR_PAIRS = PDC_COLOR_PAIRS;
117
118static bool default_colors = FALSE;
119static short first_col = 0;
120static int allocnum = 0;
121
122int start_color(void)
123{
124 PDC_LOG(("start_color() - called\n"));
125
126 if (!SP || SP->mono)
127 return ERR;
128
129 SP->color_started = TRUE;
130
131 PDC_set_blink(FALSE); /* Also sets COLORS */
132
133 if (!default_colors && SP->orig_attr && getenv("PDC_ORIGINAL_COLORS"))
134 default_colors = TRUE;
135
136 PDC_init_atrtab();
137
138 return OK;
139}
140
141static void _normalize(short *fg, short *bg)
142{
143 if (*fg == -1)
144 *fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
145
146 if (*bg == -1)
147 *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
148}
149
150static void _init_pair_core(short pair, short fg, short bg)
151{
152 PDC_PAIR *p = SP->atrtab + pair;
153
154 _normalize(&fg, &bg);
155
156 /* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
157 curscr if this call to init_pair() alters a color pair created by
158 the user. */
159
160 if (p->set)
161 {
162 if (p->f != fg || p->b != bg)
163 curscr->_clear = TRUE;
164 }
165
166 p->f = fg;
167 p->b = bg;
168 p->count = allocnum++;
169 p->set = TRUE;
170}
171
172int init_pair(short pair, short fg, short bg)
173{
174 PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
175
176 if (!SP || !SP->color_started || pair < 1 || pair >= COLOR_PAIRS ||
177 fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
178 return ERR;
179
180 _init_pair_core(pair, fg, bg);
181
182 return OK;
183}
184
185bool has_colors(void)
186{
187 PDC_LOG(("has_colors() - called\n"));
188
189 return SP ? !(SP->mono) : FALSE;
190}
191
192int init_color(short color, short red, short green, short blue)
193{
194 PDC_LOG(("init_color() - called\n"));
195
196 if (!SP || color < 0 || color >= COLORS || !PDC_can_change_color() ||
197 red < -1 || red > 1000 || green < -1 || green > 1000 ||
198 blue < -1 || blue > 1000)
199 return ERR;
200
201 SP->dirty = TRUE;
202
203 return PDC_init_color(color, red, green, blue);
204}
205
206int color_content(short color, short *red, short *green, short *blue)
207{
208 PDC_LOG(("color_content() - called\n"));
209
210 if (color < 0 || color >= COLORS || !red || !green || !blue)
211 return ERR;
212
213 if (PDC_can_change_color())
214 return PDC_color_content(color, red, green, blue);
215 else
216 {
217 /* Simulated values for platforms that don't support palette
218 changing */
219
220 short maxval = (color & 8) ? 1000 : 680;
221
222 *red = (color & COLOR_RED) ? maxval : 0;
223 *green = (color & COLOR_GREEN) ? maxval : 0;
224 *blue = (color & COLOR_BLUE) ? maxval : 0;
225
226 return OK;
227 }
228}
229
230bool can_change_color(void)
231{
232 PDC_LOG(("can_change_color() - called\n"));
233
234 return PDC_can_change_color();
235}
236
237int pair_content(short pair, short *fg, short *bg)
238{
239 PDC_LOG(("pair_content() - called\n"));
240
241 if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
242 return ERR;
243
244 *fg = SP->atrtab[pair].f;
245 *bg = SP->atrtab[pair].b;
246
247 return OK;
248}
249
250int assume_default_colors(int f, int b)
251{
252 PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
253
254 if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
255 return ERR;
256
257 if (SP->color_started)
258 _init_pair_core(0, f, b);
259
260 return OK;
261}
262
263int use_default_colors(void)
264{
265 PDC_LOG(("use_default_colors() - called\n"));
266
267 default_colors = TRUE;
268 first_col = -1;
269
270 return assume_default_colors(-1, -1);
271}
272
273int PDC_set_line_color(short color)
274{
275 PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
276
277 if (!SP || color < -1 || color >= COLORS)
278 return ERR;
279
280 SP->line_color = color;
281
282 return OK;
283}
284
285void PDC_init_atrtab(void)
286{
287 PDC_PAIR *p = SP->atrtab;
288 short i, fg, bg;
289
290 if (SP->color_started && !default_colors)
291 {
292 fg = COLOR_WHITE;
293 bg = COLOR_BLACK;
294 }
295 else
296 fg = bg = -1;
297
298 _normalize(&fg, &bg);
299
300 for (i = 0; i < PDC_COLOR_PAIRS; i++)
301 {
302 p[i].f = fg;
303 p[i].b = bg;
304 p[i].set = FALSE;
305 }
306}
307
308int free_pair(int pair)
309{
310 if (pair < 1 || pair >= PDC_COLOR_PAIRS || !(SP->atrtab[pair].set))
311 return ERR;
312
313 SP->atrtab[pair].set = FALSE;
314 return OK;
315}
316
317int find_pair(int fg, int bg)
318{
319 int i;
320 PDC_PAIR *p = SP->atrtab;
321
322 for (i = 0; i < PDC_COLOR_PAIRS; i++)
323 if (p[i].set && p[i].f == fg && p[i].b == bg)
324 return i;
325
326 return -1;
327}
328
329static int _find_oldest()
330{
331 int i, lowind = 0, lowval = 0;
332 PDC_PAIR *p = SP->atrtab;
333
334 for (i = 1; i < PDC_COLOR_PAIRS; i++)
335 {
336 if (!p[i].set)
337 return i;
338
339 if (!lowval || (p[i].count < lowval))
340 {
341 lowind = i;
342 lowval = p[i].count;
343 }
344 }
345
346 return lowind;
347}
348
349int alloc_pair(int fg, int bg)
350{
351 int i = find_pair(fg, bg);
352
353 if (-1 == i)
354 {
355 i = _find_oldest();
356
357 if (ERR == init_pair(i, fg, bg))
358 return -1;
359 }
360
361 return i;
362}
diff --git a/scripts/kconfig/libcurses/curses.h b/scripts/kconfig/libcurses/curses.h
new file mode 100644
index 000000000..e4ba3776a
--- /dev/null
+++ b/scripts/kconfig/libcurses/curses.h
@@ -0,0 +1,1440 @@
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 if building / built for X11
13 PDC_RGB if you want to use RGB color definitions
14 (Red = 1, Green = 2, Blue = 4) instead of BGR
15 PDC_WIDE if building / built with wide-character support
16 PDC_DLL_BUILD if building / built as a Windows DLL
17 PDC_NCMOUSE to use the ncurses mouse API instead
18 of PDCurses' traditional mouse API
19
20Defined by this header:
21
22 PDCURSES PDCurses-only features are available
23 PDC_BUILD 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 3907
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
304 /* these are used only if this is a pad */
305 struct pdat
306 {
307 int _pad_y;
308 int _pad_x;
309 int _pad_top;
310 int _pad_left;
311 int _pad_bottom;
312 int _pad_right;
313 } _pad; /* Pad-properties structure */
314} WINDOW;
315
316/* Color pair structure */
317
318typedef struct
319{
320 short f; /* foreground color */
321 short b; /* background color */
322 int count; /* allocation order */
323 bool set; /* pair has been set */
324} PDC_PAIR;
325
326/* Avoid using the SCREEN struct directly -- use the corresponding
327 functions if possible. This struct may eventually be made private. */
328
329typedef struct
330{
331 bool alive; /* if initscr() called, and not endwin() */
332 bool autocr; /* if cr -> lf */
333 bool cbreak; /* if terminal unbuffered */
334 bool echo; /* if terminal echo */
335 bool raw_inp; /* raw input mode (v. cooked input) */
336 bool raw_out; /* raw output mode (7 v. 8 bits) */
337 bool audible; /* FALSE if the bell is visual */
338 bool mono; /* TRUE if current screen is mono */
339 bool resized; /* TRUE if TERM has been resized */
340 bool orig_attr; /* TRUE if we have the original colors */
341 short orig_fore; /* original screen foreground color */
342 short orig_back; /* original screen foreground color */
343 int cursrow; /* position of physical cursor */
344 int curscol; /* position of physical cursor */
345 int visibility; /* visibility of cursor */
346 int orig_cursor; /* original cursor size */
347 int lines; /* new value for LINES */
348 int cols; /* new value for COLS */
349 mmask_t _trap_mbe; /* trap these mouse button events */
350 int mouse_wait; /* time to wait (in ms) for a
351 button release after a press, in
352 order to count it as a click */
353 int slklines; /* lines in use by slk_init() */
354 WINDOW *slk_winptr; /* window for slk */
355 int linesrippedoff; /* lines ripped off via ripoffline() */
356 int linesrippedoffontop; /* lines ripped off on
357 top via ripoffline() */
358 int delaytenths; /* 1/10ths second to wait block
359 getch() for */
360 bool _preserve; /* TRUE if screen background
361 to be preserved */
362 int _restore; /* specifies if screen background
363 to be restored, and how */
364 unsigned long key_modifiers; /* key modifiers (SHIFT, CONTROL, etc.)
365 on last key press */
366 bool return_key_modifiers; /* TRUE if modifier keys are
367 returned as "real" keys */
368 bool key_code; /* TRUE if last key is a special key;
369 used internally by get_wch() */
370 MOUSE_STATUS mouse_status; /* last returned mouse status */
371 short line_color; /* color of line attributes - default -1 */
372 attr_t termattrs; /* attribute capabilities */
373 WINDOW *lastscr; /* the last screen image */
374 FILE *dbfp; /* debug trace file pointer */
375 bool color_started; /* TRUE after start_color() */
376 bool dirty; /* redraw on napms() after init_color() */
377 int sel_start; /* start of selection (y * COLS + x) */
378 int sel_end; /* end of selection */
379 int *c_buffer; /* character buffer */
380 int c_pindex; /* putter index */
381 int c_gindex; /* getter index */
382 int *c_ungch; /* array of ungotten chars */
383 int c_ungind; /* ungetch() push index */
384 int c_ungmax; /* allocated size of ungetch() buffer */
385 PDC_PAIR *atrtab; /* table of color pairs */
386} SCREEN;
387
388/*----------------------------------------------------------------------
389 *
390 * External Variables
391 *
392 */
393
394#ifdef PDC_DLL_BUILD
395# ifdef CURSES_LIBRARY
396# define PDCEX __declspec(dllexport) extern
397# else
398# define PDCEX __declspec(dllimport)
399# endif
400#else
401# define PDCEX extern
402#endif
403
404PDCEX int LINES; /* terminal height */
405PDCEX int COLS; /* terminal width */
406PDCEX WINDOW *stdscr; /* the default screen window */
407PDCEX WINDOW *curscr; /* the current screen image */
408PDCEX SCREEN *SP; /* curses variables */
409PDCEX MOUSE_STATUS Mouse_status;
410PDCEX int COLORS;
411PDCEX int COLOR_PAIRS;
412PDCEX int TABSIZE;
413PDCEX chtype acs_map[]; /* alternate character set map */
414PDCEX char ttytype[]; /* terminal name/description */
415
416/*man-start**************************************************************
417
418Text Attributes
419===============
420
421PDCurses uses a 32-bit integer for its chtype:
422
423 +--------------------------------------------------------------------+
424 |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0|
425 +--------------------------------------------------------------------+
426 color pair | modifiers | character eg 'a'
427
428There are 256 color pairs (8 bits), 8 bits for modifiers, and 16 bits
429for character data. The modifiers are bold, underline, right-line,
430left-line, italic, reverse and blink, plus the alternate character set
431indicator.
432
433**man-end****************************************************************/
434
435/*** Video attribute macros ***/
436
437#define A_NORMAL (chtype)0
438
439#define A_ALTCHARSET (chtype)0x00010000
440#define A_RIGHT (chtype)0x00020000
441#define A_LEFT (chtype)0x00040000
442#define A_ITALIC (chtype)0x00080000
443#define A_UNDERLINE (chtype)0x00100000
444#define A_REVERSE (chtype)0x00200000
445#define A_BLINK (chtype)0x00400000
446#define A_BOLD (chtype)0x00800000
447
448#define A_ATTRIBUTES (chtype)0xffff0000
449#define A_CHARTEXT (chtype)0x0000ffff
450#define A_COLOR (chtype)0xff000000
451
452#define PDC_COLOR_SHIFT 24
453
454#define A_LEFTLINE A_LEFT
455#define A_RIGHTLINE A_RIGHT
456#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */
457
458#define A_DIM A_NORMAL
459#define A_INVIS A_NORMAL
460#define A_PROTECT A_NORMAL
461
462#define A_HORIZONTAL A_NORMAL
463#define A_LOW A_NORMAL
464#define A_TOP A_NORMAL
465#define A_VERTICAL A_NORMAL
466
467#define CHR_MSK A_CHARTEXT /* Obsolete */
468#define ATR_MSK A_ATTRIBUTES /* Obsolete */
469#define ATR_NRM A_NORMAL /* Obsolete */
470
471/* For use with attr_t -- X/Open says, "these shall be distinct", so
472 this is a non-conforming implementation. */
473
474#define WA_NORMAL A_NORMAL
475
476#define WA_ALTCHARSET A_ALTCHARSET
477#define WA_BLINK A_BLINK
478#define WA_BOLD A_BOLD
479#define WA_DIM A_DIM
480#define WA_INVIS A_INVIS
481#define WA_ITALIC A_ITALIC
482#define WA_LEFT A_LEFT
483#define WA_PROTECT A_PROTECT
484#define WA_REVERSE A_REVERSE
485#define WA_RIGHT A_RIGHT
486#define WA_STANDOUT A_STANDOUT
487#define WA_UNDERLINE A_UNDERLINE
488
489#define WA_HORIZONTAL A_HORIZONTAL
490#define WA_LOW A_LOW
491#define WA_TOP A_TOP
492#define WA_VERTICAL A_VERTICAL
493
494#define WA_ATTRIBUTES A_ATTRIBUTES
495
496/*** Alternate character set macros ***/
497
498#define PDC_ACS(w) ((chtype)w | A_ALTCHARSET)
499
500/* VT100-compatible symbols -- box chars */
501
502#define ACS_ULCORNER PDC_ACS('l')
503#define ACS_LLCORNER PDC_ACS('m')
504#define ACS_URCORNER PDC_ACS('k')
505#define ACS_LRCORNER PDC_ACS('j')
506#define ACS_RTEE PDC_ACS('u')
507#define ACS_LTEE PDC_ACS('t')
508#define ACS_BTEE PDC_ACS('v')
509#define ACS_TTEE PDC_ACS('w')
510#define ACS_HLINE PDC_ACS('q')
511#define ACS_VLINE PDC_ACS('x')
512#define ACS_PLUS PDC_ACS('n')
513
514/* VT100-compatible symbols -- other */
515
516#define ACS_S1 PDC_ACS('o')
517#define ACS_S9 PDC_ACS('s')
518#define ACS_DIAMOND PDC_ACS('`')
519#define ACS_CKBOARD PDC_ACS('a')
520#define ACS_DEGREE PDC_ACS('f')
521#define ACS_PLMINUS PDC_ACS('g')
522#define ACS_BULLET PDC_ACS('~')
523
524/* Teletype 5410v1 symbols -- these are defined in SysV curses, but
525 are not well-supported by most terminals. Stick to VT100 characters
526 for optimum portability. */
527
528#define ACS_LARROW PDC_ACS(',')
529#define ACS_RARROW PDC_ACS('+')
530#define ACS_DARROW PDC_ACS('.')
531#define ACS_UARROW PDC_ACS('-')
532#define ACS_BOARD PDC_ACS('h')
533#define ACS_LANTERN PDC_ACS('i')
534#define ACS_BLOCK PDC_ACS('0')
535
536/* That goes double for these -- undocumented SysV symbols. Don't use
537 them. */
538
539#define ACS_S3 PDC_ACS('p')
540#define ACS_S7 PDC_ACS('r')
541#define ACS_LEQUAL PDC_ACS('y')
542#define ACS_GEQUAL PDC_ACS('z')
543#define ACS_PI PDC_ACS('{')
544#define ACS_NEQUAL PDC_ACS('|')
545#define ACS_STERLING PDC_ACS('}')
546
547/* Box char aliases */
548
549#define ACS_BSSB ACS_ULCORNER
550#define ACS_SSBB ACS_LLCORNER
551#define ACS_BBSS ACS_URCORNER
552#define ACS_SBBS ACS_LRCORNER
553#define ACS_SBSS ACS_RTEE
554#define ACS_SSSB ACS_LTEE
555#define ACS_SSBS ACS_BTEE
556#define ACS_BSSS ACS_TTEE
557#define ACS_BSBS ACS_HLINE
558#define ACS_SBSB ACS_VLINE
559#define ACS_SSSS ACS_PLUS
560
561/* cchar_t aliases */
562
563#ifdef PDC_WIDE
564# define WACS_ULCORNER (&(acs_map['l']))
565# define WACS_LLCORNER (&(acs_map['m']))
566# define WACS_URCORNER (&(acs_map['k']))
567# define WACS_LRCORNER (&(acs_map['j']))
568# define WACS_RTEE (&(acs_map['u']))
569# define WACS_LTEE (&(acs_map['t']))
570# define WACS_BTEE (&(acs_map['v']))
571# define WACS_TTEE (&(acs_map['w']))
572# define WACS_HLINE (&(acs_map['q']))
573# define WACS_VLINE (&(acs_map['x']))
574# define WACS_PLUS (&(acs_map['n']))
575
576# define WACS_S1 (&(acs_map['o']))
577# define WACS_S9 (&(acs_map['s']))
578# define WACS_DIAMOND (&(acs_map['`']))
579# define WACS_CKBOARD (&(acs_map['a']))
580# define WACS_DEGREE (&(acs_map['f']))
581# define WACS_PLMINUS (&(acs_map['g']))
582# define WACS_BULLET (&(acs_map['~']))
583
584# define WACS_LARROW (&(acs_map[',']))
585# define WACS_RARROW (&(acs_map['+']))
586# define WACS_DARROW (&(acs_map['.']))
587# define WACS_UARROW (&(acs_map['-']))
588# define WACS_BOARD (&(acs_map['h']))
589# define WACS_LANTERN (&(acs_map['i']))
590# define WACS_BLOCK (&(acs_map['0']))
591
592# define WACS_S3 (&(acs_map['p']))
593# define WACS_S7 (&(acs_map['r']))
594# define WACS_LEQUAL (&(acs_map['y']))
595# define WACS_GEQUAL (&(acs_map['z']))
596# define WACS_PI (&(acs_map['{']))
597# define WACS_NEQUAL (&(acs_map['|']))
598# define WACS_STERLING (&(acs_map['}']))
599
600# define WACS_BSSB WACS_ULCORNER
601# define WACS_SSBB WACS_LLCORNER
602# define WACS_BBSS WACS_URCORNER
603# define WACS_SBBS WACS_LRCORNER
604# define WACS_SBSS WACS_RTEE
605# define WACS_SSSB WACS_LTEE
606# define WACS_SSBS WACS_BTEE
607# define WACS_BSSS WACS_TTEE
608# define WACS_BSBS WACS_HLINE
609# define WACS_SBSB WACS_VLINE
610# define WACS_SSSS WACS_PLUS
611#endif
612
613/*** Color macros ***/
614
615#define COLOR_BLACK 0
616
617#ifdef PDC_RGB /* RGB */
618# define COLOR_RED 1
619# define COLOR_GREEN 2
620# define COLOR_BLUE 4
621#else /* BGR */
622# define COLOR_BLUE 1
623# define COLOR_GREEN 2
624# define COLOR_RED 4
625#endif
626
627#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN)
628#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE)
629#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN)
630
631#define COLOR_WHITE 7
632
633/*----------------------------------------------------------------------
634 *
635 * Function and Keypad Key Definitions
636 * Many are just for compatibility
637 *
638 */
639
640#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
641
642#define KEY_BREAK 0x101 /* Not on PC KBD */
643#define KEY_DOWN 0x102 /* Down arrow key */
644#define KEY_UP 0x103 /* Up arrow key */
645#define KEY_LEFT 0x104 /* Left arrow key */
646#define KEY_RIGHT 0x105 /* Right arrow key */
647#define KEY_HOME 0x106 /* home key */
648#define KEY_BACKSPACE 0x107 /* not on pc */
649#define KEY_F0 0x108 /* function keys; 64 reserved */
650
651#define KEY_DL 0x148 /* delete line */
652#define KEY_IL 0x149 /* insert line */
653#define KEY_DC 0x14a /* delete character */
654#define KEY_IC 0x14b /* insert char or enter ins mode */
655#define KEY_EIC 0x14c /* exit insert char mode */
656#define KEY_CLEAR 0x14d /* clear screen */
657#define KEY_EOS 0x14e /* clear to end of screen */
658#define KEY_EOL 0x14f /* clear to end of line */
659#define KEY_SF 0x150 /* scroll 1 line forward */
660#define KEY_SR 0x151 /* scroll 1 line back (reverse) */
661#define KEY_NPAGE 0x152 /* next page */
662#define KEY_PPAGE 0x153 /* previous page */
663#define KEY_STAB 0x154 /* set tab */
664#define KEY_CTAB 0x155 /* clear tab */
665#define KEY_CATAB 0x156 /* clear all tabs */
666#define KEY_ENTER 0x157 /* enter or send (unreliable) */
667#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */
668#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */
669#define KEY_PRINT 0x15a /* print/copy */
670#define KEY_LL 0x15b /* home down/bottom (lower left) */
671#define KEY_ABORT 0x15c /* abort/terminate key (any) */
672#define KEY_SHELP 0x15d /* short help */
673#define KEY_LHELP 0x15e /* long help */
674#define KEY_BTAB 0x15f /* Back tab key */
675#define KEY_BEG 0x160 /* beg(inning) key */
676#define KEY_CANCEL 0x161 /* cancel key */
677#define KEY_CLOSE 0x162 /* close key */
678#define KEY_COMMAND 0x163 /* cmd (command) key */
679#define KEY_COPY 0x164 /* copy key */
680#define KEY_CREATE 0x165 /* create key */
681#define KEY_END 0x166 /* end key */
682#define KEY_EXIT 0x167 /* exit key */
683#define KEY_FIND 0x168 /* find key */
684#define KEY_HELP 0x169 /* help key */
685#define KEY_MARK 0x16a /* mark key */
686#define KEY_MESSAGE 0x16b /* message key */
687#define KEY_MOVE 0x16c /* move key */
688#define KEY_NEXT 0x16d /* next object key */
689#define KEY_OPEN 0x16e /* open key */
690#define KEY_OPTIONS 0x16f /* options key */
691#define KEY_PREVIOUS 0x170 /* previous object key */
692#define KEY_REDO 0x171 /* redo key */
693#define KEY_REFERENCE 0x172 /* ref(erence) key */
694#define KEY_REFRESH 0x173 /* refresh key */
695#define KEY_REPLACE 0x174 /* replace key */
696#define KEY_RESTART 0x175 /* restart key */
697#define KEY_RESUME 0x176 /* resume key */
698#define KEY_SAVE 0x177 /* save key */
699#define KEY_SBEG 0x178 /* shifted beginning key */
700#define KEY_SCANCEL 0x179 /* shifted cancel key */
701#define KEY_SCOMMAND 0x17a /* shifted command key */
702#define KEY_SCOPY 0x17b /* shifted copy key */
703#define KEY_SCREATE 0x17c /* shifted create key */
704#define KEY_SDC 0x17d /* shifted delete char key */
705#define KEY_SDL 0x17e /* shifted delete line key */
706#define KEY_SELECT 0x17f /* select key */
707#define KEY_SEND 0x180 /* shifted end key */
708#define KEY_SEOL 0x181 /* shifted clear line key */
709#define KEY_SEXIT 0x182 /* shifted exit key */
710#define KEY_SFIND 0x183 /* shifted find key */
711#define KEY_SHOME 0x184 /* shifted home key */
712#define KEY_SIC 0x185 /* shifted input key */
713
714#define KEY_SLEFT 0x187 /* shifted left arrow key */
715#define KEY_SMESSAGE 0x188 /* shifted message key */
716#define KEY_SMOVE 0x189 /* shifted move key */
717#define KEY_SNEXT 0x18a /* shifted next key */
718#define KEY_SOPTIONS 0x18b /* shifted options key */
719#define KEY_SPREVIOUS 0x18c /* shifted prev key */
720#define KEY_SPRINT 0x18d /* shifted print key */
721#define KEY_SREDO 0x18e /* shifted redo key */
722#define KEY_SREPLACE 0x18f /* shifted replace key */
723#define KEY_SRIGHT 0x190 /* shifted right arrow */
724#define KEY_SRSUME 0x191 /* shifted resume key */
725#define KEY_SSAVE 0x192 /* shifted save key */
726#define KEY_SSUSPEND 0x193 /* shifted suspend key */
727#define KEY_SUNDO 0x194 /* shifted undo key */
728#define KEY_SUSPEND 0x195 /* suspend key */
729#define KEY_UNDO 0x196 /* undo key */
730
731/* PDCurses-specific key definitions -- PC only */
732
733#define ALT_0 0x197
734#define ALT_1 0x198
735#define ALT_2 0x199
736#define ALT_3 0x19a
737#define ALT_4 0x19b
738#define ALT_5 0x19c
739#define ALT_6 0x19d
740#define ALT_7 0x19e
741#define ALT_8 0x19f
742#define ALT_9 0x1a0
743#define ALT_A 0x1a1
744#define ALT_B 0x1a2
745#define ALT_C 0x1a3
746#define ALT_D 0x1a4
747#define ALT_E 0x1a5
748#define ALT_F 0x1a6
749#define ALT_G 0x1a7
750#define ALT_H 0x1a8
751#define ALT_I 0x1a9
752#define ALT_J 0x1aa
753#define ALT_K 0x1ab
754#define ALT_L 0x1ac
755#define ALT_M 0x1ad
756#define ALT_N 0x1ae
757#define ALT_O 0x1af
758#define ALT_P 0x1b0
759#define ALT_Q 0x1b1
760#define ALT_R 0x1b2
761#define ALT_S 0x1b3
762#define ALT_T 0x1b4
763#define ALT_U 0x1b5
764#define ALT_V 0x1b6
765#define ALT_W 0x1b7
766#define ALT_X 0x1b8
767#define ALT_Y 0x1b9
768#define ALT_Z 0x1ba
769
770#define CTL_LEFT 0x1bb /* Control-Left-Arrow */
771#define CTL_RIGHT 0x1bc
772#define CTL_PGUP 0x1bd
773#define CTL_PGDN 0x1be
774#define CTL_HOME 0x1bf
775#define CTL_END 0x1c0
776
777#define KEY_A1 0x1c1 /* upper left on Virtual keypad */
778#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */
779#define KEY_A3 0x1c3 /* upper right on Vir. keypad */
780#define KEY_B1 0x1c4 /* middle left on Virt. keypad */
781#define KEY_B2 0x1c5 /* center on Virt. keypad */
782#define KEY_B3 0x1c6 /* middle right on Vir. keypad */
783#define KEY_C1 0x1c7 /* lower left on Virt. keypad */
784#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */
785#define KEY_C3 0x1c9 /* lower right on Vir. keypad */
786
787#define PADSLASH 0x1ca /* slash on keypad */
788#define PADENTER 0x1cb /* enter on keypad */
789#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */
790#define ALT_PADENTER 0x1cd /* alt-enter on keypad */
791#define PADSTOP 0x1ce /* stop on keypad */
792#define PADSTAR 0x1cf /* star on keypad */
793#define PADMINUS 0x1d0 /* minus on keypad */
794#define PADPLUS 0x1d1 /* plus on keypad */
795#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */
796#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */
797#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */
798#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */
799#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */
800#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */
801#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */
802#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */
803#define ALT_PADSLASH 0x1da /* alt-slash on keypad */
804#define ALT_PADSTAR 0x1db /* alt-star on keypad */
805#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */
806#define CTL_INS 0x1dd /* ctl-insert */
807#define ALT_DEL 0x1de /* alt-delete */
808#define ALT_INS 0x1df /* alt-insert */
809#define CTL_UP 0x1e0 /* ctl-up arrow */
810#define CTL_DOWN 0x1e1 /* ctl-down arrow */
811#define CTL_TAB 0x1e2 /* ctl-tab */
812#define ALT_TAB 0x1e3
813#define ALT_MINUS 0x1e4
814#define ALT_EQUAL 0x1e5
815#define ALT_HOME 0x1e6
816#define ALT_PGUP 0x1e7
817#define ALT_PGDN 0x1e8
818#define ALT_END 0x1e9
819#define ALT_UP 0x1ea /* alt-up arrow */
820#define ALT_DOWN 0x1eb /* alt-down arrow */
821#define ALT_RIGHT 0x1ec /* alt-right arrow */
822#define ALT_LEFT 0x1ed /* alt-left arrow */
823#define ALT_ENTER 0x1ee /* alt-enter */
824#define ALT_ESC 0x1ef /* alt-escape */
825#define ALT_BQUOTE 0x1f0 /* alt-back quote */
826#define ALT_LBRACKET 0x1f1 /* alt-left bracket */
827#define ALT_RBRACKET 0x1f2 /* alt-right bracket */
828#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */
829#define ALT_FQUOTE 0x1f4 /* alt-forward quote */
830#define ALT_COMMA 0x1f5 /* alt-comma */
831#define ALT_STOP 0x1f6 /* alt-stop */
832#define ALT_FSLASH 0x1f7 /* alt-forward slash */
833#define ALT_BKSP 0x1f8 /* alt-backspace */
834#define CTL_BKSP 0x1f9 /* ctl-backspace */
835#define PAD0 0x1fa /* keypad 0 */
836
837#define CTL_PAD0 0x1fb /* ctl-keypad 0 */
838#define CTL_PAD1 0x1fc
839#define CTL_PAD2 0x1fd
840#define CTL_PAD3 0x1fe
841#define CTL_PAD4 0x1ff
842#define CTL_PAD5 0x200
843#define CTL_PAD6 0x201
844#define CTL_PAD7 0x202
845#define CTL_PAD8 0x203
846#define CTL_PAD9 0x204
847
848#define ALT_PAD0 0x205 /* alt-keypad 0 */
849#define ALT_PAD1 0x206
850#define ALT_PAD2 0x207
851#define ALT_PAD3 0x208
852#define ALT_PAD4 0x209
853#define ALT_PAD5 0x20a
854#define ALT_PAD6 0x20b
855#define ALT_PAD7 0x20c
856#define ALT_PAD8 0x20d
857#define ALT_PAD9 0x20e
858
859#define CTL_DEL 0x20f /* clt-delete */
860#define ALT_BSLASH 0x210 /* alt-back slash */
861#define CTL_ENTER 0x211 /* ctl-enter */
862
863#define SHF_PADENTER 0x212 /* shift-enter on keypad */
864#define SHF_PADSLASH 0x213 /* shift-slash on keypad */
865#define SHF_PADSTAR 0x214 /* shift-star on keypad */
866#define SHF_PADPLUS 0x215 /* shift-plus on keypad */
867#define SHF_PADMINUS 0x216 /* shift-minus on keypad */
868#define SHF_UP 0x217 /* shift-up on keypad */
869#define SHF_DOWN 0x218 /* shift-down on keypad */
870#define SHF_IC 0x219 /* shift-insert on keypad */
871#define SHF_DC 0x21a /* shift-delete on keypad */
872
873#define KEY_MOUSE 0x21b /* "mouse" key */
874#define KEY_SHIFT_L 0x21c /* Left-shift */
875#define KEY_SHIFT_R 0x21d /* Right-shift */
876#define KEY_CONTROL_L 0x21e /* Left-control */
877#define KEY_CONTROL_R 0x21f /* Right-control */
878#define KEY_ALT_L 0x220 /* Left-alt */
879#define KEY_ALT_R 0x221 /* Right-alt */
880#define KEY_RESIZE 0x222 /* Window resize */
881#define KEY_SUP 0x223 /* Shifted up arrow */
882#define KEY_SDOWN 0x224 /* Shifted down arrow */
883
884#define KEY_MIN KEY_BREAK /* Minimum curses key value */
885#define KEY_MAX KEY_SDOWN /* Maximum curses key */
886
887#define KEY_F(n) (KEY_F0 + (n))
888
889/*----------------------------------------------------------------------
890 *
891 * Functions
892 *
893 */
894
895/* Standard */
896
897PDCEX int addch(const chtype);
898PDCEX int addchnstr(const chtype *, int);
899PDCEX int addchstr(const chtype *);
900PDCEX int addnstr(const char *, int);
901PDCEX int addstr(const char *);
902PDCEX int attroff(chtype);
903PDCEX int attron(chtype);
904PDCEX int attrset(chtype);
905PDCEX int attr_get(attr_t *, short *, void *);
906PDCEX int attr_off(attr_t, void *);
907PDCEX int attr_on(attr_t, void *);
908PDCEX int attr_set(attr_t, short, void *);
909PDCEX int baudrate(void);
910PDCEX int beep(void);
911PDCEX int bkgd(chtype);
912PDCEX void bkgdset(chtype);
913PDCEX int border(chtype, chtype, chtype, chtype,
914 chtype, chtype, chtype, chtype);
915PDCEX int box(WINDOW *, chtype, chtype);
916PDCEX bool can_change_color(void);
917PDCEX int cbreak(void);
918PDCEX int chgat(int, attr_t, short, const void *);
919PDCEX int clearok(WINDOW *, bool);
920PDCEX int clear(void);
921PDCEX int clrtobot(void);
922PDCEX int clrtoeol(void);
923PDCEX int color_content(short, short *, short *, short *);
924PDCEX int color_set(short, void *);
925PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int,
926 int, int, int, int);
927PDCEX int curs_set(int);
928PDCEX int def_prog_mode(void);
929PDCEX int def_shell_mode(void);
930PDCEX int delay_output(int);
931PDCEX int delch(void);
932PDCEX int deleteln(void);
933PDCEX void delscreen(SCREEN *);
934PDCEX int delwin(WINDOW *);
935PDCEX WINDOW *derwin(WINDOW *, int, int, int, int);
936PDCEX int doupdate(void);
937PDCEX WINDOW *dupwin(WINDOW *);
938PDCEX int echochar(const chtype);
939PDCEX int echo(void);
940PDCEX int endwin(void);
941PDCEX char erasechar(void);
942PDCEX int erase(void);
943PDCEX void filter(void);
944PDCEX int flash(void);
945PDCEX int flushinp(void);
946PDCEX chtype getbkgd(WINDOW *);
947PDCEX int getnstr(char *, int);
948PDCEX int getstr(char *);
949PDCEX WINDOW *getwin(FILE *);
950PDCEX int halfdelay(int);
951PDCEX bool has_colors(void);
952PDCEX bool has_ic(void);
953PDCEX bool has_il(void);
954PDCEX int hline(chtype, int);
955PDCEX void idcok(WINDOW *, bool);
956PDCEX int idlok(WINDOW *, bool);
957PDCEX void immedok(WINDOW *, bool);
958PDCEX int inchnstr(chtype *, int);
959PDCEX int inchstr(chtype *);
960PDCEX chtype inch(void);
961PDCEX int init_color(short, short, short, short);
962PDCEX int init_pair(short, short, short);
963PDCEX WINDOW *initscr(void);
964PDCEX int innstr(char *, int);
965PDCEX int insch(chtype);
966PDCEX int insdelln(int);
967PDCEX int insertln(void);
968PDCEX int insnstr(const char *, int);
969PDCEX int insstr(const char *);
970PDCEX int instr(char *);
971PDCEX int intrflush(WINDOW *, bool);
972PDCEX bool isendwin(void);
973PDCEX bool is_linetouched(WINDOW *, int);
974PDCEX bool is_wintouched(WINDOW *);
975PDCEX char *keyname(int);
976PDCEX int keypad(WINDOW *, bool);
977PDCEX char killchar(void);
978PDCEX int leaveok(WINDOW *, bool);
979PDCEX char *longname(void);
980PDCEX int meta(WINDOW *, bool);
981PDCEX int move(int, int);
982PDCEX int mvaddch(int, int, const chtype);
983PDCEX int mvaddchnstr(int, int, const chtype *, int);
984PDCEX int mvaddchstr(int, int, const chtype *);
985PDCEX int mvaddnstr(int, int, const char *, int);
986PDCEX int mvaddstr(int, int, const char *);
987PDCEX int mvchgat(int, int, int, attr_t, short, const void *);
988PDCEX int mvcur(int, int, int, int);
989PDCEX int mvdelch(int, int);
990PDCEX int mvderwin(WINDOW *, int, int);
991PDCEX int mvgetch(int, int);
992PDCEX int mvgetnstr(int, int, char *, int);
993PDCEX int mvgetstr(int, int, char *);
994PDCEX int mvhline(int, int, chtype, int);
995PDCEX chtype mvinch(int, int);
996PDCEX int mvinchnstr(int, int, chtype *, int);
997PDCEX int mvinchstr(int, int, chtype *);
998PDCEX int mvinnstr(int, int, char *, int);
999PDCEX int mvinsch(int, int, chtype);
1000PDCEX int mvinsnstr(int, int, const char *, int);
1001PDCEX int mvinsstr(int, int, const char *);
1002PDCEX int mvinstr(int, int, char *);
1003PDCEX int mvprintw(int, int, const char *, ...);
1004PDCEX int mvscanw(int, int, const char *, ...);
1005PDCEX int mvvline(int, int, chtype, int);
1006PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
1007PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *);
1008PDCEX int mvwaddch(WINDOW *, int, int, const chtype);
1009PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int);
1010PDCEX int mvwaddstr(WINDOW *, int, int, const char *);
1011PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
1012PDCEX int mvwdelch(WINDOW *, int, int);
1013PDCEX int mvwgetch(WINDOW *, int, int);
1014PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int);
1015PDCEX int mvwgetstr(WINDOW *, int, int, char *);
1016PDCEX int mvwhline(WINDOW *, int, int, chtype, int);
1017PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int);
1018PDCEX int mvwinchstr(WINDOW *, int, int, chtype *);
1019PDCEX chtype mvwinch(WINDOW *, int, int);
1020PDCEX int mvwinnstr(WINDOW *, int, int, char *, int);
1021PDCEX int mvwinsch(WINDOW *, int, int, chtype);
1022PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int);
1023PDCEX int mvwinsstr(WINDOW *, int, int, const char *);
1024PDCEX int mvwinstr(WINDOW *, int, int, char *);
1025PDCEX int mvwin(WINDOW *, int, int);
1026PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...);
1027PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...);
1028PDCEX int mvwvline(WINDOW *, int, int, chtype, int);
1029PDCEX int napms(int);
1030PDCEX WINDOW *newpad(int, int);
1031PDCEX SCREEN *newterm(const char *, FILE *, FILE *);
1032PDCEX WINDOW *newwin(int, int, int, int);
1033PDCEX int nl(void);
1034PDCEX int nocbreak(void);
1035PDCEX int nodelay(WINDOW *, bool);
1036PDCEX int noecho(void);
1037PDCEX int nonl(void);
1038PDCEX void noqiflush(void);
1039PDCEX int noraw(void);
1040PDCEX int notimeout(WINDOW *, bool);
1041PDCEX int overlay(const WINDOW *, WINDOW *);
1042PDCEX int overwrite(const WINDOW *, WINDOW *);
1043PDCEX int pair_content(short, short *, short *);
1044PDCEX int pechochar(WINDOW *, chtype);
1045PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
1046PDCEX int prefresh(WINDOW *, int, int, int, int, int, int);
1047PDCEX int printw(const char *, ...);
1048PDCEX int putwin(WINDOW *, FILE *);
1049PDCEX void qiflush(void);
1050PDCEX int raw(void);
1051PDCEX int redrawwin(WINDOW *);
1052PDCEX int refresh(void);
1053PDCEX int reset_prog_mode(void);
1054PDCEX int reset_shell_mode(void);
1055PDCEX int resetty(void);
1056PDCEX int ripoffline(int, int (*)(WINDOW *, int));
1057PDCEX int savetty(void);
1058PDCEX int scanw(const char *, ...);
1059PDCEX int scr_dump(const char *);
1060PDCEX int scr_init(const char *);
1061PDCEX int scr_restore(const char *);
1062PDCEX int scr_set(const char *);
1063PDCEX int scrl(int);
1064PDCEX int scroll(WINDOW *);
1065PDCEX int scrollok(WINDOW *, bool);
1066PDCEX SCREEN *set_term(SCREEN *);
1067PDCEX int setscrreg(int, int);
1068PDCEX int slk_attroff(const chtype);
1069PDCEX int slk_attr_off(const attr_t, void *);
1070PDCEX int slk_attron(const chtype);
1071PDCEX int slk_attr_on(const attr_t, void *);
1072PDCEX int slk_attrset(const chtype);
1073PDCEX int slk_attr_set(const attr_t, short, void *);
1074PDCEX int slk_clear(void);
1075PDCEX int slk_color(short);
1076PDCEX int slk_init(int);
1077PDCEX char *slk_label(int);
1078PDCEX int slk_noutrefresh(void);
1079PDCEX int slk_refresh(void);
1080PDCEX int slk_restore(void);
1081PDCEX int slk_set(int, const char *, int);
1082PDCEX int slk_touch(void);
1083PDCEX int standend(void);
1084PDCEX int standout(void);
1085PDCEX int start_color(void);
1086PDCEX WINDOW *subpad(WINDOW *, int, int, int, int);
1087PDCEX WINDOW *subwin(WINDOW *, int, int, int, int);
1088PDCEX int syncok(WINDOW *, bool);
1089PDCEX chtype termattrs(void);
1090PDCEX attr_t term_attrs(void);
1091PDCEX char *termname(void);
1092PDCEX void timeout(int);
1093PDCEX int touchline(WINDOW *, int, int);
1094PDCEX int touchwin(WINDOW *);
1095PDCEX int typeahead(int);
1096PDCEX int untouchwin(WINDOW *);
1097PDCEX void use_env(bool);
1098PDCEX int vidattr(chtype);
1099PDCEX int vid_attr(attr_t, short, void *);
1100PDCEX int vidputs(chtype, int (*)(int));
1101PDCEX int vid_puts(attr_t, short, void *, int (*)(int));
1102PDCEX int vline(chtype, int);
1103PDCEX int vw_printw(WINDOW *, const char *, va_list);
1104PDCEX int vwprintw(WINDOW *, const char *, va_list);
1105PDCEX int vw_scanw(WINDOW *, const char *, va_list);
1106PDCEX int vwscanw(WINDOW *, const char *, va_list);
1107PDCEX int waddchnstr(WINDOW *, const chtype *, int);
1108PDCEX int waddchstr(WINDOW *, const chtype *);
1109PDCEX int waddch(WINDOW *, const chtype);
1110PDCEX int waddnstr(WINDOW *, const char *, int);
1111PDCEX int waddstr(WINDOW *, const char *);
1112PDCEX int wattroff(WINDOW *, chtype);
1113PDCEX int wattron(WINDOW *, chtype);
1114PDCEX int wattrset(WINDOW *, chtype);
1115PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *);
1116PDCEX int wattr_off(WINDOW *, attr_t, void *);
1117PDCEX int wattr_on(WINDOW *, attr_t, void *);
1118PDCEX int wattr_set(WINDOW *, attr_t, short, void *);
1119PDCEX void wbkgdset(WINDOW *, chtype);
1120PDCEX int wbkgd(WINDOW *, chtype);
1121PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype,
1122 chtype, chtype, chtype, chtype);
1123PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *);
1124PDCEX int wclear(WINDOW *);
1125PDCEX int wclrtobot(WINDOW *);
1126PDCEX int wclrtoeol(WINDOW *);
1127PDCEX int wcolor_set(WINDOW *, short, void *);
1128PDCEX void wcursyncup(WINDOW *);
1129PDCEX int wdelch(WINDOW *);
1130PDCEX int wdeleteln(WINDOW *);
1131PDCEX int wechochar(WINDOW *, const chtype);
1132PDCEX int werase(WINDOW *);
1133PDCEX int wgetch(WINDOW *);
1134PDCEX int wgetnstr(WINDOW *, char *, int);
1135PDCEX int wgetstr(WINDOW *, char *);
1136PDCEX int whline(WINDOW *, chtype, int);
1137PDCEX int winchnstr(WINDOW *, chtype *, int);
1138PDCEX int winchstr(WINDOW *, chtype *);
1139PDCEX chtype winch(WINDOW *);
1140PDCEX int winnstr(WINDOW *, char *, int);
1141PDCEX int winsch(WINDOW *, chtype);
1142PDCEX int winsdelln(WINDOW *, int);
1143PDCEX int winsertln(WINDOW *);
1144PDCEX int winsnstr(WINDOW *, const char *, int);
1145PDCEX int winsstr(WINDOW *, const char *);
1146PDCEX int winstr(WINDOW *, char *);
1147PDCEX int wmove(WINDOW *, int, int);
1148PDCEX int wnoutrefresh(WINDOW *);
1149PDCEX int wprintw(WINDOW *, const char *, ...);
1150PDCEX int wredrawln(WINDOW *, int, int);
1151PDCEX int wrefresh(WINDOW *);
1152PDCEX int wscanw(WINDOW *, const char *, ...);
1153PDCEX int wscrl(WINDOW *, int);
1154PDCEX int wsetscrreg(WINDOW *, int, int);
1155PDCEX int wstandend(WINDOW *);
1156PDCEX int wstandout(WINDOW *);
1157PDCEX void wsyncdown(WINDOW *);
1158PDCEX void wsyncup(WINDOW *);
1159PDCEX void wtimeout(WINDOW *, int);
1160PDCEX int wtouchln(WINDOW *, int, int, int);
1161PDCEX int wvline(WINDOW *, chtype, int);
1162
1163/* Wide-character functions */
1164
1165#ifdef PDC_WIDE
1166PDCEX int addnwstr(const wchar_t *, int);
1167PDCEX int addwstr(const wchar_t *);
1168PDCEX int add_wch(const cchar_t *);
1169PDCEX int add_wchnstr(const cchar_t *, int);
1170PDCEX int add_wchstr(const cchar_t *);
1171PDCEX int bkgrnd(const cchar_t *);
1172PDCEX void bkgrndset(const cchar_t *);
1173PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *,
1174 const cchar_t *, const cchar_t *, const cchar_t *,
1175 const cchar_t *, const cchar_t *);
1176PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *);
1177PDCEX int echo_wchar(const cchar_t *);
1178PDCEX int erasewchar(wchar_t *);
1179PDCEX int getbkgrnd(cchar_t *);
1180PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
1181PDCEX int getn_wstr(wint_t *, int);
1182PDCEX int get_wch(wint_t *);
1183PDCEX int get_wstr(wint_t *);
1184PDCEX int hline_set(const cchar_t *, int);
1185PDCEX int innwstr(wchar_t *, int);
1186PDCEX int ins_nwstr(const wchar_t *, int);
1187PDCEX int ins_wch(const cchar_t *);
1188PDCEX int ins_wstr(const wchar_t *);
1189PDCEX int inwstr(wchar_t *);
1190PDCEX int in_wch(cchar_t *);
1191PDCEX int in_wchnstr(cchar_t *, int);
1192PDCEX int in_wchstr(cchar_t *);
1193PDCEX char *key_name(wchar_t);
1194PDCEX int killwchar(wchar_t *);
1195PDCEX int mvaddnwstr(int, int, const wchar_t *, int);
1196PDCEX int mvaddwstr(int, int, const wchar_t *);
1197PDCEX int mvadd_wch(int, int, const cchar_t *);
1198PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int);
1199PDCEX int mvadd_wchstr(int, int, const cchar_t *);
1200PDCEX int mvgetn_wstr(int, int, wint_t *, int);
1201PDCEX int mvget_wch(int, int, wint_t *);
1202PDCEX int mvget_wstr(int, int, wint_t *);
1203PDCEX int mvhline_set(int, int, const cchar_t *, int);
1204PDCEX int mvinnwstr(int, int, wchar_t *, int);
1205PDCEX int mvins_nwstr(int, int, const wchar_t *, int);
1206PDCEX int mvins_wch(int, int, const cchar_t *);
1207PDCEX int mvins_wstr(int, int, const wchar_t *);
1208PDCEX int mvinwstr(int, int, wchar_t *);
1209PDCEX int mvin_wch(int, int, cchar_t *);
1210PDCEX int mvin_wchnstr(int, int, cchar_t *, int);
1211PDCEX int mvin_wchstr(int, int, cchar_t *);
1212PDCEX int mvvline_set(int, int, const cchar_t *, int);
1213PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
1214PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
1215PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
1216PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
1217PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
1218PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
1219PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *);
1220PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *);
1221PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
1222PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
1223PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
1224PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *);
1225PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
1226PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *);
1227PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
1228PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
1229PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *);
1230PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
1231PDCEX int pecho_wchar(WINDOW *, const cchar_t*);
1232PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t,
1233 short, const void*);
1234PDCEX int slk_wset(int, const wchar_t *, int);
1235PDCEX int unget_wch(const wchar_t);
1236PDCEX int vline_set(const cchar_t *, int);
1237PDCEX int waddnwstr(WINDOW *, const wchar_t *, int);
1238PDCEX int waddwstr(WINDOW *, const wchar_t *);
1239PDCEX int wadd_wch(WINDOW *, const cchar_t *);
1240PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int);
1241PDCEX int wadd_wchstr(WINDOW *, const cchar_t *);
1242PDCEX int wbkgrnd(WINDOW *, const cchar_t *);
1243PDCEX void wbkgrndset(WINDOW *, const cchar_t *);
1244PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *,
1245 const cchar_t *, const cchar_t *, const cchar_t *,
1246 const cchar_t *, const cchar_t *, const cchar_t *);
1247PDCEX int wecho_wchar(WINDOW *, const cchar_t *);
1248PDCEX int wgetbkgrnd(WINDOW *, cchar_t *);
1249PDCEX int wgetn_wstr(WINDOW *, wint_t *, int);
1250PDCEX int wget_wch(WINDOW *, wint_t *);
1251PDCEX int wget_wstr(WINDOW *, wint_t *);
1252PDCEX int whline_set(WINDOW *, const cchar_t *, int);
1253PDCEX int winnwstr(WINDOW *, wchar_t *, int);
1254PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int);
1255PDCEX int wins_wch(WINDOW *, const cchar_t *);
1256PDCEX int wins_wstr(WINDOW *, const wchar_t *);
1257PDCEX int winwstr(WINDOW *, wchar_t *);
1258PDCEX int win_wch(WINDOW *, cchar_t *);
1259PDCEX int win_wchnstr(WINDOW *, cchar_t *, int);
1260PDCEX int win_wchstr(WINDOW *, cchar_t *);
1261PDCEX wchar_t *wunctrl(cchar_t *);
1262PDCEX int wvline_set(WINDOW *, const cchar_t *, int);
1263#endif
1264
1265/* Quasi-standard */
1266
1267PDCEX chtype getattrs(WINDOW *);
1268PDCEX int getbegx(WINDOW *);
1269PDCEX int getbegy(WINDOW *);
1270PDCEX int getmaxx(WINDOW *);
1271PDCEX int getmaxy(WINDOW *);
1272PDCEX int getparx(WINDOW *);
1273PDCEX int getpary(WINDOW *);
1274PDCEX int getcurx(WINDOW *);
1275PDCEX int getcury(WINDOW *);
1276PDCEX void traceoff(void);
1277PDCEX void traceon(void);
1278PDCEX char *unctrl(chtype);
1279
1280PDCEX int crmode(void);
1281PDCEX int nocrmode(void);
1282PDCEX int draino(int);
1283PDCEX int resetterm(void);
1284PDCEX int fixterm(void);
1285PDCEX int saveterm(void);
1286PDCEX void setsyx(int, int);
1287
1288PDCEX int mouse_set(mmask_t);
1289PDCEX int mouse_on(mmask_t);
1290PDCEX int mouse_off(mmask_t);
1291PDCEX int request_mouse_pos(void);
1292PDCEX void wmouse_position(WINDOW *, int *, int *);
1293PDCEX mmask_t getmouse(void);
1294
1295/* ncurses */
1296
1297PDCEX int alloc_pair(int, int);
1298PDCEX int assume_default_colors(int, int);
1299PDCEX const char *curses_version(void);
1300PDCEX int find_pair(int, int);
1301PDCEX int free_pair(int);
1302PDCEX bool has_key(int);
1303PDCEX bool is_cleared(const WINDOW *);
1304PDCEX bool is_idcok(const WINDOW *);
1305PDCEX bool is_idlok(const WINDOW *);
1306PDCEX bool is_immedok(const WINDOW *);
1307PDCEX bool is_keypad(const WINDOW *);
1308PDCEX bool is_leaveok(const WINDOW *);
1309PDCEX bool is_nodelay(const WINDOW *);
1310PDCEX bool is_notimeout(const WINDOW *);
1311PDCEX bool is_pad(const WINDOW *);
1312PDCEX bool is_scrollok(const WINDOW *);
1313PDCEX bool is_subwin(const WINDOW *);
1314PDCEX bool is_syncok(const WINDOW *);
1315PDCEX int set_tabsize(int);
1316PDCEX int use_default_colors(void);
1317PDCEX int wgetdelay(const WINDOW *);
1318PDCEX WINDOW *wgetparent(const WINDOW *);
1319PDCEX int wgetscrreg(const WINDOW *, int *, int *);
1320PDCEX int wresize(WINDOW *, int, int);
1321
1322PDCEX bool has_mouse(void);
1323PDCEX int mouseinterval(int);
1324PDCEX mmask_t mousemask(mmask_t, mmask_t *);
1325PDCEX bool mouse_trafo(int *, int *, bool);
1326PDCEX int nc_getmouse(MEVENT *);
1327PDCEX int ungetmouse(MEVENT *);
1328PDCEX bool wenclose(const WINDOW *, int, int);
1329PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool);
1330
1331/* PDCurses */
1332
1333PDCEX int addrawch(chtype);
1334PDCEX int insrawch(chtype);
1335PDCEX bool is_termresized(void);
1336PDCEX int mvaddrawch(int, int, chtype);
1337PDCEX int mvdeleteln(int, int);
1338PDCEX int mvinsertln(int, int);
1339PDCEX int mvinsrawch(int, int, chtype);
1340PDCEX int mvwaddrawch(WINDOW *, int, int, chtype);
1341PDCEX int mvwdeleteln(WINDOW *, int, int);
1342PDCEX int mvwinsertln(WINDOW *, int, int);
1343PDCEX int mvwinsrawch(WINDOW *, int, int, chtype);
1344PDCEX int raw_output(bool);
1345PDCEX int resize_term(int, int);
1346PDCEX WINDOW *resize_window(WINDOW *, int, int);
1347PDCEX int waddrawch(WINDOW *, chtype);
1348PDCEX int winsrawch(WINDOW *, chtype);
1349PDCEX char wordchar(void);
1350
1351#ifdef PDC_WIDE
1352PDCEX wchar_t *slk_wlabel(int);
1353#endif
1354
1355PDCEX void PDC_debug(const char *, ...);
1356PDCEX void PDC_get_version(PDC_VERSION *);
1357PDCEX int PDC_ungetch(int);
1358PDCEX int PDC_set_blink(bool);
1359PDCEX int PDC_set_bold(bool);
1360PDCEX int PDC_set_line_color(short);
1361PDCEX void PDC_set_title(const char *);
1362
1363PDCEX int PDC_clearclipboard(void);
1364PDCEX int PDC_freeclipboard(char *);
1365PDCEX int PDC_getclipboard(char **, long *);
1366PDCEX int PDC_setclipboard(const char *, long);
1367
1368PDCEX unsigned long PDC_get_key_modifiers(void);
1369PDCEX int PDC_return_key_modifiers(bool);
1370
1371#ifdef XCURSES
1372PDCEX WINDOW *Xinitscr(int, char **);
1373PDCEX void XCursesExit(void);
1374PDCEX int sb_init(void);
1375PDCEX int sb_set_horz(int, int, int);
1376PDCEX int sb_set_vert(int, int, int);
1377PDCEX int sb_get_horz(int *, int *, int *);
1378PDCEX int sb_get_vert(int *, int *, int *);
1379PDCEX int sb_refresh(void);
1380#endif
1381
1382/* NetBSD */
1383
1384PDCEX int touchoverlap(const WINDOW *, WINDOW *);
1385PDCEX int underend(void);
1386PDCEX int underscore(void);
1387PDCEX int wunderend(WINDOW *);
1388PDCEX int wunderscore(WINDOW *);
1389
1390/*** Functions defined as macros ***/
1391
1392/* getch() and ungetch() conflict with some DOS libraries */
1393
1394#define getch() wgetch(stdscr)
1395#define ungetch(ch) PDC_ungetch(ch)
1396
1397#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR)
1398#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT)
1399
1400/* These will _only_ work as macros */
1401
1402#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w))
1403#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w))
1404#define getparyx(w, y, x) (y = getpary(w), x = getparx(w))
1405#define getyx(w, y, x) (y = getcury(w), x = getcurx(w))
1406
1407#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \
1408 else getyx(curscr,(y),(x)); }
1409
1410#ifdef NCURSES_MOUSE_VERSION
1411# define getmouse(x) nc_getmouse(x)
1412#endif
1413
1414/* Deprecated */
1415
1416#define PDC_save_key_modifiers(x) (OK)
1417#define PDC_get_input_fd() 0
1418
1419/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */
1420
1421#define PDC_CLIP_SUCCESS 0
1422#define PDC_CLIP_ACCESS_ERROR 1
1423#define PDC_CLIP_EMPTY 2
1424#define PDC_CLIP_MEMORY_ERROR 3
1425
1426/* PDCurses key modifier masks */
1427
1428#define PDC_KEY_MODIFIER_SHIFT 1
1429#define PDC_KEY_MODIFIER_CONTROL 2
1430#define PDC_KEY_MODIFIER_ALT 4
1431#define PDC_KEY_MODIFIER_NUMLOCK 8
1432
1433#ifdef __cplusplus
1434# ifndef PDC_PP98
1435# undef bool
1436# endif
1437}
1438#endif
1439
1440#endif /* __PDCURSES__ */
diff --git a/scripts/kconfig/libcurses/curspriv.h b/scripts/kconfig/libcurses/curspriv.h
new file mode 100644
index 000000000..5a6ec1550
--- /dev/null
+++ b/scripts/kconfig/libcurses/curspriv.h
@@ -0,0 +1,133 @@
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#ifdef __cplusplus
11extern "C" {
12#endif
13
14#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
15 defined(PDC_99) || defined(__WATCOMC__)
16# ifndef HAVE_VSSCANF
17# define HAVE_VSSCANF 1 /* have vsscanf() */
18# endif
19#endif
20
21#if defined(PDC_99) || defined(__WATCOMC__)
22# ifndef HAVE_SNPRINTF
23# define HAVE_SNPRINTF 1 /* have snprintf() */
24# endif
25# ifndef HAVE_VSNPRINTF
26# define HAVE_VSNPRINTF 1 /* have vsnprintf() */
27# endif
28#endif
29
30/*----------------------------------------------------------------------*/
31
32typedef struct /* structure for ripped off lines */
33{
34 int line;
35 int (*init)(WINDOW *, int);
36} RIPPEDOFFLINE;
37
38/* Window properties */
39
40#define _SUBWIN 0x01 /* window is a subwindow */
41#define _PAD 0x10 /* X/Open Pad. */
42#define _SUBPAD 0x20 /* X/Open subpad. */
43
44/* Miscellaneous */
45
46#define _NO_CHANGE -1 /* flags line edge unchanged */
47
48#define _ECHAR 0x08 /* Erase char (^H) */
49#define _DWCHAR 0x17 /* Delete Word char (^W) */
50#define _DLCHAR 0x15 /* Delete Line char (^U) */
51
52/*----------------------------------------------------------------------*/
53
54/* Platform implementation functions */
55
56void PDC_beep(void);
57bool PDC_can_change_color(void);
58int PDC_color_content(short, short *, short *, short *);
59bool PDC_check_key(void);
60int PDC_curs_set(int);
61void PDC_doupdate(void);
62void PDC_flushinp(void);
63int PDC_get_columns(void);
64int PDC_get_cursor_mode(void);
65int PDC_get_key(void);
66int PDC_get_rows(void);
67void PDC_gotoyx(int, int);
68bool PDC_has_mouse(void);
69int PDC_init_color(short, short, short, short);
70int PDC_modifiers_set(void);
71int PDC_mouse_set(void);
72void PDC_napms(int);
73void PDC_reset_prog_mode(void);
74void PDC_reset_shell_mode(void);
75int PDC_resize_screen(int, int);
76void PDC_restore_screen_mode(int);
77void PDC_save_screen_mode(int);
78#ifdef XCURSES
79void PDC_set_args(int, char **);
80#endif
81void PDC_scr_close(void);
82void PDC_scr_free(void);
83int PDC_scr_open(void);
84void PDC_set_keyboard_binary(bool);
85void PDC_transform_line(int, int, int, const chtype *);
86const char *PDC_sysname(void);
87
88/* Internal cross-module functions */
89
90void PDC_init_atrtab(void);
91WINDOW *PDC_makelines(WINDOW *);
92WINDOW *PDC_makenew(int, int, int, int);
93int PDC_mouse_in_slk(int, int);
94void PDC_slk_free(void);
95void PDC_slk_initialize(void);
96void PDC_sync(WINDOW *);
97
98#ifdef PDC_WIDE
99int PDC_mbtowc(wchar_t *, const char *, size_t);
100size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
101size_t PDC_wcstombs(char *, const wchar_t *, size_t);
102#endif
103
104#ifdef PDCDEBUG
105# define PDC_LOG(x) if (SP && SP->dbfp) PDC_debug x
106#else
107# define PDC_LOG(x)
108#endif
109
110/* Internal macros for attributes */
111
112#ifndef max
113# define max(a,b) (((a) > (b)) ? (a) : (b))
114#endif
115#ifndef min
116# define min(a,b) (((a) < (b)) ? (a) : (b))
117#endif
118
119#define DIVROUND(num, divisor) ((num) + ((divisor) >> 1)) / (divisor)
120
121#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if
122 not set by mouseinterval() */
123#define PDC_COLOR_PAIRS 256
124#define PDC_MAXCOL 768 /* maximum possible COLORS; may be less */
125
126#define _INBUFSIZ 512 /* size of terminal input buffer */
127#define NUNGETCH 256 /* max # chars to ungetch() */
128
129#ifdef __cplusplus
130}
131#endif
132
133#endif /* __CURSES_INTERNALS__ */
diff --git a/scripts/kconfig/libcurses/getch.c b/scripts/kconfig/libcurses/getch.c
new file mode 100644
index 000000000..8719ca39c
--- /dev/null
+++ b/scripts/kconfig/libcurses/getch.c
@@ -0,0 +1,589 @@
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
96static int _get_box(int *y_start, int *y_end, int *x_start, int *x_end)
97{
98 int start, end;
99
100 if (SP->sel_start < SP->sel_end)
101 {
102 start = SP->sel_start;
103 end = SP->sel_end;
104 }
105 else
106 {
107 start = SP->sel_end;
108 end = SP->sel_start;
109 }
110
111 *y_start = start / COLS;
112 *x_start = start % COLS;
113
114 *y_end = end / COLS;
115 *x_end = end % COLS;
116
117 return (end - start) + (*y_end - *y_start);
118}
119
120static void _highlight(void)
121{
122 int i, j, y_start, y_end, x_start, x_end;
123
124 if (-1 == SP->sel_start)
125 return;
126
127 _get_box(&y_start, &y_end, &x_start, &x_end);
128
129 for (j = y_start; j <= y_end; j++)
130 for (i = (j == y_start ? x_start : 0);
131 i < (j == y_end ? x_end : COLS); i++)
132 curscr->_y[j][i] ^= A_REVERSE;
133
134 wrefresh(curscr);
135}
136
137static void _copy(void)
138{
139#ifdef PDC_WIDE
140 wchar_t *wtmp;
141# define TMP wtmp
142# define MASK A_CHARTEXT
143#else
144# define TMP tmp
145# define MASK 0xff
146#endif
147 char *tmp;
148 long pos;
149 int i, j, y_start, y_end, x_start, x_end, len;
150
151 if (-1 == SP->sel_start)
152 return;
153
154 len = _get_box(&y_start, &y_end, &x_start, &x_end);
155
156 if (!len)
157 return;
158
159#ifdef PDC_WIDE
160 wtmp = malloc((len + 1) * sizeof(wchar_t));
161 len *= 4;
162#endif
163 tmp = malloc(len + 1);
164
165 for (j = y_start, pos = 0; j <= y_end; j++)
166 {
167 for (i = (j == y_start ? x_start : 0);
168 i < (j == y_end ? x_end : COLS); i++)
169 TMP[pos++] = curscr->_y[j][i] & MASK;
170
171 while (y_start != y_end && pos > 0 && TMP[pos - 1] == 32)
172 pos--;
173
174 if (j < y_end)
175 TMP[pos++] = 10;
176 }
177 TMP[pos] = 0;
178
179#ifdef PDC_WIDE
180 pos = PDC_wcstombs(tmp, wtmp, len);
181#endif
182
183 PDC_setclipboard(tmp, pos);
184 free(tmp);
185#ifdef PDC_WIDE
186 free(wtmp);
187#endif
188}
189
190static int _paste(void)
191{
192#ifdef PDC_WIDE
193 wchar_t *wpaste;
194# define PASTE wpaste
195#else
196# define PASTE paste
197#endif
198 char *paste;
199 long len, newmax;
200 int key;
201
202 key = PDC_getclipboard(&paste, &len);
203 if (PDC_CLIP_SUCCESS != key || !len)
204 return -1;
205
206#ifdef PDC_WIDE
207 wpaste = malloc(len * sizeof(wchar_t));
208 len = PDC_mbstowcs(wpaste, paste, len);
209#endif
210 newmax = len + SP->c_ungind;
211 if (newmax > SP->c_ungmax)
212 {
213 SP->c_ungch = realloc(SP->c_ungch, newmax * sizeof(int));
214 if (!SP->c_ungch)
215 return -1;
216 SP->c_ungmax = newmax;
217 }
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 int key, waitcount;
326
327 PDC_LOG(("wgetch() - called\n"));
328
329 if (!win || !SP)
330 return ERR;
331
332 waitcount = 0;
333
334 /* set the number of 1/20th second napms() calls */
335
336 if (SP->delaytenths)
337 waitcount = 2 * SP->delaytenths;
338 else
339 if (win->_delayms)
340 {
341 /* Can't really do millisecond intervals, so delay in
342 1/20ths of a second (50ms) */
343
344 waitcount = win->_delayms / 50;
345 if (!waitcount)
346 waitcount = 1;
347 }
348
349 /* refresh window when wgetch is called if there have been changes
350 to it and it is not a pad */
351
352 if (!(win->_flags & _PAD) && ((!win->_leaveit &&
353 (win->_begx + win->_curx != SP->curscol ||
354 win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win)))
355 wrefresh(win);
356
357 /* if ungotten char exists, remove and return it */
358
359 if (SP->c_ungind)
360 return SP->c_ungch[--(SP->c_ungind)];
361
362 /* if normal and data in buffer */
363
364 if ((!SP->raw_inp && !SP->cbreak) && (SP->c_gindex < SP->c_pindex))
365 return SP->c_buffer[SP->c_gindex++];
366
367 /* prepare to buffer data */
368
369 SP->c_pindex = 0;
370 SP->c_gindex = 0;
371
372 /* to get here, no keys are buffered. go and get one. */
373
374 for (;;) /* loop for any buffering */
375 {
376 /* is there a keystroke ready? */
377
378 if (!PDC_check_key())
379 {
380 /* if not, handle timeout() and halfdelay() */
381
382 if (SP->delaytenths || win->_delayms)
383 {
384 if (!waitcount)
385 return ERR;
386
387 waitcount--;
388 }
389 else
390 if (win->_nodelay)
391 return ERR;
392
393 napms(50); /* sleep for 1/20th second */
394 continue; /* then check again */
395 }
396
397 /* if there is, fetch it */
398
399 key = PDC_get_key();
400
401 /* copy or paste? */
402
403 if (SP->key_modifiers & PDC_KEY_MODIFIER_SHIFT)
404 {
405 if (0x03 == key)
406 {
407 _copy();
408 continue;
409 }
410 else if (0x16 == key)
411 key = _paste();
412 }
413
414 /* filter mouse events; translate mouse clicks in the slk
415 area to function keys */
416
417 if (SP->key_code && key == KEY_MOUSE)
418 key = _mouse_key();
419
420 /* filter special keys if not in keypad mode */
421
422 if (SP->key_code && !win->_use_keypad)
423 key = -1;
424
425 /* unwanted key? loop back */
426
427 if (key == -1)
428 continue;
429
430 _highlight();
431 SP->sel_start = SP->sel_end = -1;
432
433 /* translate CR */
434
435 if (key == '\r' && SP->autocr && !SP->raw_inp)
436 key = '\n';
437
438 /* if echo is enabled */
439
440 if (SP->echo && !SP->key_code)
441 {
442 waddch(win, key);
443 wrefresh(win);
444 }
445
446 /* if no buffering */
447
448 if (SP->raw_inp || SP->cbreak)
449 return key;
450
451 /* if no overflow, put data in buffer */
452
453 if (key == '\b')
454 {
455 if (SP->c_pindex > SP->c_gindex)
456 SP->c_pindex--;
457 }
458 else
459 if (SP->c_pindex < _INBUFSIZ - 2)
460 SP->c_buffer[SP->c_pindex++] = key;
461
462 /* if we got a line */
463
464 if (key == '\n' || key == '\r')
465 return SP->c_buffer[SP->c_gindex++];
466 }
467}
468
469int mvgetch(int y, int x)
470{
471 PDC_LOG(("mvgetch() - called\n"));
472
473 if (move(y, x) == ERR)
474 return ERR;
475
476 return wgetch(stdscr);
477}
478
479int mvwgetch(WINDOW *win, int y, int x)
480{
481 PDC_LOG(("mvwgetch() - called\n"));
482
483 if (wmove(win, y, x) == ERR)
484 return ERR;
485
486 return wgetch(win);
487}
488
489int PDC_ungetch(int ch)
490{
491 PDC_LOG(("ungetch() - called\n"));
492
493 if (SP->c_ungind >= SP->c_ungmax) /* pushback stack full */
494 return ERR;
495
496 SP->c_ungch[SP->c_ungind++] = ch;
497
498 return OK;
499}
500
501int flushinp(void)
502{
503 PDC_LOG(("flushinp() - called\n"));
504
505 if (!SP)
506 return ERR;
507
508 PDC_flushinp();
509
510 SP->c_gindex = 1; /* set indices to kill buffer */
511 SP->c_pindex = 0;
512 SP->c_ungind = 0; /* clear SP->c_ungch array */
513
514 return OK;
515}
516
517unsigned long PDC_get_key_modifiers(void)
518{
519 PDC_LOG(("PDC_get_key_modifiers() - called\n"));
520
521 if (!SP)
522 return ERR;
523
524 return SP->key_modifiers;
525}
526
527int PDC_return_key_modifiers(bool flag)
528{
529 PDC_LOG(("PDC_return_key_modifiers() - called\n"));
530
531 if (!SP)
532 return ERR;
533
534 SP->return_key_modifiers = flag;
535 return PDC_modifiers_set();
536}
537
538#ifdef PDC_WIDE
539int wget_wch(WINDOW *win, wint_t *wch)
540{
541 int key;
542
543 PDC_LOG(("wget_wch() - called\n"));
544
545 if (!wch)
546 return ERR;
547
548 key = wgetch(win);
549
550 if (key == ERR)
551 return ERR;
552
553 *wch = key;
554
555 return SP->key_code ? KEY_CODE_YES : OK;
556}
557
558int get_wch(wint_t *wch)
559{
560 PDC_LOG(("get_wch() - called\n"));
561
562 return wget_wch(stdscr, wch);
563}
564
565int mvget_wch(int y, int x, wint_t *wch)
566{
567 PDC_LOG(("mvget_wch() - called\n"));
568
569 if (move(y, x) == ERR)
570 return ERR;
571
572 return wget_wch(stdscr, wch);
573}
574
575int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch)
576{
577 PDC_LOG(("mvwget_wch() - called\n"));
578
579 if (wmove(win, y, x) == ERR)
580 return ERR;
581
582 return wget_wch(win, wch);
583}
584
585int unget_wch(const wchar_t wch)
586{
587 return PDC_ungetch(wch);
588}
589#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..66940a3cf
--- /dev/null
+++ b/scripts/kconfig/libcurses/initscr.c
@@ -0,0 +1,431 @@
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
119WINDOW *initscr(void)
120{
121 int i;
122
123 PDC_LOG(("initscr() - called\n"));
124
125 if (SP && SP->alive)
126 return NULL;
127
128 SP = calloc(1, sizeof(SCREEN));
129 if (!SP)
130 return NULL;
131
132 if (PDC_scr_open() == ERR)
133 {
134 fprintf(stderr, "initscr(): Unable to create SP\n");
135 exit(8);
136 }
137
138 SP->autocr = TRUE; /* cr -> lf by default */
139 SP->raw_out = FALSE; /* tty I/O modes */
140 SP->raw_inp = FALSE; /* tty I/O modes */
141 SP->cbreak = TRUE;
142 SP->key_modifiers = 0L;
143 SP->return_key_modifiers = FALSE;
144 SP->echo = TRUE;
145 SP->visibility = 1;
146 SP->resized = FALSE;
147 SP->_trap_mbe = 0L;
148 SP->linesrippedoff = 0;
149 SP->linesrippedoffontop = 0;
150 SP->delaytenths = 0;
151 SP->line_color = -1;
152 SP->lastscr = (WINDOW *)NULL;
153 SP->dbfp = NULL;
154 SP->color_started = FALSE;
155 SP->dirty = FALSE;
156 SP->sel_start = -1;
157 SP->sel_end = -1;
158
159 SP->orig_cursor = PDC_get_cursor_mode();
160
161 LINES = SP->lines = PDC_get_rows();
162 COLS = SP->cols = PDC_get_columns();
163
164 if (LINES < 2 || COLS < 2)
165 {
166 fprintf(stderr, "initscr(): LINES=%d COLS=%d: too small.\n",
167 LINES, COLS);
168 exit(4);
169 }
170
171 curscr = newwin(LINES, COLS, 0, 0);
172 if (!curscr)
173 {
174 fprintf(stderr, "initscr(): Unable to create curscr.\n");
175 exit(2);
176 }
177
178 SP->lastscr = newwin(LINES, COLS, 0, 0);
179 if (!SP->lastscr)
180 {
181 fprintf(stderr, "initscr(): Unable to create SP->lastscr.\n");
182 exit(2);
183 }
184
185 wattrset(SP->lastscr, (chtype)(-1));
186 werase(SP->lastscr);
187
188 PDC_slk_initialize();
189 LINES -= SP->slklines;
190
191 /* We have to sort out ripped off lines here, and reduce the height
192 of stdscr by the number of lines ripped off */
193
194 for (i = 0; i < linesrippedoff; i++)
195 {
196 if (linesripped[i].line < 0)
197 (*linesripped[i].init)(newwin(1, COLS, LINES - 1, 0), COLS);
198 else
199 (*linesripped[i].init)(newwin(1, COLS,
200 SP->linesrippedoffontop++, 0), COLS);
201
202 SP->linesrippedoff++;
203 LINES--;
204 }
205
206 linesrippedoff = 0;
207
208 stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0);
209 if (!stdscr)
210 {
211 fprintf(stderr, "initscr(): Unable to create stdscr.\n");
212 exit(1);
213 }
214
215 wclrtobot(stdscr);
216
217 /* If preserving the existing screen, don't allow a screen clear */
218
219 if (SP->_preserve)
220 {
221 untouchwin(curscr);
222 untouchwin(stdscr);
223 stdscr->_clear = FALSE;
224 curscr->_clear = FALSE;
225 }
226 else
227 curscr->_clear = TRUE;
228
229 SP->atrtab = calloc(PDC_COLOR_PAIRS, sizeof(PDC_PAIR));
230 if (!SP->atrtab)
231 return NULL;
232 PDC_init_atrtab(); /* set up default colors */
233
234 MOUSE_X_POS = MOUSE_Y_POS = -1;
235 BUTTON_STATUS(1) = BUTTON_RELEASED;
236 BUTTON_STATUS(2) = BUTTON_RELEASED;
237 BUTTON_STATUS(3) = BUTTON_RELEASED;
238 Mouse_status.changes = 0;
239
240 SP->alive = TRUE;
241
242 def_shell_mode();
243
244 sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname());
245
246 SP->c_buffer = malloc(_INBUFSIZ * sizeof(int));
247 if (!SP->c_buffer)
248 return NULL;
249 SP->c_pindex = 0;
250 SP->c_gindex = 1;
251
252 SP->c_ungch = malloc(NUNGETCH * sizeof(int));
253 if (!SP->c_ungch)
254 return NULL;
255 SP->c_ungind = 0;
256 SP->c_ungmax = NUNGETCH;
257
258 return stdscr;
259}
260
261#ifdef XCURSES
262WINDOW *Xinitscr(int argc, char **argv)
263{
264 PDC_LOG(("Xinitscr() - called\n"));
265
266 PDC_set_args(argc, argv);
267 return initscr();
268}
269#endif
270
271int endwin(void)
272{
273 PDC_LOG(("endwin() - called\n"));
274
275 /* Allow temporary exit from curses using endwin() */
276
277 def_prog_mode();
278 PDC_scr_close();
279
280 SP->alive = FALSE;
281
282 return OK;
283}
284
285bool isendwin(void)
286{
287 PDC_LOG(("isendwin() - called\n"));
288
289 return SP ? !(SP->alive) : FALSE;
290}
291
292SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
293{
294 PDC_LOG(("newterm() - called\n"));
295
296 return initscr() ? SP : NULL;
297}
298
299SCREEN *set_term(SCREEN *new)
300{
301 PDC_LOG(("set_term() - called\n"));
302
303 /* We only support one screen */
304
305 return (new == SP) ? SP : NULL;
306}
307
308void delscreen(SCREEN *sp)
309{
310 PDC_LOG(("delscreen() - called\n"));
311
312 if (!SP || sp != SP)
313 return;
314
315 free(SP->c_ungch);
316 free(SP->c_buffer);
317 free(SP->atrtab);
318
319 PDC_slk_free(); /* free the soft label keys, if needed */
320
321 delwin(stdscr);
322 delwin(curscr);
323 delwin(SP->lastscr);
324 stdscr = (WINDOW *)NULL;
325 curscr = (WINDOW *)NULL;
326 SP->lastscr = (WINDOW *)NULL;
327
328 SP->alive = FALSE;
329
330 PDC_scr_free();
331
332 free(SP);
333 SP = (SCREEN *)NULL;
334}
335
336int resize_term(int nlines, int ncols)
337{
338 PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
339
340 if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
341 return ERR;
342
343 SP->resized = FALSE;
344
345 SP->lines = PDC_get_rows();
346 LINES = SP->lines - SP->linesrippedoff - SP->slklines;
347 SP->cols = COLS = PDC_get_columns();
348
349 if (SP->cursrow >= SP->lines)
350 SP->cursrow = SP->lines - 1;
351 if (SP->curscol >= SP->cols)
352 SP->curscol = SP->cols - 1;
353
354 if (wresize(curscr, SP->lines, SP->cols) == ERR ||
355 wresize(stdscr, LINES, COLS) == ERR ||
356 wresize(SP->lastscr, SP->lines, SP->cols) == ERR)
357 return ERR;
358
359 werase(SP->lastscr);
360 curscr->_clear = TRUE;
361
362 if (SP->slk_winptr)
363 {
364 if (wresize(SP->slk_winptr, SP->slklines, COLS) == ERR)
365 return ERR;
366
367 wmove(SP->slk_winptr, 0, 0);
368 wclrtobot(SP->slk_winptr);
369 PDC_slk_initialize();
370 slk_noutrefresh();
371 }
372
373 touchwin(stdscr);
374 wnoutrefresh(stdscr);
375
376 return OK;
377}
378
379bool is_termresized(void)
380{
381 PDC_LOG(("is_termresized() - called\n"));
382
383 return SP->resized;
384}
385
386const char *curses_version(void)
387{
388 return _curses_notice;
389}
390
391void PDC_get_version(PDC_VERSION *ver)
392{
393 if (!ver)
394 return;
395
396 ver->flags = 0
397#ifdef PDCDEBUG
398 | PDC_VFLAG_DEBUG
399#endif
400#ifdef PDC_WIDE
401 | PDC_VFLAG_WIDE
402#endif
403#ifdef PDC_FORCE_UTF8
404 | PDC_VFLAG_UTF8
405#endif
406#ifdef PDC_DLL_BUILD
407 | PDC_VFLAG_DLL
408#endif
409#ifdef PDC_RGB
410 | PDC_VFLAG_RGB
411#endif
412 ;
413
414 ver->build = PDC_BUILD;
415 ver->major = PDC_VER_MAJOR;
416 ver->minor = PDC_VER_MINOR;
417 ver->csize = sizeof(chtype);
418 ver->bsize = sizeof(bool);
419}
420
421int set_tabsize(int tabsize)
422{
423 PDC_LOG(("set_tabsize() - called: tabsize %d\n", tabsize));
424
425 if (tabsize < 1)
426 return ERR;
427
428 TABSIZE = tabsize;
429
430 return OK;
431}
diff --git a/scripts/kconfig/libcurses/inopts.c b/scripts/kconfig/libcurses/inopts.c
new file mode 100644
index 000000000..30e18f611
--- /dev/null
+++ b/scripts/kconfig/libcurses/inopts.c
@@ -0,0 +1,408 @@
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 wgetdelay(const WINDOW *win);
31 int typeahead(int fildes);
32
33 int crmode(void);
34 int nocrmode(void);
35
36 bool is_keypad(const WINDOW *win);
37 bool is_nodelay(const WINDOW *win);
38 bool is_notimeout(const WINDOW *win);
39
40### Description
41
42 cbreak() and nocbreak() toggle cbreak mode. In cbreak mode,
43 characters typed by the user are made available immediately, and
44 erase/kill character processing is not performed. In nocbreak mode,
45 typed characters are buffered until a newline or carriage return.
46 Interrupt and flow control characters are unaffected by this mode.
47 PDCurses always starts in cbreak mode.
48
49 echo() and noecho() control whether typed characters are echoed by
50 the input routine. Initially, input characters are echoed. Subsequent
51 calls to echo() and noecho() do not flush type-ahead.
52
53 halfdelay() is similar to cbreak(), but allows for a time limit to be
54 specified, in tenths of a second. This causes getch() to block for
55 that period before returning ERR if no key has been received. tenths
56 must be between 1 and 255.
57
58 keypad() controls whether getch() returns function/special keys as
59 single key codes (e.g., the left arrow key as KEY_LEFT). Per X/Open,
60 the default for keypad mode is OFF. You'll probably want it on. With
61 keypad mode off, if a special key is pressed, getch() does nothing or
62 returns ERR.
63
64 nodelay() controls whether wgetch() is a non-blocking call. If the
65 option is enabled, and no input is ready, wgetch() will return ERR.
66 If disabled, wgetch() will hang until input is ready.
67
68 nl() enables the translation of a carriage return into a newline on
69 input. nonl() disables this. Initially, the translation does occur.
70
71 raw() and noraw() toggle raw mode. Raw mode is similar to cbreak
72 mode, in that characters typed are immediately passed through to the
73 user program. The difference is that in raw mode, the INTR, QUIT,
74 SUSP, and STOP characters are passed through without being
75 interpreted, and without generating a signal.
76
77 In PDCurses, the meta() function sets raw mode on or off.
78
79 timeout() and wtimeout() set blocking or non-blocking reads for the
80 specified window. If the delay is negative, a blocking read is used;
81 if zero, then non-blocking reads are done -- if no input is waiting,
82 ERR is returned immediately. If the delay is positive, the read
83 blocks for the delay period; if the period expires, ERR is returned.
84 The delay is given in milliseconds, but this is rounded down to 50ms
85 (1/20th sec) intervals, with a minimum of one interval if a postive
86 delay is given; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms,
87 etc.
88
89 wgetdelay() returns the delay timeout as set in wtimeout().
90
91 intrflush(), notimeout(), noqiflush(), qiflush() and typeahead() do
92 nothing in PDCurses, but are included for compatibility with other
93 curses implementations.
94
95 crmode() and nocrmode() are archaic equivalents to cbreak() and
96 nocbreak(), respectively.
97
98 is_keypad() reports whether the specified window is in keypad mode.
99
100 is_nodelay() reports whether the specified window is in nodelay mode.
101
102### Return Value
103
104 is_keypad() and is_nodelay() return TRUE or FALSE. is_notimeout() is
105 provided for compatibility with other curses implementations, and
106 always returns FALSE. All others return OK on success and ERR on error.
107
108### Portability
109 X/Open ncurses NetBSD
110 cbreak Y Y Y
111 nocbreak Y Y Y
112 echo Y Y Y
113 noecho Y Y Y
114 halfdelay Y Y Y
115 intrflush Y Y Y
116 keypad Y Y Y
117 meta Y Y Y
118 nl Y Y Y
119 nonl Y Y Y
120 nodelay Y Y Y
121 notimeout Y Y Y
122 raw Y Y Y
123 noraw Y Y Y
124 noqiflush Y Y Y
125 qiflush Y Y Y
126 timeout Y Y Y
127 wtimeout Y Y Y
128 wgetdelay - Y -
129 typeahead Y Y Y
130 crmode Y Y Y
131 nocrmode Y Y Y
132 is_keypad - Y Y
133 is_nodelay - Y -
134 is_notimeout - Y -
135
136**man-end****************************************************************/
137
138int cbreak(void)
139{
140 PDC_LOG(("cbreak() - called\n"));
141
142 if (!SP)
143 return ERR;
144
145 SP->cbreak = TRUE;
146
147 return OK;
148}
149
150int nocbreak(void)
151{
152 PDC_LOG(("nocbreak() - called\n"));
153
154 if (!SP)
155 return ERR;
156
157 SP->cbreak = FALSE;
158 SP->delaytenths = 0;
159
160 return OK;
161}
162
163int echo(void)
164{
165 PDC_LOG(("echo() - called\n"));
166
167 if (!SP)
168 return ERR;
169
170 SP->echo = TRUE;
171
172 return OK;
173}
174
175int noecho(void)
176{
177 PDC_LOG(("noecho() - called\n"));
178
179 if (!SP)
180 return ERR;
181
182 SP->echo = FALSE;
183
184 return OK;
185}
186
187int halfdelay(int tenths)
188{
189 PDC_LOG(("halfdelay() - called\n"));
190
191 if (!SP || tenths < 1 || tenths > 255)
192 return ERR;
193
194 SP->delaytenths = tenths;
195
196 return OK;
197}
198
199int intrflush(WINDOW *win, bool bf)
200{
201 PDC_LOG(("intrflush() - called\n"));
202
203 return OK;
204}
205
206int keypad(WINDOW *win, bool bf)
207{
208 PDC_LOG(("keypad() - called\n"));
209
210 if (!win)
211 return ERR;
212
213 win->_use_keypad = bf;
214
215 return OK;
216}
217
218int meta(WINDOW *win, bool bf)
219{
220 PDC_LOG(("meta() - called\n"));
221
222 if (!SP)
223 return ERR;
224
225 SP->raw_inp = bf;
226
227 return OK;
228}
229
230int nl(void)
231{
232 PDC_LOG(("nl() - called\n"));
233
234 if (!SP)
235 return ERR;
236
237 SP->autocr = TRUE;
238
239 return OK;
240}
241
242int nonl(void)
243{
244 PDC_LOG(("nonl() - called\n"));
245
246 if (!SP)
247 return ERR;
248
249 SP->autocr = FALSE;
250
251 return OK;
252}
253
254int nodelay(WINDOW *win, bool flag)
255{
256 PDC_LOG(("nodelay() - called\n"));
257
258 if (!win)
259 return ERR;
260
261 win->_nodelay = flag;
262
263 return OK;
264}
265
266int notimeout(WINDOW *win, bool flag)
267{
268 PDC_LOG(("notimeout() - called\n"));
269
270 return OK;
271}
272
273int raw(void)
274{
275 PDC_LOG(("raw() - called\n"));
276
277 if (!SP)
278 return ERR;
279
280 PDC_set_keyboard_binary(TRUE);
281 SP->raw_inp = TRUE;
282
283 return OK;
284}
285
286int noraw(void)
287{
288 PDC_LOG(("noraw() - called\n"));
289
290 if (!SP)
291 return ERR;
292
293 PDC_set_keyboard_binary(FALSE);
294 SP->raw_inp = FALSE;
295
296 return OK;
297}
298
299void noqiflush(void)
300{
301 PDC_LOG(("noqiflush() - called\n"));
302}
303
304void qiflush(void)
305{
306 PDC_LOG(("qiflush() - called\n"));
307}
308
309void timeout(int delay)
310{
311 PDC_LOG(("timeout() - called\n"));
312
313 wtimeout(stdscr, delay);
314}
315
316void wtimeout(WINDOW *win, int delay)
317{
318 PDC_LOG(("wtimeout() - called\n"));
319
320 if (!win)
321 return;
322
323 if (delay < 0)
324 {
325 /* This causes a blocking read on the window, so turn on delay
326 mode */
327
328 win->_nodelay = FALSE;
329 win->_delayms = 0;
330 }
331 else if (!delay)
332 {
333 /* This causes a non-blocking read on the window, so turn off
334 delay mode */
335
336 win->_nodelay = TRUE;
337 win->_delayms = 0;
338 }
339 else
340 {
341 /* This causes the read on the window to delay for the number of
342 milliseconds. Also forces the window into non-blocking read
343 mode */
344
345 /*win->_nodelay = TRUE;*/
346 win->_delayms = delay;
347 }
348}
349
350int wgetdelay(const WINDOW *win)
351{
352 PDC_LOG(("wgetdelay() - called\n"));
353
354 if (!win)
355 return 0;
356
357 return win->_delayms;
358}
359
360int typeahead(int fildes)
361{
362 PDC_LOG(("typeahead() - called\n"));
363
364 return OK;
365}
366
367int crmode(void)
368{
369 PDC_LOG(("crmode() - called\n"));
370
371 return cbreak();
372}
373
374int nocrmode(void)
375{
376 PDC_LOG(("nocrmode() - called\n"));
377
378 return nocbreak();
379}
380
381bool is_keypad(const WINDOW *win)
382{
383 PDC_LOG(("is_keypad() - called\n"));
384
385 if (!win)
386 return FALSE;
387
388 return win->_use_keypad;
389}
390
391bool is_nodelay(const WINDOW *win)
392{
393 PDC_LOG(("is_nodelay() - called\n"));
394
395 if (!win)
396 return FALSE;
397
398 return win->_nodelay;
399}
400
401bool is_notimeout(const WINDOW *win)
402{
403 (void) win;
404
405 PDC_LOG(("is_notimeout() - called - returning FALSE...\n"));
406
407 return FALSE;
408}
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..e0a55e437
--- /dev/null
+++ b/scripts/kconfig/libcurses/outopts.c
@@ -0,0 +1,260 @@
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 wgetscrreg(const WINDOW *win, int *top, int *bot);
20 int scrollok(WINDOW *win, bool bf);
21
22 int raw_output(bool bf);
23
24 bool is_cleared(const WINDOW *win);
25 bool is_idlok(const WINDOW *win);
26 bool is_idcok(const WINDOW *win);
27 bool is_immedok(const WINDOW *win);
28 bool is_leaveok(const WINDOW *win);
29 bool is_scrollok(const WINDOW *win);
30
31### Description
32
33 With clearok(), if bf is TRUE, the next call to wrefresh() with this
34 window will clear the screen completely and redraw the entire screen.
35
36 immedok(), called with a second argument of TRUE, causes an automatic
37 wrefresh() every time a change is made to the specified window.
38
39 Normally, the hardware cursor is left at the location of the window
40 being refreshed. leaveok() allows the cursor to be left wherever the
41 update happens to leave it. It's useful for applications where the
42 cursor is not used, since it reduces the need for cursor motions. If
43 possible, the cursor is made invisible when this option is enabled.
44
45 wsetscrreg() sets a scrolling region in a window; "top" and "bot" are
46 the line numbers for the top and bottom margins. If this option and
47 scrollok() are enabled, any attempt to move off the bottom margin
48 will cause all lines in the scrolling region to scroll up one line.
49 setscrreg() is the stdscr version.
50
51 wgetscrreg() gets the top and bottom margins as set in wsetscrreg().
52
53 idlok() and idcok() do nothing in PDCurses, but are provided for
54 compatibility with other curses implementations, likewise is_idlok()
55 and is_idcok().
56
57 raw_output() enables the output of raw characters using the standard
58 *add* and *ins* curses functions (that is, it disables translation of
59 control characters).
60
61 is_cleared() reports whether the specified window causes clear at next
62 refresh.
63
64 is_immedok() reports whether the specified window is in immedok mode.
65
66 is_leaveok() reports whether the specified window is in leaveok mode.
67
68 is_scrollok() reports whether the specified window allows scrolling.
69
70### Return Value
71
72 is_cleared(), is_immedok(), is_leaveok() and is_scrollok() return TRUE
73 or FALSE. is_idlok() and is_idcok() are provided for compatibility with
74 other curses implementations, and always return FALSE. All others
75 return OK on success and ERR on error.
76
77### Portability
78 X/Open ncurses NetBSD
79 clearok Y Y Y
80 idlok Y Y Y
81 idcok Y Y Y
82 immedok Y Y Y
83 leaveok Y Y Y
84 setscrreg Y Y Y
85 wsetscrreg Y Y Y
86 wgetscrreg - Y -
87 scrollok Y Y Y
88 is_cleared - Y -
89 is_idlok - Y -
90 is_idcok - Y -
91 is_immedok - Y -
92 is_leaveok - Y Y
93 is_scrollok - Y -
94 raw_output - - -
95
96**man-end****************************************************************/
97
98int clearok(WINDOW *win, bool bf)
99{
100 PDC_LOG(("clearok() - called\n"));
101
102 if (!win)
103 return ERR;
104
105 win->_clear = bf;
106
107 return OK;
108}
109
110int idlok(WINDOW *win, bool bf)
111{
112 PDC_LOG(("idlok() - called\n"));
113
114 return OK;
115}
116
117void idcok(WINDOW *win, bool bf)
118{
119 PDC_LOG(("idcok() - called\n"));
120}
121
122void immedok(WINDOW *win, bool bf)
123{
124 PDC_LOG(("immedok() - called\n"));
125
126 if (win)
127 win->_immed = bf;
128}
129
130int leaveok(WINDOW *win, bool bf)
131{
132 PDC_LOG(("leaveok() - called\n"));
133
134 if (!win)
135 return ERR;
136
137 win->_leaveit = bf;
138
139 curs_set(!bf);
140
141 return OK;
142}
143
144int setscrreg(int top, int bottom)
145{
146 PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
147
148 return wsetscrreg(stdscr, top, bottom);
149}
150
151int wsetscrreg(WINDOW *win, int top, int bottom)
152{
153 PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
154
155 if (win && 0 <= top && top <= win->_cury &&
156 win->_cury <= bottom && bottom < win->_maxy)
157 {
158 win->_tmarg = top;
159 win->_bmarg = bottom;
160
161 return OK;
162 }
163 else
164 return ERR;
165}
166
167int wgetscrreg(const WINDOW *win, int *top, int *bot)
168{
169 PDC_LOG(("wgetscrreg() - called\n"));
170
171 if (!win || !top || !bot)
172 return ERR;
173
174 *top = win->_tmarg;
175 *bot = win->_bmarg;
176
177 return OK;
178}
179
180int scrollok(WINDOW *win, bool bf)
181{
182 PDC_LOG(("scrollok() - called\n"));
183
184 if (!win)
185 return ERR;
186
187 win->_scroll = bf;
188
189 return OK;
190}
191
192int raw_output(bool bf)
193{
194 PDC_LOG(("raw_output() - called\n"));
195
196 if (!SP)
197 return ERR;
198
199 SP->raw_out = bf;
200
201 return OK;
202}
203
204bool is_cleared(const WINDOW *win)
205{
206 PDC_LOG(("is_cleared() - called\n"));
207
208 if (!win)
209 return FALSE;
210
211 return win->_clear;
212}
213
214bool is_idlok(const WINDOW *win)
215{
216 (void) win;
217
218 PDC_LOG(("is_idlok() - called\n"));
219
220 return FALSE;
221}
222
223bool is_idcok(const WINDOW *win)
224{
225 (void) win;
226
227 PDC_LOG(("is_idcok() - called\n"));
228
229 return FALSE;
230}
231
232bool is_immedok(const WINDOW *win)
233{
234 PDC_LOG(("is_immedok() - called\n"));
235
236 if (!win)
237 return FALSE;
238
239 return win->_immed;
240}
241
242bool is_leaveok(const WINDOW *win)
243{
244 PDC_LOG(("is_leaveok() - called\n"));
245
246 if (!win)
247 return FALSE;
248
249 return win->_leaveit;
250}
251
252bool is_scrollok(const WINDOW *win)
253{
254 PDC_LOG(("is_scrollok() - called\n"));
255
256 if (!win)
257 return FALSE;
258
259 return win->_scroll;
260}
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..3dfdfe5d6
--- /dev/null
+++ b/scripts/kconfig/libcurses/pad.c
@@ -0,0 +1,274 @@
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
78WINDOW *newpad(int nlines, int ncols)
79{
80 WINDOW *win;
81
82 PDC_LOG(("newpad() - called: lines=%d cols=%d\n", nlines, ncols));
83
84 win = PDC_makenew(nlines, ncols, 0, 0);
85 if (win)
86 win = PDC_makelines(win);
87
88 if (!win)
89 return (WINDOW *)NULL;
90
91 werase(win);
92
93 win->_flags = _PAD;
94 win->_pad._pad_y = 0;
95 win->_pad._pad_x = 0;
96 win->_pad._pad_top = 0;
97 win->_pad._pad_left = 0;
98 win->_pad._pad_bottom = min(LINES, nlines) - 1;
99 win->_pad._pad_right = min(COLS, ncols) - 1;
100
101 return win;
102}
103
104WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
105{
106 WINDOW *win;
107 int i;
108
109 PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n",
110 nlines, ncols, begy, begx));
111
112 if (!orig || !(orig->_flags & _PAD))
113 return (WINDOW *)NULL;
114
115 /* make sure window fits inside the original one */
116
117 if (begy < 0 || begx < 0 ||
118 (begy + nlines) > orig->_maxy ||
119 (begx + ncols) > orig->_maxx)
120 return (WINDOW *)NULL;
121
122 if (!nlines)
123 nlines = orig->_maxy - begy;
124
125 if (!ncols)
126 ncols = orig->_maxx - begx;
127
128 win = PDC_makenew(nlines, ncols, begy, begx);
129 if (!win)
130 return (WINDOW *)NULL;
131
132 /* initialize window variables */
133
134 win->_attrs = orig->_attrs;
135 win->_leaveit = orig->_leaveit;
136 win->_scroll = orig->_scroll;
137 win->_nodelay = orig->_nodelay;
138 win->_use_keypad = orig->_use_keypad;
139 win->_parent = orig;
140
141 for (i = 0; i < nlines; i++)
142 win->_y[i] = orig->_y[begy + i] + begx;
143
144 win->_flags = _SUBPAD;
145 win->_pad._pad_y = 0;
146 win->_pad._pad_x = 0;
147 win->_pad._pad_top = 0;
148 win->_pad._pad_left = 0;
149 win->_pad._pad_bottom = min(LINES, nlines) - 1;
150 win->_pad._pad_right = min(COLS, ncols) - 1;
151
152 return win;
153}
154
155int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2)
156{
157 PDC_LOG(("prefresh() - called\n"));
158
159 if (pnoutrefresh(win, py, px, sy1, sx1, sy2, sx2) == ERR)
160 return ERR;
161
162 doupdate();
163 return OK;
164}
165
166int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
167{
168 int num_cols;
169 int sline;
170 int pline;
171
172 PDC_LOG(("pnoutrefresh() - called\n"));
173
174 if (py < 0)
175 py = 0;
176 if (px < 0)
177 px = 0;
178 if (sy1 < 0)
179 sy1 = 0;
180 if (sx1 < 0)
181 sx1 = 0;
182
183 if ((!w || !(w->_flags & (_PAD|_SUBPAD)) ||
184 (sy2 >= LINES) || (sx2 >= COLS)) ||
185 (sy2 < sy1) || (sx2 < sx1))
186 return ERR;
187
188 sline = sy1;
189 pline = py;
190
191 num_cols = min((sx2 - sx1 + 1), (w->_maxx - px));
192
193 while (sline <= sy2)
194 {
195 if (pline < w->_maxy)
196 {
197 memcpy(curscr->_y[sline] + sx1, w->_y[pline] + px,
198 num_cols * sizeof(chtype));
199
200 if ((curscr->_firstch[sline] == _NO_CHANGE)
201 || (curscr->_firstch[sline] > sx1))
202 curscr->_firstch[sline] = sx1;
203
204 if (sx2 > curscr->_lastch[sline])
205 curscr->_lastch[sline] = sx2;
206
207 w->_firstch[pline] = _NO_CHANGE; /* updated now */
208 w->_lastch[pline] = _NO_CHANGE; /* updated now */
209 }
210
211 sline++;
212 pline++;
213 }
214
215 if (w->_clear)
216 {
217 w->_clear = FALSE;
218 curscr->_clear = TRUE;
219 }
220
221 /* position the cursor to the pad's current position if possible --
222 is the pad current position going to end up displayed? if not,
223 then don't move the cursor; if so, move it to the correct place */
224
225 if (!w->_leaveit && w->_cury >= py && w->_curx >= px &&
226 w->_cury <= py + (sy2 - sy1) && w->_curx <= px + (sx2 - sx1))
227 {
228 curscr->_cury = (w->_cury - py) + sy1;
229 curscr->_curx = (w->_curx - px) + sx1;
230 }
231
232 w->_pad._pad_y = py;
233 w->_pad._pad_x = px;
234 w->_pad._pad_top = sy1;
235 w->_pad._pad_left = sx1;
236 w->_pad._pad_bottom = sy2;
237 w->_pad._pad_right = sx2;
238
239 return OK;
240}
241
242int pechochar(WINDOW *pad, chtype ch)
243{
244 PDC_LOG(("pechochar() - called\n"));
245
246 if (waddch(pad, ch) == ERR)
247 return ERR;
248
249 return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top,
250 pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right);
251}
252
253#ifdef PDC_WIDE
254int pecho_wchar(WINDOW *pad, const cchar_t *wch)
255{
256 PDC_LOG(("pecho_wchar() - called\n"));
257
258 if (!wch || (waddch(pad, *wch) == ERR))
259 return ERR;
260
261 return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top,
262 pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right);
263}
264#endif
265
266bool is_pad(const WINDOW *pad)
267{
268 PDC_LOG(("is_pad() - called\n"));
269
270 if (!pad)
271 return FALSE;
272
273 return (pad->_flags & _PAD) ? TRUE : FALSE;
274}
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..f6115ecb0
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcdisp.c
@@ -0,0 +1,329 @@
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 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 {
185 ch = acs_map[ch & 0x7f];
186
187 if (pdc_wt && (ch & A_CHARTEXT) < ' ')
188 goto NONANSI;
189 }
190
191 if (blink && blinked_off)
192 ch = ' ';
193
194 buffer[j] = ch & A_CHARTEXT;
195 }
196
197 PDC_gotoyx(lineno, x);
198 _set_ansi_color(fore, back, attr);
199#ifdef PDC_WIDE
200 WriteConsoleW(pdc_con_out, buffer, len, NULL, NULL);
201#else
202 WriteConsoleA(pdc_con_out, buffer, len, NULL, NULL);
203#endif
204 }
205 else
206NONANSI:
207 {
208 CHAR_INFO buffer[512];
209 COORD bufSize, bufPos;
210 SMALL_RECT sr;
211 WORD mapped_attr;
212
213 fore = pdc_curstoreal[fore];
214 back = pdc_curstoreal[back];
215
216 if (attr & A_REVERSE)
217 mapped_attr = back | (fore << 4);
218 else
219 mapped_attr = fore | (back << 4);
220
221 if (attr & A_UNDERLINE)
222 mapped_attr |= 0x8000; /* COMMON_LVB_UNDERSCORE */
223 if (attr & A_LEFT)
224 mapped_attr |= 0x0800; /* COMMON_LVB_GRID_LVERTICAL */
225 if (attr & A_RIGHT)
226 mapped_attr |= 0x1000; /* COMMON_LVB_GRID_RVERTICAL */
227
228 for (j = 0; j < len; j++)
229 {
230 chtype ch = srcp[j];
231
232 if (ch & A_ALTCHARSET && !(ch & 0xff80))
233 ch = acs_map[ch & 0x7f];
234
235 if (blink && blinked_off)
236 ch = ' ';
237
238 buffer[j].Attributes = mapped_attr;
239 buffer[j].Char.UnicodeChar = ch & A_CHARTEXT;
240 }
241
242 bufPos.X = bufPos.Y = 0;
243 bufSize.X = len;
244 bufSize.Y = 1;
245
246 sr.Top = sr.Bottom = lineno;
247 sr.Left = x;
248 sr.Right = x + len - 1;
249
250 WriteConsoleOutput(pdc_con_out, buffer, bufSize, bufPos, &sr);
251 }
252}
253
254/* update the given physical line to look like the corresponding line in
255 curscr */
256
257void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
258{
259 attr_t old_attr, attr;
260 int i, j;
261
262 PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
263
264 old_attr = *srcp & (A_ATTRIBUTES ^ A_ALTCHARSET);
265
266 for (i = 1, j = 1; j < len; i++, j++)
267 {
268 attr = srcp[i] & (A_ATTRIBUTES ^ A_ALTCHARSET);
269
270 if (attr != old_attr)
271 {
272 _new_packet(old_attr, lineno, x, i, srcp);
273 old_attr = attr;
274 srcp += i;
275 x += i;
276 i = 0;
277 }
278 }
279
280 _new_packet(old_attr, lineno, x, i, srcp);
281}
282
283void PDC_blink_text(void)
284{
285 CONSOLE_CURSOR_INFO cci;
286 int i, j, k;
287 bool oldvis;
288
289 GetConsoleCursorInfo(pdc_con_out, &cci);
290 oldvis = cci.bVisible;
291 if (oldvis)
292 {
293 cci.bVisible = FALSE;
294 SetConsoleCursorInfo(pdc_con_out, &cci);
295 }
296
297 if (!(SP->termattrs & A_BLINK))
298 blinked_off = FALSE;
299 else
300 blinked_off = !blinked_off;
301
302 for (i = 0; i < SP->lines; i++)
303 {
304 const chtype *srcp = curscr->_y[i];
305
306 for (j = 0; j < SP->cols; j++)
307 if (srcp[j] & A_BLINK)
308 {
309 k = j;
310 while (k < SP->cols && (srcp[k] & A_BLINK))
311 k++;
312 PDC_transform_line(i, j, k - j, srcp + j);
313 j = k;
314 }
315 }
316
317 PDC_gotoyx(SP->cursrow, SP->curscol);
318 if (oldvis)
319 {
320 cci.bVisible = TRUE;
321 SetConsoleCursorInfo(pdc_con_out, &cci);
322 }
323
324 pdc_last_blink = GetTickCount();
325}
326
327void PDC_doupdate(void)
328{
329}
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..cbab60d63
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdckbd.c
@@ -0,0 +1,693 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5/* These variables are used to store information about the next
6 Input Event. */
7
8static INPUT_RECORD save_ip;
9static MOUSE_STATUS old_mouse_status;
10static DWORD event_count = 0;
11static SHORT left_key;
12static int key_count = 0;
13static int save_press = 0;
14
15#define KEV save_ip.Event.KeyEvent
16#define MEV save_ip.Event.MouseEvent
17#define REV save_ip.Event.WindowBufferSizeEvent
18
19/************************************************************************
20 * Table for key code translation of function keys in keypad mode *
21 * These values are for strict IBM keyboard compatibles only *
22 ************************************************************************/
23
24typedef struct
25{
26 unsigned short normal;
27 unsigned short shift;
28 unsigned short control;
29 unsigned short alt;
30 unsigned short extended;
31} KPTAB;
32
33static KPTAB kptab[] =
34{
35 {0, 0, 0, 0, 0 }, /* 0 */
36 {0, 0, 0, 0, 0 }, /* 1 VK_LBUTTON */
37 {0, 0, 0, 0, 0 }, /* 2 VK_RBUTTON */
38 {0, 0, 0, 0, 0 }, /* 3 VK_CANCEL */
39 {0, 0, 0, 0, 0 }, /* 4 VK_MBUTTON */
40 {0, 0, 0, 0, 0 }, /* 5 */
41 {0, 0, 0, 0, 0 }, /* 6 */
42 {0, 0, 0, 0, 0 }, /* 7 */
43 {0x08, 0x08, 0x7F, ALT_BKSP, 0 }, /* 8 VK_BACK */
44 {0x09, KEY_BTAB, CTL_TAB, ALT_TAB, 999 }, /* 9 VK_TAB */
45 {0, 0, 0, 0, 0 }, /* 10 */
46 {0, 0, 0, 0, 0 }, /* 11 */
47 {KEY_B2, 0x35, CTL_PAD5, ALT_PAD5, 0 }, /* 12 VK_CLEAR */
48 {0x0D, 0x0D, CTL_ENTER, ALT_ENTER, 1 }, /* 13 VK_RETURN */
49 {0, 0, 0, 0, 0 }, /* 14 */
50 {0, 0, 0, 0, 0 }, /* 15 */
51 {0, 0, 0, 0, 0 }, /* 16 VK_SHIFT HANDLED SEPARATELY */
52 {0, 0, 0, 0, 0 }, /* 17 VK_CONTROL HANDLED SEPARATELY */
53 {0, 0, 0, 0, 0 }, /* 18 VK_MENU HANDLED SEPARATELY */
54 {0, 0, 0, 0, 0 }, /* 19 VK_PAUSE */
55 {0, 0, 0, 0, 0 }, /* 20 VK_CAPITAL HANDLED SEPARATELY */
56 {0, 0, 0, 0, 0 }, /* 21 VK_HANGUL */
57 {0, 0, 0, 0, 0 }, /* 22 */
58 {0, 0, 0, 0, 0 }, /* 23 VK_JUNJA */
59 {0, 0, 0, 0, 0 }, /* 24 VK_FINAL */
60 {0, 0, 0, 0, 0 }, /* 25 VK_HANJA */
61 {0, 0, 0, 0, 0 }, /* 26 */
62 {0x1B, 0x1B, 0x1B, ALT_ESC, 0 }, /* 27 VK_ESCAPE */
63 {0, 0, 0, 0, 0 }, /* 28 VK_CONVERT */
64 {0, 0, 0, 0, 0 }, /* 29 VK_NONCONVERT */
65 {0, 0, 0, 0, 0 }, /* 30 VK_ACCEPT */
66 {0, 0, 0, 0, 0 }, /* 31 VK_MODECHANGE */
67 {0x20, 0x20, 0x20, 0x20, 0 }, /* 32 VK_SPACE */
68 {KEY_A3, 0x39, CTL_PAD9, ALT_PAD9, 3 }, /* 33 VK_PRIOR */
69 {KEY_C3, 0x33, CTL_PAD3, ALT_PAD3, 4 }, /* 34 VK_NEXT */
70 {KEY_C1, 0x31, CTL_PAD1, ALT_PAD1, 5 }, /* 35 VK_END */
71 {KEY_A1, 0x37, CTL_PAD7, ALT_PAD7, 6 }, /* 36 VK_HOME */
72 {KEY_B1, 0x34, CTL_PAD4, ALT_PAD4, 7 }, /* 37 VK_LEFT */
73 {KEY_A2, 0x38, CTL_PAD8, ALT_PAD8, 8 }, /* 38 VK_UP */
74 {KEY_B3, 0x36, CTL_PAD6, ALT_PAD6, 9 }, /* 39 VK_RIGHT */
75 {KEY_C2, 0x32, CTL_PAD2, ALT_PAD2, 10 }, /* 40 VK_DOWN */
76 {0, 0, 0, 0, 0 }, /* 41 VK_SELECT */
77 {0, 0, 0, 0, 0 }, /* 42 VK_PRINT */
78 {0, 0, 0, 0, 0 }, /* 43 VK_EXECUTE */
79 {0, 0, 0, 0, 0 }, /* 44 VK_SNAPSHOT*/
80 {PAD0, 0x30, CTL_PAD0, ALT_PAD0, 11 }, /* 45 VK_INSERT */
81 {PADSTOP, 0x2E, CTL_PADSTOP, ALT_PADSTOP,12 }, /* 46 VK_DELETE */
82 {0, 0, 0, 0, 0 }, /* 47 VK_HELP */
83 {0x30, 0x29, 0, ALT_0, 0 }, /* 48 */
84 {0x31, 0x21, 0, ALT_1, 0 }, /* 49 */
85 {0x32, 0x40, 0, ALT_2, 0 }, /* 50 */
86 {0x33, 0x23, 0, ALT_3, 0 }, /* 51 */
87 {0x34, 0x24, 0, ALT_4, 0 }, /* 52 */
88 {0x35, 0x25, 0, ALT_5, 0 }, /* 53 */
89 {0x36, 0x5E, 0, ALT_6, 0 }, /* 54 */
90 {0x37, 0x26, 0, ALT_7, 0 }, /* 55 */
91 {0x38, 0x2A, 0, ALT_8, 0 }, /* 56 */
92 {0x39, 0x28, 0, ALT_9, 0 }, /* 57 */
93 {0, 0, 0, 0, 0 }, /* 58 */
94 {0, 0, 0, 0, 0 }, /* 59 */
95 {0, 0, 0, 0, 0 }, /* 60 */
96 {0, 0, 0, 0, 0 }, /* 61 */
97 {0, 0, 0, 0, 0 }, /* 62 */
98 {0, 0, 0, 0, 0 }, /* 63 */
99 {0, 0, 0, 0, 0 }, /* 64 */
100 {0x61, 0x41, 0x01, ALT_A, 0 }, /* 65 */
101 {0x62, 0x42, 0x02, ALT_B, 0 }, /* 66 */
102 {0x63, 0x43, 0x03, ALT_C, 0 }, /* 67 */
103 {0x64, 0x44, 0x04, ALT_D, 0 }, /* 68 */
104 {0x65, 0x45, 0x05, ALT_E, 0 }, /* 69 */
105 {0x66, 0x46, 0x06, ALT_F, 0 }, /* 70 */
106 {0x67, 0x47, 0x07, ALT_G, 0 }, /* 71 */
107 {0x68, 0x48, 0x08, ALT_H, 0 }, /* 72 */
108 {0x69, 0x49, 0x09, ALT_I, 0 }, /* 73 */
109 {0x6A, 0x4A, 0x0A, ALT_J, 0 }, /* 74 */
110 {0x6B, 0x4B, 0x0B, ALT_K, 0 }, /* 75 */
111 {0x6C, 0x4C, 0x0C, ALT_L, 0 }, /* 76 */
112 {0x6D, 0x4D, 0x0D, ALT_M, 0 }, /* 77 */
113 {0x6E, 0x4E, 0x0E, ALT_N, 0 }, /* 78 */
114 {0x6F, 0x4F, 0x0F, ALT_O, 0 }, /* 79 */
115 {0x70, 0x50, 0x10, ALT_P, 0 }, /* 80 */
116 {0x71, 0x51, 0x11, ALT_Q, 0 }, /* 81 */
117 {0x72, 0x52, 0x12, ALT_R, 0 }, /* 82 */
118 {0x73, 0x53, 0x13, ALT_S, 0 }, /* 83 */
119 {0x74, 0x54, 0x14, ALT_T, 0 }, /* 84 */
120 {0x75, 0x55, 0x15, ALT_U, 0 }, /* 85 */
121 {0x76, 0x56, 0x16, ALT_V, 0 }, /* 86 */
122 {0x77, 0x57, 0x17, ALT_W, 0 }, /* 87 */
123 {0x78, 0x58, 0x18, ALT_X, 0 }, /* 88 */
124 {0x79, 0x59, 0x19, ALT_Y, 0 }, /* 89 */
125 {0x7A, 0x5A, 0x1A, ALT_Z, 0 }, /* 90 */
126 {0, 0, 0, 0, 0 }, /* 91 VK_LWIN */
127 {0, 0, 0, 0, 0 }, /* 92 VK_RWIN */
128 {0, 0, 0, 0, 0 }, /* 93 VK_APPS */
129 {0, 0, 0, 0, 0 }, /* 94 */
130 {0, 0, 0, 0, 0 }, /* 95 */
131 {0x30, 0, CTL_PAD0, ALT_PAD0, 0 }, /* 96 VK_NUMPAD0 */
132 {0x31, 0, CTL_PAD1, ALT_PAD1, 0 }, /* 97 VK_NUMPAD1 */
133 {0x32, 0, CTL_PAD2, ALT_PAD2, 0 }, /* 98 VK_NUMPAD2 */
134 {0x33, 0, CTL_PAD3, ALT_PAD3, 0 }, /* 99 VK_NUMPAD3 */
135 {0x34, 0, CTL_PAD4, ALT_PAD4, 0 }, /* 100 VK_NUMPAD4 */
136 {0x35, 0, CTL_PAD5, ALT_PAD5, 0 }, /* 101 VK_NUMPAD5 */
137 {0x36, 0, CTL_PAD6, ALT_PAD6, 0 }, /* 102 VK_NUMPAD6 */
138 {0x37, 0, CTL_PAD7, ALT_PAD7, 0 }, /* 103 VK_NUMPAD7 */
139 {0x38, 0, CTL_PAD8, ALT_PAD8, 0 }, /* 104 VK_NUMPAD8 */
140 {0x39, 0, CTL_PAD9, ALT_PAD9, 0 }, /* 105 VK_NUMPAD9 */
141 {PADSTAR, SHF_PADSTAR,CTL_PADSTAR, ALT_PADSTAR,999 }, /* 106 VK_MULTIPLY*/
142 {PADPLUS, SHF_PADPLUS,CTL_PADPLUS, ALT_PADPLUS,999 }, /* 107 VK_ADD */
143 {0, 0, 0, 0, 0 }, /* 108 VK_SEPARATOR */
144 {PADMINUS, SHF_PADMINUS,CTL_PADMINUS,ALT_PADMINUS,999}, /* 109 VK_SUBTRACT*/
145 {0x2E, 0, CTL_PADSTOP, ALT_PADSTOP,0 }, /* 110 VK_DECIMAL */
146 {PADSLASH, SHF_PADSLASH,CTL_PADSLASH,ALT_PADSLASH,2 }, /* 111 VK_DIVIDE */
147 {KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37), 0 }, /* 112 VK_F1 */
148 {KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38), 0 }, /* 113 VK_F2 */
149 {KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39), 0 }, /* 114 VK_F3 */
150 {KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40), 0 }, /* 115 VK_F4 */
151 {KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41), 0 }, /* 116 VK_F5 */
152 {KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42), 0 }, /* 117 VK_F6 */
153 {KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43), 0 }, /* 118 VK_F7 */
154 {KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44), 0 }, /* 119 VK_F8 */
155 {KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45), 0 }, /* 120 VK_F9 */
156 {KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46), 0 }, /* 121 VK_F10 */
157 {KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47), 0 }, /* 122 VK_F11 */
158 {KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48), 0 }, /* 123 VK_F12 */
159
160 /* 124 through 218 */
161
162 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
163 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
164 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
165 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
166 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
167 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
168 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
169 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
170 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
171 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
172 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
173 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
174 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
175 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
176 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
177 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
178 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
179 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
180 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
181 {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
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},
186
187 {0x5B, 0x7B, 0x1B, ALT_LBRACKET,0 }, /* 219 */
188 {0x5C, 0x7C, 0x1C, ALT_BSLASH, 0 }, /* 220 */
189 {0x5D, 0x7D, 0x1D, ALT_RBRACKET,0 }, /* 221 */
190 {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */
191 {0, 0, 0, 0, 0 }, /* 223 */
192 {0, 0, 0, 0, 0 }, /* 224 */
193 {0, 0, 0, 0, 0 }, /* 225 */
194 {0, 0, 0, 0, 0 }, /* 226 */
195 {0, 0, 0, 0, 0 }, /* 227 */
196 {0, 0, 0, 0, 0 }, /* 228 */
197 {0, 0, 0, 0, 0 }, /* 229 */
198 {0, 0, 0, 0, 0 }, /* 230 */
199 {0, 0, 0, 0, 0 }, /* 231 */
200 {0, 0, 0, 0, 0 }, /* 232 */
201 {0, 0, 0, 0, 0 }, /* 233 */
202 {0, 0, 0, 0, 0 }, /* 234 */
203 {0, 0, 0, 0, 0 }, /* 235 */
204 {0, 0, 0, 0, 0 }, /* 236 */
205 {0, 0, 0, 0, 0 }, /* 237 */
206 {0, 0, 0, 0, 0 }, /* 238 */
207 {0, 0, 0, 0, 0 }, /* 239 */
208 {0, 0, 0, 0, 0 }, /* 240 */
209 {0, 0, 0, 0, 0 }, /* 241 */
210 {0, 0, 0, 0, 0 }, /* 242 */
211 {0, 0, 0, 0, 0 }, /* 243 */
212 {0, 0, 0, 0, 0 }, /* 244 */
213 {0, 0, 0, 0, 0 }, /* 245 */
214 {0, 0, 0, 0, 0 }, /* 246 */
215 {0, 0, 0, 0, 0 }, /* 247 */
216 {0, 0, 0, 0, 0 }, /* 248 */
217 {0, 0, 0, 0, 0 }, /* 249 */
218 {0, 0, 0, 0, 0 }, /* 250 */
219 {0, 0, 0, 0, 0 }, /* 251 */
220 {0, 0, 0, 0, 0 }, /* 252 */
221 {0, 0, 0, 0, 0 }, /* 253 */
222 {0, 0, 0, 0, 0 }, /* 254 */
223 {0, 0, 0, 0, 0 } /* 255 */
224};
225
226static KPTAB ext_kptab[] =
227{
228 {0, 0, 0, 0, }, /* MUST BE EMPTY */
229 {PADENTER, SHF_PADENTER, CTL_PADENTER, ALT_PADENTER}, /* 13 */
230 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 111 */
231 {KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP }, /* 33 */
232 {KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN }, /* 34 */
233 {KEY_END, KEY_SEND, CTL_END, ALT_END }, /* 35 */
234 {KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME }, /* 36 */
235 {KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT }, /* 37 */
236 {KEY_UP, KEY_SUP, CTL_UP, ALT_UP }, /* 38 */
237 {KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT }, /* 39 */
238 {KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN }, /* 40 */
239 {KEY_IC, KEY_SIC, CTL_INS, ALT_INS }, /* 45 */
240 {KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL }, /* 46 */
241 {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 191 */
242};
243
244/* End of kptab[] */
245
246void PDC_set_keyboard_binary(bool on)
247{
248 DWORD mode;
249
250 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
251
252 GetConsoleMode(pdc_con_in, &mode);
253 SetConsoleMode(pdc_con_in, !on ? (mode | ENABLE_PROCESSED_INPUT) :
254 (mode & ~ENABLE_PROCESSED_INPUT));
255}
256
257/* check if a key or mouse event is waiting */
258
259bool PDC_check_key(void)
260{
261 if (key_count > 0)
262 return TRUE;
263
264 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
265
266 return (event_count != 0);
267}
268
269/* _get_key_count returns 0 if save_ip doesn't contain an event which
270 should be passed back to the user. This function filters "useless"
271 events.
272
273 The function returns the number of keys waiting. This may be > 1
274 if the repetition of real keys pressed so far are > 1.
275
276 Returns 0 on NUMLOCK, CAPSLOCK, SCROLLLOCK.
277
278 Returns 1 for SHIFT, ALT, CTRL only if no other key has been pressed
279 in between, and SP->return_key_modifiers is set; these are returned
280 on keyup.
281
282 Normal keys are returned on keydown only. The number of repetitions
283 are returned. Dead keys (diacritics) are omitted. See below for a
284 description.
285*/
286
287static int _get_key_count(void)
288{
289 int num_keys = 0, vk;
290
291 PDC_LOG(("_get_key_count() - called\n"));
292
293 vk = KEV.wVirtualKeyCode;
294
295 if (KEV.bKeyDown)
296 {
297 /* key down */
298
299 save_press = 0;
300
301 if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
302 {
303 /* throw away these modifiers */
304 }
305 else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
306 {
307 /* These keys are returned on keyup only. */
308
309 save_press = vk;
310 switch (vk)
311 {
312 case VK_SHIFT:
313 left_key = GetKeyState(VK_LSHIFT);
314 break;
315 case VK_CONTROL:
316 left_key = GetKeyState(VK_LCONTROL);
317 break;
318 case VK_MENU:
319 left_key = GetKeyState(VK_LMENU);
320 }
321 }
322 else
323 {
324 /* Check for diacritics. These are dead keys. Some locales
325 have modified characters like umlaut-a, which is an "a"
326 with two dots on it. In some locales you have to press a
327 special key (the dead key) immediately followed by the
328 "a" to get a composed umlaut-a. The special key may have
329 a normal meaning with different modifiers. */
330
331 if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
332 num_keys = KEV.wRepeatCount;
333 }
334 }
335 else
336 {
337 /* key up */
338
339 /* Only modifier keys or the results of ALT-numpad entry are
340 returned on keyup */
341
342 if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
343 ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
344 vk == save_press))
345 {
346 save_press = 0;
347 num_keys = 1;
348 }
349 }
350
351 PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));
352
353 return num_keys;
354}
355
356/* _process_key_event returns -1 if the key in save_ip should be
357 ignored. Otherwise it returns the keycode which should be returned
358 by PDC_get_key(). save_ip must be a key event.
359
360 CTRL-ALT support has been disabled, when is it emitted plainly? */
361
362static int _process_key_event(void)
363{
364 int key =
365#ifdef PDC_WIDE
366 KEV.uChar.UnicodeChar;
367#else
368 KEV.uChar.AsciiChar;
369#endif
370 WORD vk = KEV.wVirtualKeyCode;
371 DWORD state = KEV.dwControlKeyState;
372
373 int idx;
374 BOOL enhanced;
375
376 SP->key_code = TRUE;
377
378 /* Save the key modifiers. Do this first to allow to detect e.g. a
379 pressed CTRL key after a hit of NUMLOCK. */
380
381 if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
382 SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
383
384 if (state & SHIFT_PRESSED)
385 SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
386
387 if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
388 SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
389
390 if (state & NUMLOCK_ON)
391 SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
392
393 /* Handle modifier keys hit by themselves */
394
395 switch (vk)
396 {
397 case VK_SHIFT: /* shift */
398 if (!SP->return_key_modifiers)
399 return -1;
400
401 return (left_key & 0x8000) ? KEY_SHIFT_L : KEY_SHIFT_R;
402
403 case VK_CONTROL: /* control */
404 if (!SP->return_key_modifiers)
405 return -1;
406
407 return (left_key & 0x8000) ? KEY_CONTROL_L : KEY_CONTROL_R;
408
409 case VK_MENU: /* alt */
410 if (!key)
411 {
412 if (!SP->return_key_modifiers)
413 return -1;
414
415 return (left_key & 0x8000) ? KEY_ALT_L : KEY_ALT_R;
416 }
417 }
418
419 /* The system may emit Ascii or Unicode characters depending on
420 whether ReadConsoleInputA or ReadConsoleInputW is used.
421
422 Normally, if key != 0 then the system did the translation
423 successfully. But this is not true for LEFT_ALT (different to
424 RIGHT_ALT). In case of LEFT_ALT we can get key != 0. So
425 check for this first. */
426
427 if (key && ( !(state & LEFT_ALT_PRESSED) ||
428 (state & RIGHT_ALT_PRESSED) ))
429 {
430 /* This code should catch all keys returning a printable
431 character. Characters above 0x7F should be returned as
432 positive codes. */
433
434 if (kptab[vk].extended == 0)
435 {
436 SP->key_code = FALSE;
437 return key;
438 }
439 }
440
441 /* This case happens if a functional key has been entered. */
442
443 if ((state & ENHANCED_KEY) && (kptab[vk].extended != 999))
444 {
445 enhanced = TRUE;
446 idx = kptab[vk].extended;
447 }
448 else
449 {
450 enhanced = FALSE;
451 idx = vk;
452 }
453
454 if (state & SHIFT_PRESSED)
455 key = enhanced ? ext_kptab[idx].shift : kptab[idx].shift;
456
457 else if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
458 key = enhanced ? ext_kptab[idx].control : kptab[idx].control;
459
460 else if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
461 key = enhanced ? ext_kptab[idx].alt : kptab[idx].alt;
462
463 else
464 key = enhanced ? ext_kptab[idx].normal : kptab[idx].normal;
465
466 if (key < KEY_CODE_YES)
467 SP->key_code = FALSE;
468
469 return key;
470}
471
472static int _process_mouse_event(void)
473{
474 static const DWORD button_mask[] = {1, 4, 2};
475 short action, shift_flags = 0;
476 int i;
477
478 save_press = 0;
479 SP->key_code = TRUE;
480
481 memset(&SP->mouse_status, 0, sizeof(MOUSE_STATUS));
482
483 SP->mouse_status.x = MEV.dwMousePosition.X;
484 SP->mouse_status.y = MEV.dwMousePosition.Y;
485
486 /* Handle scroll wheel */
487
488 if (MEV.dwEventFlags == 4)
489 {
490 SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
491 PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
492
493 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
494
495 return KEY_MOUSE;
496 }
497
498 if (MEV.dwEventFlags == 8)
499 {
500 SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
501 PDC_MOUSE_WHEEL_RIGHT : PDC_MOUSE_WHEEL_LEFT;
502
503 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
504
505 return KEY_MOUSE;
506 }
507
508 action = (MEV.dwEventFlags == 2) ? BUTTON_DOUBLE_CLICKED :
509 ((MEV.dwEventFlags == 1) ? BUTTON_MOVED : BUTTON_PRESSED);
510
511 for (i = 0; i < 3; i++)
512 SP->mouse_status.button[i] =
513 (MEV.dwButtonState & button_mask[i]) ? action : 0;
514
515 if (action == BUTTON_PRESSED && MEV.dwButtonState & 7 && SP->mouse_wait)
516 {
517 /* Check for a click -- a PRESS followed immediately by a release */
518
519 if (!event_count)
520 {
521 napms(SP->mouse_wait);
522
523 GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
524 }
525
526 if (event_count)
527 {
528 INPUT_RECORD ip;
529 DWORD count;
530 bool have_click = FALSE;
531
532 PeekConsoleInput(pdc_con_in, &ip, 1, &count);
533
534 for (i = 0; i < 3; i++)
535 {
536 if (SP->mouse_status.button[i] == BUTTON_PRESSED &&
537 !(ip.Event.MouseEvent.dwButtonState & button_mask[i]))
538 {
539 SP->mouse_status.button[i] = BUTTON_CLICKED;
540 have_click = TRUE;
541 }
542 }
543
544 /* If a click was found, throw out the event */
545
546 if (have_click)
547 ReadConsoleInput(pdc_con_in, &ip, 1, &count);
548 }
549 }
550
551 SP->mouse_status.changes = 0;
552
553 for (i = 0; i < 3; i++)
554 {
555 if (old_mouse_status.button[i] != SP->mouse_status.button[i])
556 SP->mouse_status.changes |= (1 << i);
557
558 if (SP->mouse_status.button[i] == BUTTON_MOVED)
559 {
560 /* Discard non-moved "moves" */
561
562 if (SP->mouse_status.x == old_mouse_status.x &&
563 SP->mouse_status.y == old_mouse_status.y)
564 return -1;
565
566 /* Motion events always flag the button as changed */
567
568 SP->mouse_status.changes |= (1 << i);
569 SP->mouse_status.changes |= PDC_MOUSE_MOVED;
570 break;
571 }
572 }
573
574 old_mouse_status = SP->mouse_status;
575
576 /* Treat click events as release events for comparison purposes */
577
578 for (i = 0; i < 3; i++)
579 {
580 if (old_mouse_status.button[i] == BUTTON_CLICKED ||
581 old_mouse_status.button[i] == BUTTON_DOUBLE_CLICKED)
582 old_mouse_status.button[i] = BUTTON_RELEASED;
583 }
584
585 /* Check for SHIFT/CONTROL/ALT */
586
587 if (MEV.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
588 shift_flags |= BUTTON_ALT;
589
590 if (MEV.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
591 shift_flags |= BUTTON_CONTROL;
592
593 if (MEV.dwControlKeyState & SHIFT_PRESSED)
594 shift_flags |= BUTTON_SHIFT;
595
596 if (shift_flags)
597 {
598 for (i = 0; i < 3; i++)
599 {
600 if (SP->mouse_status.changes & (1 << i))
601 SP->mouse_status.button[i] |= shift_flags;
602 }
603 }
604
605 return KEY_MOUSE;
606}
607
608/* return the next available key or mouse event */
609
610int PDC_get_key(void)
611{
612 SP->key_modifiers = 0L;
613
614 if (!key_count)
615 {
616 DWORD count;
617
618 ReadConsoleInput(pdc_con_in, &save_ip, 1, &count);
619 event_count--;
620
621 if (save_ip.EventType == MOUSE_EVENT ||
622 save_ip.EventType == WINDOW_BUFFER_SIZE_EVENT)
623 key_count = 1;
624 else if (save_ip.EventType == KEY_EVENT)
625 key_count = _get_key_count();
626 }
627
628 if (key_count)
629 {
630 key_count--;
631
632 switch (save_ip.EventType)
633 {
634 case KEY_EVENT:
635 return _process_key_event();
636
637 case MOUSE_EVENT:
638 return _process_mouse_event();
639
640 case WINDOW_BUFFER_SIZE_EVENT:
641 if (REV.dwSize.Y != LINES || REV.dwSize.X != COLS)
642 {
643 if (!SP->resized)
644 {
645 SP->resized = TRUE;
646 SP->key_code = TRUE;
647 return KEY_RESIZE;
648 }
649 }
650 }
651 }
652
653 return -1;
654}
655
656/* discard any pending keyboard or mouse input -- this is the core
657 routine for flushinp() */
658
659void PDC_flushinp(void)
660{
661 PDC_LOG(("PDC_flushinp() - called\n"));
662
663 FlushConsoleInputBuffer(pdc_con_in);
664}
665
666bool PDC_has_mouse(void)
667{
668 return TRUE;
669}
670
671int PDC_mouse_set(void)
672{
673 DWORD mode;
674
675 /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
676 all other flags, except processed input mode;
677 If turning off the mouse: Set QuickEdit Mode to the status it
678 had on startup, and clear all other flags, except etc. */
679
680 GetConsoleMode(pdc_con_in, &mode);
681 mode = (mode & 1) | 0x0088;
682 SetConsoleMode(pdc_con_in, mode | (SP->_trap_mbe ?
683 ENABLE_MOUSE_INPUT : pdc_quick_edit));
684
685 memset(&old_mouse_status, 0, sizeof(old_mouse_status));
686
687 return OK;
688}
689
690int PDC_modifiers_set(void)
691{
692 return OK;
693}
diff --git a/scripts/kconfig/libcurses/pdcscrn.c b/scripts/kconfig/libcurses/pdcscrn.c
new file mode 100644
index 000000000..e2f4ddd90
--- /dev/null
+++ b/scripts/kconfig/libcurses/pdcscrn.c
@@ -0,0 +1,686 @@
1/* PDCurses */
2
3#include "pdcwin.h"
4
5#include <stdlib.h>
6
7/* Color component table */
8
9PDCCOLOR pdc_color[PDC_MAXCOL];
10
11HANDLE std_con_out = INVALID_HANDLE_VALUE;
12HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
13HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
14
15DWORD pdc_quick_edit;
16
17static short realtocurs[16] =
18{
19 COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
20 COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
21 COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
22 COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
23};
24
25static short ansitocurs[16] =
26{
27 COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE,
28 COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE, COLOR_BLACK + 8,
29 COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, COLOR_BLUE + 8,
30 COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8
31};
32
33short pdc_curstoreal[16], pdc_curstoansi[16];
34short pdc_oldf, pdc_oldb, pdc_oldu;
35bool pdc_conemu, pdc_wt, pdc_ansi;
36
37enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER };
38
39/* Struct for storing console registry keys, and for use with the
40 undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
41 www.catch22.net. */
42
43static struct
44{
45 ULONG Length;
46 COORD ScreenBufferSize;
47 COORD WindowSize;
48 ULONG WindowPosX;
49 ULONG WindowPosY;
50
51 COORD FontSize;
52 ULONG FontFamily;
53 ULONG FontWeight;
54 WCHAR FaceName[32];
55
56 ULONG CursorSize;
57 ULONG FullScreen;
58 ULONG QuickEdit;
59 ULONG AutoPosition;
60 ULONG InsertMode;
61
62 USHORT ScreenColors;
63 USHORT PopupColors;
64 ULONG HistoryNoDup;
65 ULONG HistoryBufferSize;
66 ULONG NumberOfHistoryBuffers;
67
68 COLORREF ColorTable[16];
69
70 ULONG CodePage;
71 HWND Hwnd;
72
73 WCHAR ConsoleTitle[0x100];
74} console_info;
75
76#ifdef HAVE_NO_INFOEX
77/* Console screen buffer information (extended version) */
78typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
79 ULONG cbSize;
80 COORD dwSize;
81 COORD dwCursorPosition;
82 WORD wAttributes;
83 SMALL_RECT srWindow;
84 COORD dwMaximumWindowSize;
85 WORD wPopupAttributes;
86 BOOL bFullscreenSupported;
87 COLORREF ColorTable[16];
88} CONSOLE_SCREEN_BUFFER_INFOEX;
89typedef CONSOLE_SCREEN_BUFFER_INFOEX *PCONSOLE_SCREEN_BUFFER_INFOEX;
90#endif
91
92typedef BOOL (WINAPI *SetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
93 PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
94typedef BOOL (WINAPI *GetConsoleScreenBufferInfoExFn)(HANDLE hConsoleOutput,
95 PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
96
97static SetConsoleScreenBufferInfoExFn pSetConsoleScreenBufferInfoEx = NULL;
98static GetConsoleScreenBufferInfoExFn pGetConsoleScreenBufferInfoEx = NULL;
99
100static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
101static CONSOLE_SCREEN_BUFFER_INFOEX console_infoex;
102
103static LPTOP_LEVEL_EXCEPTION_FILTER xcpt_filter;
104
105static DWORD old_console_mode = 0;
106
107static bool is_nt;
108
109static void _reset_old_colors(void)
110{
111 pdc_oldf = -1;
112 pdc_oldb = -1;
113 pdc_oldu = 0;
114}
115
116static HWND _find_console_handle(void)
117{
118 TCHAR orgtitle[1024], temptitle[1024];
119 HWND wnd;
120
121 GetConsoleTitle(orgtitle, 1024);
122
123 wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
124 SetConsoleTitle(temptitle);
125
126 Sleep(40);
127
128 wnd = FindWindow(NULL, temptitle);
129
130 SetConsoleTitle(orgtitle);
131
132 return wnd;
133}
134
135/* Undocumented console message */
136
137#define WM_SETCONSOLEINFO (WM_USER + 201)
138
139/* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
140 section (file-mapping) object in the context of the process which
141 owns the console, before posting the message. Originally by JB. */
142
143static void _set_console_info(void)
144{
145 CONSOLE_SCREEN_BUFFER_INFO csbi;
146 CONSOLE_CURSOR_INFO cci;
147 DWORD dwConsoleOwnerPid;
148 HANDLE hProcess;
149 HANDLE hSection, hDupSection;
150 PVOID ptrView;
151
152 /* Each-time initialization for console_info */
153
154 GetConsoleCursorInfo(pdc_con_out, &cci);
155 console_info.CursorSize = cci.dwSize;
156
157 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
158 console_info.ScreenBufferSize = csbi.dwSize;
159
160 console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
161 console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
162
163 console_info.WindowPosX = csbi.srWindow.Left;
164 console_info.WindowPosY = csbi.srWindow.Top;
165
166 /* Open the process which "owns" the console */
167
168 GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
169
170 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
171
172 /* Create a SECTION object backed by page-file, then map a view of
173 this section into the owner process so we can write the contents
174 of the CONSOLE_INFO buffer into it */
175
176 hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
177 0, sizeof(console_info), 0);
178
179 /* Copy our console structure into the section-object */
180
181 ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
182 0, 0, sizeof(console_info));
183
184 memcpy(ptrView, &console_info, sizeof(console_info));
185
186 UnmapViewOfFile(ptrView);
187
188 /* Map the memory into owner process */
189
190 DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
191 0, FALSE, DUPLICATE_SAME_ACCESS);
192
193 /* Send console window the "update" message */
194
195 SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
196
197 CloseHandle(hSection);
198 CloseHandle(hProcess);
199}
200
201static int _set_console_infoex(void)
202{
203 if (!pSetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
204 return ERR;
205
206 return OK;
207}
208
209static int _set_colors(void)
210{
211 SetConsoleTextAttribute(pdc_con_out, 7);
212 _reset_old_colors();
213
214 if (pSetConsoleScreenBufferInfoEx)
215 return _set_console_infoex();
216 else
217 {
218 _set_console_info();
219 return OK;
220 }
221}
222
223/* One-time initialization for console_info -- color table and font info
224 from the registry; other values from functions. */
225
226static void _init_console_info(void)
227{
228 DWORD scrnmode, len;
229 HKEY reghnd;
230 int i;
231
232 console_info.Hwnd = _find_console_handle();
233 console_info.Length = sizeof(console_info);
234
235 GetConsoleMode(pdc_con_in, &scrnmode);
236 console_info.QuickEdit = !!(scrnmode & 0x0040);
237 console_info.InsertMode = !!(scrnmode & 0x0020);
238
239 console_info.FullScreen = FALSE;
240 console_info.AutoPosition = 0x10000;
241 console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
242 console_info.PopupColors = 0xf5;
243
244 console_info.HistoryNoDup = FALSE;
245 console_info.HistoryBufferSize = 50;
246 console_info.NumberOfHistoryBuffers = 4;
247
248 console_info.CodePage = GetConsoleOutputCP();
249
250 RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
251 KEY_QUERY_VALUE, &reghnd);
252
253 len = sizeof(DWORD);
254
255 /* Default color table */
256
257 for (i = 0; i < 16; i++)
258 {
259 char tname[13];
260
261 sprintf(tname, "ColorTable%02d", i);
262 RegQueryValueExA(reghnd, tname, NULL, NULL,
263 (LPBYTE)(&(console_info.ColorTable[i])), &len);
264 }
265
266 /* Font info */
267
268 RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
269 (LPBYTE)(&console_info.FontSize), &len);
270 RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
271 (LPBYTE)(&console_info.FontFamily), &len);
272 RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
273 (LPBYTE)(&console_info.FontWeight), &len);
274
275 len = sizeof(WCHAR) * 32;
276 RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
277 (LPBYTE)(console_info.FaceName), &len);
278
279 RegCloseKey(reghnd);
280}
281
282static int _init_console_infoex(void)
283{
284 console_infoex.cbSize = sizeof(console_infoex);
285
286 if (!pGetConsoleScreenBufferInfoEx(pdc_con_out, &console_infoex))
287 return ERR;
288
289 console_infoex.srWindow.Right++;
290 console_infoex.srWindow.Bottom++;
291
292 return OK;
293}
294
295static COLORREF *_get_colors(void)
296{
297 if (pGetConsoleScreenBufferInfoEx)
298 {
299 int status = OK;
300 if (!console_infoex.cbSize)
301 status = _init_console_infoex();
302 return (status == ERR) ? NULL :
303 (COLORREF *)(&(console_infoex.ColorTable));
304 }
305 else
306 {
307 if (!console_info.Hwnd)
308 _init_console_info();
309 return (COLORREF *)(&(console_info.ColorTable));
310 }
311}
312
313/* restore the original console buffer in the event of a crash */
314
315static LONG WINAPI _restore_console(LPEXCEPTION_POINTERS ep)
316{
317 PDC_scr_close();
318
319 return EXCEPTION_CONTINUE_SEARCH;
320}
321
322/* restore the original console buffer on Ctrl+Break (or Ctrl+C,
323 if it gets re-enabled) */
324
325static BOOL WINAPI _ctrl_break(DWORD dwCtrlType)
326{
327 if (dwCtrlType == CTRL_BREAK_EVENT || dwCtrlType == CTRL_C_EVENT)
328 PDC_scr_close();
329
330 return FALSE;
331}
332
333/* close the physical screen -- may restore the screen to its state
334 before PDC_scr_open(); miscellaneous cleanup */
335
336void PDC_scr_close(void)
337{
338 PDC_LOG(("PDC_scr_close() - called\n"));
339
340 if (SP->visibility != 1)
341 curs_set(1);
342
343 PDC_reset_shell_mode();
344
345 /* Position cursor to the bottom left of the screen. */
346
347 if (SP->_restore == PDC_RESTORE_NONE)
348 {
349 SMALL_RECT win;
350
351 win.Left = orig_scr.srWindow.Left;
352 win.Right = orig_scr.srWindow.Right;
353 win.Top = 0;
354 win.Bottom = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top;
355 SetConsoleWindowInfo(pdc_con_out, TRUE, &win);
356 PDC_gotoyx(win.Bottom, 0);
357 }
358}
359
360void PDC_scr_free(void)
361{
362 if (pdc_con_out != std_con_out)
363 {
364 CloseHandle(pdc_con_out);
365 pdc_con_out = std_con_out;
366 }
367
368 SetUnhandledExceptionFilter(xcpt_filter);
369 SetConsoleCtrlHandler(_ctrl_break, FALSE);
370}
371
372/* open the physical screen -- miscellaneous initialization, may save
373 the existing screen for later restoration */
374
375int PDC_scr_open(void)
376{
377 const char *str;
378 CONSOLE_SCREEN_BUFFER_INFO csbi;
379 HMODULE h_kernel;
380 BOOL result;
381 int i;
382
383 PDC_LOG(("PDC_scr_open() - called\n"));
384
385 for (i = 0; i < 16; i++)
386 {
387 pdc_curstoreal[realtocurs[i]] = i;
388 pdc_curstoansi[ansitocurs[i]] = i;
389 }
390 _reset_old_colors();
391
392 std_con_out =
393 pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
394 pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
395
396 if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
397 {
398 fprintf(stderr, "\nRedirection is not supported.\n");
399 exit(1);
400 }
401
402 is_nt = !(GetVersion() & 0x80000000);
403
404 pdc_wt = !!getenv("WT_SESSION");
405 str = pdc_wt ? NULL : getenv("ConEmuANSI");
406 pdc_conemu = !!str;
407 pdc_ansi = pdc_wt ? TRUE : pdc_conemu ? !strcmp(str, "ON") : FALSE;
408
409 GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
410 GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
411 GetConsoleMode(pdc_con_in, &old_console_mode);
412
413 /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
414 the mouse is not enabled -- other console input settings are
415 cleared */
416
417 pdc_quick_edit = old_console_mode & 0x0040;
418
419 SP->mouse_wait = PDC_CLICK_PERIOD;
420 SP->audible = TRUE;
421
422 SP->termattrs = A_COLOR | A_REVERSE;
423 if (pdc_ansi)
424 SP->termattrs |= A_UNDERLINE | A_ITALIC;
425
426 SP->orig_fore = csbi.wAttributes & 0x0f;
427 SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
428
429 SP->orig_attr = TRUE;
430
431 SP->_restore = PDC_RESTORE_NONE;
432
433 if ((str = getenv("PDC_RESTORE_SCREEN")) == NULL || *str != '0')
434 {
435 /* Create a new console buffer */
436
437 pdc_con_out =
438 CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
439 FILE_SHARE_READ | FILE_SHARE_WRITE,
440 NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
441
442 if (pdc_con_out == INVALID_HANDLE_VALUE)
443 {
444 PDC_LOG(("PDC_scr_open() - screen buffer failure\n"));
445
446 pdc_con_out = std_con_out;
447 }
448 else
449 SP->_restore = PDC_RESTORE_BUFFER;
450 }
451
452 xcpt_filter = SetUnhandledExceptionFilter(_restore_console);
453 SetConsoleCtrlHandler(_ctrl_break, TRUE);
454
455 SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
456
457 /* ENABLE_LVB_GRID_WORLDWIDE */
458 result = SetConsoleMode(pdc_con_out, 0x0010);
459 if (result)
460 SP->termattrs |= A_UNDERLINE | A_LEFT | A_RIGHT;
461
462 PDC_reset_prog_mode();
463
464 SP->mono = FALSE;
465
466 h_kernel = GetModuleHandleA("kernel32.dll");
467 pGetConsoleScreenBufferInfoEx =
468 (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
469 "GetConsoleScreenBufferInfoEx");
470 pSetConsoleScreenBufferInfoEx =
471 (SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
472 "SetConsoleScreenBufferInfoEx");
473
474 return OK;
475}
476
477 /* Calls SetConsoleWindowInfo with the given parameters, but fits them
478 if a scoll bar shrinks the maximum possible value. The rectangle
479 must at least fit in a half-sized window. */
480
481static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
482{
483 SMALL_RECT run;
484 SHORT mx, my;
485
486 if (SetConsoleWindowInfo(con_out, TRUE, rect))
487 return TRUE;
488
489 run = *rect;
490 run.Right /= 2;
491 run.Bottom /= 2;
492
493 mx = run.Right;
494 my = run.Bottom;
495
496 if (!SetConsoleWindowInfo(con_out, TRUE, &run))
497 return FALSE;
498
499 for (run.Right = rect->Right; run.Right >= mx; run.Right--)
500 if (SetConsoleWindowInfo(con_out, TRUE, &run))
501 break;
502
503 if (run.Right < mx)
504 return FALSE;
505
506 for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
507 if (SetConsoleWindowInfo(con_out, TRUE, &run))
508 return TRUE;
509
510 return FALSE;
511}
512
513/* the core of resize_term() */
514
515int PDC_resize_screen(int nlines, int ncols)
516{
517 SMALL_RECT rect;
518 COORD size, max;
519
520 bool prog_resize = nlines || ncols;
521
522 if (!prog_resize)
523 {
524 nlines = PDC_get_rows();
525 ncols = PDC_get_columns();
526 }
527
528 if (nlines < 2 || ncols < 2)
529 return ERR;
530
531 max = GetLargestConsoleWindowSize(pdc_con_out);
532
533 rect.Left = rect.Top = 0;
534 rect.Right = ncols - 1;
535
536 if (rect.Right > max.X)
537 rect.Right = max.X;
538
539 rect.Bottom = nlines - 1;
540
541 if (rect.Bottom > max.Y)
542 rect.Bottom = max.Y;
543
544 size.X = rect.Right + 1;
545 size.Y = rect.Bottom + 1;
546
547 _fit_console_window(pdc_con_out, &rect);
548 SetConsoleScreenBufferSize(pdc_con_out, size);
549
550 if (prog_resize)
551 {
552 _fit_console_window(pdc_con_out, &rect);
553 SetConsoleScreenBufferSize(pdc_con_out, size);
554 }
555 SetConsoleActiveScreenBuffer(pdc_con_out);
556
557 PDC_flushinp();
558
559 return OK;
560}
561
562void PDC_reset_prog_mode(void)
563{
564 PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
565
566 if (pdc_con_out != std_con_out)
567 SetConsoleActiveScreenBuffer(pdc_con_out);
568 else if (is_nt)
569 {
570 COORD bufsize;
571 SMALL_RECT rect;
572
573 bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
574 bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
575
576 rect.Top = rect.Left = 0;
577 rect.Bottom = bufsize.Y - 1;
578 rect.Right = bufsize.X - 1;
579
580 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
581 SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
582 SetConsoleScreenBufferSize(pdc_con_out, bufsize);
583 SetConsoleActiveScreenBuffer(pdc_con_out);
584 }
585
586 PDC_mouse_set();
587}
588
589void PDC_reset_shell_mode(void)
590{
591 PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
592
593 if (pdc_con_out != std_con_out)
594 SetConsoleActiveScreenBuffer(std_con_out);
595 else if (is_nt)
596 {
597 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
598 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
599 SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
600 SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
601 SetConsoleActiveScreenBuffer(pdc_con_out);
602 }
603
604 SetConsoleMode(pdc_con_in, old_console_mode | 0x0080);
605}
606
607void PDC_restore_screen_mode(int i)
608{
609}
610
611void PDC_save_screen_mode(int i)
612{
613}
614
615bool PDC_can_change_color(void)
616{
617 return is_nt;
618}
619
620int PDC_color_content(short color, short *red, short *green, short *blue)
621{
622 if (color < 16 && !(pdc_conemu || pdc_wt))
623 {
624 COLORREF *color_table = _get_colors();
625
626 if (color_table)
627 {
628 DWORD col = color_table[pdc_curstoreal[color]];
629
630 *red = DIVROUND(GetRValue(col) * 1000, 255);
631 *green = DIVROUND(GetGValue(col) * 1000, 255);
632 *blue = DIVROUND(GetBValue(col) * 1000, 255);
633 }
634 else
635 return ERR;
636 }
637 else
638 {
639 if (!pdc_color[color].mapped)
640 {
641 *red = *green = *blue = -1;
642 return ERR;
643 }
644
645 *red = pdc_color[color].r;
646 *green = pdc_color[color].g;
647 *blue = pdc_color[color].b;
648 }
649
650 return OK;
651}
652
653int PDC_init_color(short color, short red, short green, short blue)
654{
655 if (red == -1 && green == -1 && blue == -1)
656 {
657 pdc_color[color].mapped = FALSE;
658 return OK;
659 }
660
661 if (color < 16 && !(pdc_conemu || pdc_wt))
662 {
663 COLORREF *color_table = _get_colors();
664
665 if (color_table)
666 {
667 color_table[pdc_curstoreal[color]] =
668 RGB(DIVROUND(red * 255, 1000),
669 DIVROUND(green * 255, 1000),
670 DIVROUND(blue * 255, 1000));
671
672 return _set_colors();
673 }
674
675 return ERR;
676 }
677 else
678 {
679 pdc_color[color].r = red;
680 pdc_color[color].g = green;
681 pdc_color[color].b = blue;
682 pdc_color[color].mapped = TRUE;
683 }
684
685 return OK;
686}
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..cee76931b
--- /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_wt, 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..306f4efb3
--- /dev/null
+++ b/scripts/kconfig/libcurses/refresh.c
@@ -0,0 +1,287 @@
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)
68 return ERR;
69 if (is_pad(win))
70 return pnoutrefresh(win,
71 win->_pad._pad_y,
72 win->_pad._pad_x,
73 win->_pad._pad_top,
74 win->_pad._pad_left,
75 win->_pad._pad_bottom,
76 win->_pad._pad_right);
77
78 begy = win->_begy;
79 begx = win->_begx;
80
81 for (i = 0, j = begy; i < win->_maxy; i++, j++)
82 {
83 if (win->_firstch[i] != _NO_CHANGE)
84 {
85 chtype *src = win->_y[i];
86 chtype *dest = curscr->_y[j] + begx;
87
88 int first = win->_firstch[i]; /* first changed */
89 int last = win->_lastch[i]; /* last changed */
90
91 /* ignore areas on the outside that are marked as changed,
92 but really aren't */
93
94 while (first <= last && src[first] == dest[first])
95 first++;
96
97 while (last >= first && src[last] == dest[last])
98 last--;
99
100 /* if any have really changed... */
101
102 if (first <= last)
103 {
104 memcpy(dest + first, src + first,
105 (last - first + 1) * sizeof(chtype));
106
107 first += begx;
108 last += begx;
109
110 if (first < curscr->_firstch[j] ||
111 curscr->_firstch[j] == _NO_CHANGE)
112 curscr->_firstch[j] = first;
113
114 if (last > curscr->_lastch[j])
115 curscr->_lastch[j] = last;
116 }
117
118 win->_firstch[i] = _NO_CHANGE; /* updated now */
119 }
120
121 win->_lastch[i] = _NO_CHANGE; /* updated now */
122 }
123
124 if (win->_clear)
125 win->_clear = FALSE;
126
127 if (!win->_leaveit)
128 {
129 curscr->_cury = win->_cury + begy;
130 curscr->_curx = win->_curx + begx;
131 }
132
133 return OK;
134}
135
136int doupdate(void)
137{
138 int y;
139 bool clearall;
140
141 PDC_LOG(("doupdate() - called\n"));
142
143 if (!SP || !curscr)
144 return ERR;
145
146 if (isendwin()) /* coming back after endwin() called */
147 {
148 reset_prog_mode();
149 clearall = TRUE;
150 SP->alive = TRUE; /* so isendwin() result is correct */
151 }
152 else
153 clearall = curscr->_clear;
154
155 for (y = 0; y < SP->lines; y++)
156 {
157 PDC_LOG(("doupdate() - Transforming line %d of %d: %s\n",
158 y, SP->lines, (curscr->_firstch[y] != _NO_CHANGE) ?
159 "Yes" : "No"));
160
161 if (clearall || curscr->_firstch[y] != _NO_CHANGE)
162 {
163 int first, last;
164
165 chtype *src = curscr->_y[y];
166 chtype *dest = SP->lastscr->_y[y];
167
168 if (clearall)
169 {
170 first = 0;
171 last = COLS - 1;
172 }
173 else
174 {
175 first = curscr->_firstch[y];
176 last = curscr->_lastch[y];
177 }
178
179 while (first <= last)
180 {
181 int len = 0;
182
183 /* build up a run of changed cells; if two runs are
184 separated by a single unchanged cell, ignore the
185 break */
186
187 if (clearall)
188 len = last - first + 1;
189 else
190 while (first + len <= last &&
191 (src[first + len] != dest[first + len] ||
192 (len && first + len < last &&
193 src[first + len + 1] != dest[first + len + 1])
194 )
195 )
196 len++;
197
198 /* update the screen, and SP->lastscr */
199
200 if (len)
201 {
202 PDC_transform_line(y, first, len, src + first);
203 memcpy(dest + first, src + first, len * sizeof(chtype));
204 first += len;
205 }
206
207 /* skip over runs of unchanged cells */
208
209 while (first <= last && src[first] == dest[first])
210 first++;
211 }
212
213 curscr->_firstch[y] = _NO_CHANGE;
214 curscr->_lastch[y] = _NO_CHANGE;
215 }
216 }
217
218 curscr->_clear = FALSE;
219
220 if (SP->visibility)
221 PDC_gotoyx(curscr->_cury, curscr->_curx);
222
223 SP->cursrow = curscr->_cury;
224 SP->curscol = curscr->_curx;
225
226 PDC_doupdate();
227
228 return OK;
229}
230
231int wrefresh(WINDOW *win)
232{
233 bool save_clear;
234
235 PDC_LOG(("wrefresh() - called\n"));
236
237 if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
238 return ERR;
239
240 save_clear = win->_clear;
241
242 if (win == curscr)
243 curscr->_clear = TRUE;
244 else
245 wnoutrefresh(win);
246
247 if (save_clear && win->_maxy == SP->lines && win->_maxx == SP->cols)
248 curscr->_clear = TRUE;
249
250 return doupdate();
251}
252
253int refresh(void)
254{
255 PDC_LOG(("refresh() - called\n"));
256
257 return wrefresh(stdscr);
258}
259
260int wredrawln(WINDOW *win, int start, int num)
261{
262 int i;
263
264 PDC_LOG(("wredrawln() - called: win=%p start=%d num=%d\n",
265 win, start, num));
266
267 if (!win || start > win->_maxy || start + num > win->_maxy)
268 return ERR;
269
270 for (i = start; i < start + num; i++)
271 {
272 win->_firstch[i] = 0;
273 win->_lastch[i] = win->_maxx - 1;
274 }
275
276 return OK;
277}
278
279int redrawwin(WINDOW *win)
280{
281 PDC_LOG(("redrawwin() - called: win=%p\n", win));
282
283 if (!win)
284 return ERR;
285
286 return wredrawln(win, 0, win->_maxy);
287}
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..2fd03cce5
--- /dev/null
+++ b/scripts/kconfig/libcurses/touch.c
@@ -0,0 +1,208 @@
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, begy1, begx1, begy2, begx2;
172
173 PDC_LOG(("touchoverlap() - called: win1=%p win2=%p\n", win1, win2));
174
175 if (!win1 || !win2)
176 return ERR;
177
178 begy1 = win1->_begy;
179 begx1 = win1->_begx;
180 begy2 = win2->_begy;
181 begx2 = win2->_begy;
182
183 starty = max(begy1, begy2);
184 startx = max(begx1, begx2);
185 endy = min(win1->_maxy + begy1, win2->_maxy + begy2);
186 endx = min(win1->_maxx + begx1, win2->_maxx + begx2);
187
188 if (starty >= endy || startx >= endx)
189 return OK;
190
191 starty -= begy2;
192 startx -= begx2;
193 endy -= begy2;
194 endx -= begx2;
195 endx -= 1;
196
197 for (y = starty; y < endy; y++)
198 {
199 int first = win2->_firstch[y];
200
201 if (first == _NO_CHANGE || win2->_lastch[y] < endx)
202 win2->_lastch[y] = endx;
203 if (first == _NO_CHANGE || first > startx)
204 win2->_firstch[y] = startx;
205 }
206
207 return OK;
208}
diff --git a/scripts/kconfig/libcurses/window.c b/scripts/kconfig/libcurses/window.c
new file mode 100644
index 000000000..4ae5b0861
--- /dev/null
+++ b/scripts/kconfig/libcurses/window.c
@@ -0,0 +1,637 @@
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 WINDOW *wgetparent(const WINDOW *win);
19 int delwin(WINDOW *win);
20 int mvwin(WINDOW *win, int y, int x);
21 int mvderwin(WINDOW *win, int pary, int parx);
22 int syncok(WINDOW *win, bool bf);
23 bool is_subwin(const WINDOW *win);
24 bool is_syncok(const WINDOW *win);
25 void wsyncup(WINDOW *win);
26 void wcursyncup(WINDOW *win);
27 void wsyncdown(WINDOW *win);
28
29 WINDOW *resize_window(WINDOW *win, int nlines, int ncols);
30 int wresize(WINDOW *win, int nlines, int ncols);
31 WINDOW *PDC_makelines(WINDOW *win);
32 WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx);
33 void PDC_sync(WINDOW *win);
34
35### Description
36
37 newwin() creates a new window with the given number of lines, nlines
38 and columns, ncols. The upper left corner of the window is at line
39 begy, column begx. If nlines is zero, it defaults to LINES - begy;
40 ncols to COLS - begx. Create a new full-screen window by calling
41 newwin(0, 0, 0, 0).
42
43 delwin() deletes the named window, freeing all associated memory. In
44 the case of overlapping windows, subwindows should be deleted before
45 the main window.
46
47 mvwin() moves the window so that the upper left-hand corner is at
48 position (y,x). If the move would cause the window to be off the
49 screen, it is an error and the window is not moved. Moving subwindows
50 is allowed.
51
52 subwin() creates a new subwindow within a window. The dimensions of
53 the subwindow are nlines lines and ncols columns. The subwindow is at
54 position (begy, begx) on the screen. This position is relative to the
55 screen, and not to the window orig. Changes made to either window
56 will affect both. When using this routine, you will often need to
57 call touchwin() before calling wrefresh().
58
59 derwin() is the same as subwin(), except that begy and begx are
60 relative to the origin of the window orig rather than the screen.
61 There is no difference between subwindows and derived windows.
62
63 mvderwin() moves a derived window (or subwindow) inside its parent
64 window. The screen-relative parameters of the window are not changed.
65 This routine is used to display different parts of the parent window
66 at the same physical position on the screen.
67
68 dupwin() creates an exact duplicate of the window win.
69
70 wgetparent() returns the parent WINDOW pointer for subwindows, or NULL
71 for windows having no parent.
72
73 wsyncup() causes a touchwin() of all of the window's parents.
74
75 If syncok() is called with a second argument of TRUE, this causes a
76 wsyncup() to be called every time the window is changed.
77
78 is_subwin() reports whether the specified window is a subwindow,
79 created by subwin() or derwin().
80
81 is_syncok() reports whether the specified window is in syncok mode.
82
83 wcursyncup() causes the current cursor position of all of a window's
84 ancestors to reflect the current cursor position of the current
85 window.
86
87 wsyncdown() causes a touchwin() of the current window if any of its
88 parent's windows have been touched.
89
90 resize_window() allows the user to resize an existing window. It
91 returns the pointer to the new window, or NULL on failure.
92
93 wresize() is an ncurses-compatible wrapper for resize_window(). Note
94 that, unlike ncurses, it will NOT process any subwindows of the
95 window. (However, you still can call it _on_ subwindows.) It returns
96 OK or ERR.
97
98 PDC_makenew() allocates all data for a new WINDOW * except the actual
99 lines themselves. If it's unable to allocate memory for the window
100 structure, it will free all allocated memory and return a NULL
101 pointer.
102
103 PDC_makelines() allocates the memory for the lines.
104
105 PDC_sync() handles wrefresh() and wsyncup() calls when a window is
106 changed.
107
108### Return Value
109
110 newwin(), subwin(), derwin() and dupwin() return a pointer to the new
111 window, or NULL on failure. delwin(), mvwin(), mvderwin() and
112 syncok() return OK or ERR. wsyncup(), wcursyncup() and wsyncdown()
113 return nothing.
114
115 is_subwin() and is_syncok() returns TRUE or FALSE.
116
117### Errors
118
119 It is an error to call resize_window() before calling initscr().
120 Also, an error will be generated if we fail to create a newly sized
121 replacement window for curscr, or stdscr. This could happen when
122 increasing the window size. NOTE: If this happens, the previously
123 successfully allocated windows are left alone; i.e., the resize is
124 NOT cancelled for those windows.
125
126### Portability
127 X/Open ncurses NetBSD
128 newwin Y Y Y
129 delwin Y Y Y
130 mvwin Y Y Y
131 subwin Y Y Y
132 derwin Y Y Y
133 mvderwin Y Y Y
134 dupwin Y Y Y
135 wgetparent - Y -
136 wsyncup Y Y Y
137 syncok Y Y Y
138 is_subwin - Y -
139 is_syncok - Y -
140 wcursyncup Y Y Y
141 wsyncdown Y Y Y
142 wresize - Y Y
143 resize_window - - -
144 PDC_makelines - - -
145 PDC_makenew - - -
146 PDC_sync - - -
147
148**man-end****************************************************************/
149
150#include <stdlib.h>
151
152WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
153{
154 WINDOW *win;
155
156 PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
157 nlines, ncols, begy, begx));
158
159 /* allocate the window structure itself */
160
161 win = calloc(1, sizeof(WINDOW));
162 if (!win)
163 return win;
164
165 /* allocate the line pointer array */
166
167 win->_y = malloc(nlines * sizeof(chtype *));
168 if (!win->_y)
169 {
170 free(win);
171 return (WINDOW *)NULL;
172 }
173
174 /* allocate the minchng and maxchng arrays */
175
176 win->_firstch = malloc(nlines * sizeof(int));
177 if (!win->_firstch)
178 {
179 free(win->_y);
180 free(win);
181 return (WINDOW *)NULL;
182 }
183
184 win->_lastch = malloc(nlines * sizeof(int));
185 if (!win->_lastch)
186 {
187 free(win->_firstch);
188 free(win->_y);
189 free(win);
190 return (WINDOW *)NULL;
191 }
192
193 /* initialize window variables */
194
195 win->_maxy = nlines; /* real max screen size */
196 win->_maxx = ncols; /* real max screen size */
197 win->_begy = begy;
198 win->_begx = begx;
199 win->_bkgd = ' '; /* wrs 4/10/93 -- initialize background to blank */
200 win->_clear = (bool) ((nlines == LINES) && (ncols == COLS));
201 win->_bmarg = nlines - 1;
202 win->_parx = win->_pary = -1;
203
204 /* initialize pad variables*/
205
206 win->_pad._pad_y = -1;
207 win->_pad._pad_x = -1;
208 win->_pad._pad_top = -1;
209 win->_pad._pad_left = -1;
210 win->_pad._pad_bottom = -1;
211 win->_pad._pad_right = -1;
212
213 /* init to say window all changed */
214
215 touchwin(win);
216
217 return win;
218}
219
220WINDOW *PDC_makelines(WINDOW *win)
221{
222 int i, j, nlines, ncols;
223
224 PDC_LOG(("PDC_makelines() - called\n"));
225
226 if (!win)
227 return (WINDOW *)NULL;
228
229 nlines = win->_maxy;
230 ncols = win->_maxx;
231
232 for (i = 0; i < nlines; i++)
233 {
234 win->_y[i] = malloc(ncols * sizeof(chtype));
235 if (!win->_y[i])
236 {
237 /* if error, free all the data */
238
239 for (j = 0; j < i; j++)
240 free(win->_y[j]);
241
242 free(win->_firstch);
243 free(win->_lastch);
244 free(win->_y);
245 free(win);
246
247 return (WINDOW *)NULL;
248 }
249 }
250
251 return win;
252}
253
254void PDC_sync(WINDOW *win)
255{
256 PDC_LOG(("PDC_sync() - called:\n"));
257
258 if (win->_immed)
259 wrefresh(win);
260 if (win->_sync)
261 wsyncup(win);
262}
263
264WINDOW *newwin(int nlines, int ncols, int begy, int begx)
265{
266 WINDOW *win;
267
268 PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
269 nlines, ncols, begy, begx));
270
271 if (!nlines)
272 nlines = LINES - begy;
273 if (!ncols)
274 ncols = COLS - begx;
275
276 if (!SP || begy + nlines > SP->lines || begx + ncols > SP->cols)
277 return (WINDOW *)NULL;
278
279 win = PDC_makenew(nlines, ncols, begy, begx);
280 if (win)
281 win = PDC_makelines(win);
282
283 if (win)
284 werase(win);
285
286 return win;
287}
288
289int delwin(WINDOW *win)
290{
291 int i;
292
293 PDC_LOG(("delwin() - called\n"));
294
295 if (!win)
296 return ERR;
297
298 /* subwindows use parents' lines */
299
300 if (!(win->_flags & (_SUBWIN|_SUBPAD)))
301 for (i = 0; i < win->_maxy && win->_y[i]; i++)
302 if (win->_y[i])
303 free(win->_y[i]);
304
305 free(win->_firstch);
306 free(win->_lastch);
307 free(win->_y);
308 free(win);
309
310 return OK;
311}
312
313int mvwin(WINDOW *win, int y, int x)
314{
315 PDC_LOG(("mvwin() - called\n"));
316
317 if (!win || (y + win->_maxy > LINES || y < 0)
318 || (x + win->_maxx > COLS || x < 0))
319 return ERR;
320
321 win->_begy = y;
322 win->_begx = x;
323 touchwin(win);
324
325 return OK;
326}
327
328WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
329{
330 WINDOW *win;
331 int i, j, k;
332
333 PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
334 nlines, ncols, begy, begx));
335
336 /* make sure window fits inside the original one */
337
338 if (!orig || (begy < orig->_begy) || (begx < orig->_begx) ||
339 (begy + nlines) > (orig->_begy + orig->_maxy) ||
340 (begx + ncols) > (orig->_begx + orig->_maxx))
341 return (WINDOW *)NULL;
342
343 j = begy - orig->_begy;
344 k = begx - orig->_begx;
345
346 if (!nlines)
347 nlines = orig->_maxy - j;
348 if (!ncols)
349 ncols = orig->_maxx - k;
350
351 win = PDC_makenew(nlines, ncols, begy, begx);
352 if (!win)
353 return (WINDOW *)NULL;
354
355 /* initialize window variables */
356
357 win->_attrs = orig->_attrs;
358 win->_bkgd = orig->_bkgd;
359 win->_leaveit = orig->_leaveit;
360 win->_scroll = orig->_scroll;
361 win->_nodelay = orig->_nodelay;
362 win->_delayms = orig->_delayms;
363 win->_use_keypad = orig->_use_keypad;
364 win->_immed = orig->_immed;
365 win->_sync = orig->_sync;
366 win->_pary = j;
367 win->_parx = k;
368 win->_parent = orig;
369
370 for (i = 0; i < nlines; i++, j++)
371 win->_y[i] = orig->_y[j] + k;
372
373 win->_flags |= _SUBWIN;
374
375 return win;
376}
377
378WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
379{
380 return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx);
381}
382
383int mvderwin(WINDOW *win, int pary, int parx)
384{
385 int i, j;
386 WINDOW *mypar;
387
388 if (!win || !(win->_parent))
389 return ERR;
390
391 mypar = win->_parent;
392
393 if (pary < 0 || parx < 0 || (pary + win->_maxy) > mypar->_maxy ||
394 (parx + win->_maxx) > mypar->_maxx)
395 return ERR;
396
397 j = pary;
398
399 for (i = 0; i < win->_maxy; i++)
400 win->_y[i] = (mypar->_y[j++]) + parx;
401
402 win->_pary = pary;
403 win->_parx = parx;
404
405 return OK;
406}
407
408WINDOW *dupwin(WINDOW *win)
409{
410 WINDOW *new;
411 chtype *ptr, *ptr1;
412 int nlines, ncols, begy, begx, i;
413
414 if (!win)
415 return (WINDOW *)NULL;
416
417 nlines = win->_maxy;
418 ncols = win->_maxx;
419 begy = win->_begy;
420 begx = win->_begx;
421
422 new = PDC_makenew(nlines, ncols, begy, begx);
423 if (new)
424 new = PDC_makelines(new);
425
426 if (!new)
427 return (WINDOW *)NULL;
428
429 /* copy the contents of win into new */
430
431 for (i = 0; i < nlines; i++)
432 {
433 for (ptr = new->_y[i], ptr1 = win->_y[i];
434 ptr < new->_y[i] + ncols; ptr++, ptr1++)
435 *ptr = *ptr1;
436
437 new->_firstch[i] = 0;
438 new->_lastch[i] = ncols - 1;
439 }
440
441 new->_curx = win->_curx;
442 new->_cury = win->_cury;
443 new->_maxy = win->_maxy;
444 new->_maxx = win->_maxx;
445 new->_begy = win->_begy;
446 new->_begx = win->_begx;
447 new->_flags = win->_flags;
448 new->_attrs = win->_attrs;
449 new->_clear = win->_clear;
450 new->_leaveit = win->_leaveit;
451 new->_scroll = win->_scroll;
452 new->_nodelay = win->_nodelay;
453 new->_delayms = win->_delayms;
454 new->_use_keypad = win->_use_keypad;
455 new->_tmarg = win->_tmarg;
456 new->_bmarg = win->_bmarg;
457 new->_parx = win->_parx;
458 new->_pary = win->_pary;
459 new->_parent = win->_parent;
460 new->_bkgd = win->_bkgd;
461 new->_flags = win->_flags;
462
463 return new;
464}
465
466WINDOW *wgetparent(const WINDOW *win)
467{
468 PDC_LOG(("wgetparent() - called\n"));
469
470 if (!win || !win->_parent)
471 return NULL;
472
473 return win->_parent;
474}
475
476WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
477{
478 WINDOW *new;
479 int i, save_cury, save_curx, new_begy, new_begx;
480
481 PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
482 nlines, ncols));
483
484 if (!win || !SP)
485 return (WINDOW *)NULL;
486
487 if (win->_flags & _SUBPAD)
488 {
489 new = subpad(win->_parent, nlines, ncols, win->_begy, win->_begx);
490 if (!new)
491 return (WINDOW *)NULL;
492 }
493 else if (win->_flags & _SUBWIN)
494 {
495 new = subwin(win->_parent, nlines, ncols, win->_begy, win->_begx);
496 if (!new)
497 return (WINDOW *)NULL;
498 }
499 else
500 {
501 if (win == SP->slk_winptr)
502 {
503 new_begy = SP->lines - SP->slklines;
504 new_begx = 0;
505 }
506 else
507 {
508 new_begy = win->_begy;
509 new_begx = win->_begx;
510 }
511
512 new = PDC_makenew(nlines, ncols, new_begy, new_begx);
513 if (!new)
514 return (WINDOW *)NULL;
515 }
516
517 save_curx = min(win->_curx, (new->_maxx - 1));
518 save_cury = min(win->_cury, (new->_maxy - 1));
519
520 if (!(win->_flags & (_SUBPAD|_SUBWIN)))
521 {
522 new = PDC_makelines(new);
523 if (!new)
524 return (WINDOW *)NULL;
525
526 new->_bkgd = win->_bkgd;
527 werase(new);
528
529 copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1,
530 min(win->_maxx, new->_maxx) - 1, FALSE);
531
532 for (i = 0; i < win->_maxy && win->_y[i]; i++)
533 if (win->_y[i])
534 free(win->_y[i]);
535 }
536
537 new->_flags = win->_flags;
538 new->_attrs = win->_attrs;
539 new->_clear = win->_clear;
540 new->_leaveit = win->_leaveit;
541 new->_scroll = win->_scroll;
542 new->_nodelay = win->_nodelay;
543 new->_delayms = win->_delayms;
544 new->_use_keypad = win->_use_keypad;
545 new->_tmarg = (win->_tmarg > new->_maxy - 1) ? 0 : win->_tmarg;
546 new->_bmarg = (win->_bmarg == win->_maxy - 1) ?
547 new->_maxy - 1 : min(win->_bmarg, (new->_maxy - 1));
548 new->_parent = win->_parent;
549 new->_immed = win->_immed;
550 new->_sync = win->_sync;
551 new->_bkgd = win->_bkgd;
552
553 new->_curx = save_curx;
554 new->_cury = save_cury;
555
556 free(win->_firstch);
557 free(win->_lastch);
558 free(win->_y);
559
560 *win = *new;
561 free(new);
562
563 return win;
564}
565
566int wresize(WINDOW *win, int nlines, int ncols)
567{
568 return (resize_window(win, nlines, ncols) ? OK : ERR);
569}
570
571void wsyncup(WINDOW *win)
572{
573 WINDOW *tmp;
574
575 PDC_LOG(("wsyncup() - called\n"));
576
577 for (tmp = win; tmp; tmp = tmp->_parent)
578 touchwin(tmp);
579}
580
581int syncok(WINDOW *win, bool bf)
582{
583 PDC_LOG(("syncok() - called\n"));
584
585 if (!win)
586 return ERR;
587
588 win->_sync = bf;
589
590 return OK;
591}
592
593bool is_subwin(const WINDOW *win)
594{
595 PDC_LOG(("is_subwin() - called\n"));
596
597 if (!win)
598 return FALSE;
599
600 return ((win->_flags & _SUBWIN) ? TRUE : FALSE);
601}
602
603bool is_syncok(const WINDOW *win)
604{
605 PDC_LOG(("is_syncok() - called\n"));
606
607 if (!win)
608 return FALSE;
609
610 return win->_sync;
611}
612
613void wcursyncup(WINDOW *win)
614{
615 WINDOW *tmp;
616
617 PDC_LOG(("wcursyncup() - called\n"));
618
619 for (tmp = win; tmp && tmp->_parent; tmp = tmp->_parent)
620 wmove(tmp->_parent, tmp->_pary + tmp->_cury, tmp->_parx + tmp->_curx);
621}
622
623void wsyncdown(WINDOW *win)
624{
625 WINDOW *tmp;
626
627 PDC_LOG(("wsyncdown() - called\n"));
628
629 for (tmp = win; tmp; tmp = tmp->_parent)
630 {
631 if (is_wintouched(tmp))
632 {
633 touchwin(win);
634 break;
635 }
636 }
637}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 527f60c99..b88b89d2d 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -11,9 +11,9 @@
11#ifndef KBUILD_NO_NLS 11#ifndef KBUILD_NO_NLS
12# include <libintl.h> 12# include <libintl.h>
13#else 13#else
14# define gettext(Msgid) ((const char *) (Msgid)) 14static inline const char *gettext(const char *txt) { return txt; }
15# define textdomain(Domainname) ((const char *) (Domainname)) 15static inline void textdomain(const char *domainname) {}
16# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) 16static inline void bindtextdomain(const char *name, const char *dir) {}
17#endif 17#endif
18 18
19#ifdef __cplusplus 19#ifdef __cplusplus
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 5075ebf2d..a608d4c5e 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
@@ -47,7 +53,7 @@ trap "rm -f $tmp" 0 1 2 3 15
47check() { 53check() {
48 $cc -x c - -o $tmp 2>/dev/null <<'EOF' 54 $cc -x c - -o $tmp 2>/dev/null <<'EOF'
49#include CURSES_LOC 55#include CURSES_LOC
50main() {} 56int main() {}
51EOF 57EOF
52 if [ $? != 0 ]; then 58 if [ $? != 0 ]; then
53 echo " *** Unable to find the ncurses libraries or the" 1>&2 59 echo " *** Unable to find the ncurses libraries or the" 1>&2
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index af3cf716e..10a3292e1 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -24,6 +24,7 @@
24#include <ctype.h> 24#include <ctype.h>
25#include <stdlib.h> 25#include <stdlib.h>
26#include <string.h> 26#include <string.h>
27#include <strings.h>
27 28
28#ifdef __sun__ 29#ifdef __sun__
29#define CURS_MACROS 30#define CURS_MACROS
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index 072d3eecc..ea3ee4a95 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -138,6 +138,9 @@ void dialog_clear(void)
138 */ 138 */
139void init_dialog(void) 139void init_dialog(void)
140{ 140{
141 char *colors = getenv("COLORS");
142 use_colors = !(colors && *colors == '0');
143
141 initscr(); /* Init curses */ 144 initscr(); /* Init curses */
142 keypad(stdscr, TRUE); 145 keypad(stdscr, TRUE);
143 cbreak(); 146 cbreak();
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index aaf82820e..62baa82b0 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -12,8 +12,12 @@
12/* On Darwin, this may be needed to get SIGWINCH: */ 12/* On Darwin, this may be needed to get SIGWINCH: */
13#define _DARWIN_C_SOURCE 1 13#define _DARWIN_C_SOURCE 1
14 14
15#ifndef __MINGW32__
15#include <sys/ioctl.h> 16#include <sys/ioctl.h>
16#include <sys/wait.h> 17#include <sys/wait.h>
18#else
19#include <windows.h>
20#endif
17#include <ctype.h> 21#include <ctype.h>
18#include <errno.h> 22#include <errno.h>
19#include <fcntl.h> 23#include <fcntl.h>
@@ -23,13 +27,17 @@
23#include <stdlib.h> 27#include <stdlib.h>
24#include <string.h> 28#include <string.h>
25#include <strings.h> /* for strcasecmp */ 29#include <strings.h> /* for strcasecmp */
30#ifndef __MINGW32__
26#include <termios.h> 31#include <termios.h>
32#endif
27#include <unistd.h> 33#include <unistd.h>
28#include <locale.h> 34#include <locale.h>
29 35
36#ifndef __MINGW32__
30#ifndef SIGWINCH 37#ifndef SIGWINCH
31#define SIGWINCH 28 38#define SIGWINCH 28
32#endif 39#endif
40#endif
33 41
34#define LKC_DIRECT_LINK 42#define LKC_DIRECT_LINK
35#include "lkc.h" 43#include "lkc.h"
@@ -270,11 +278,15 @@ static char input_buf[4096];
270static const char filename[] = ".config"; 278static const char filename[] = ".config";
271static char *args[1024], **argptr = args; 279static char *args[1024], **argptr = args;
272static int indent; 280static int indent;
281#ifndef __MINGW32__
273static struct termios ios_org; 282static struct termios ios_org;
283#endif
274static int rows = 0, cols = 0; 284static int rows = 0, cols = 0;
275static struct menu *current_menu; 285static struct menu *current_menu;
276static int child_count; 286static int child_count;
287#ifndef __MINGW32__
277static int do_resize; 288static int do_resize;
289#endif
278static int single_menu_mode; 290static int single_menu_mode;
279 291
280static void conf(struct menu *menu); 292static void conf(struct menu *menu);
@@ -292,12 +304,45 @@ static int cprint1(const char *fmt, ...);
292static void cprint_done(void); 304static void cprint_done(void);
293static int cprint(const char *fmt, ...); 305static int cprint(const char *fmt, ...);
294 306
307#ifdef __MINGW32__
308struct winsize {
309 unsigned short ws_row, ws_col;
310 unsigned short ws_xpixel, ws_ypixel;
311};
312
313static int mingw_get_terminal_width_height(struct winsize *win)
314{
315 int fd;
316 HANDLE handle;
317 CONSOLE_SCREEN_BUFFER_INFO sbi;
318
319 win->ws_row = 0;
320 win->ws_col = 0;
321
322 for (fd=STDOUT_FILENO; fd<=STDERR_FILENO; ++fd) {
323 handle = (HANDLE)_get_osfhandle(fd);
324 if (handle != INVALID_HANDLE_VALUE &&
325 GetConsoleScreenBufferInfo(handle, &sbi) != 0) {
326 win->ws_row = sbi.srWindow.Bottom - sbi.srWindow.Top + 1;
327 win->ws_col = sbi.srWindow.Right - sbi.srWindow.Left + 1;
328 return 0;
329 }
330 }
331
332 return -1;
333}
334#endif
335
295static void init_wsize(void) 336static void init_wsize(void)
296{ 337{
297 struct winsize ws; 338 struct winsize ws;
298 char *env; 339 char *env;
299 340
341#ifndef __MINGW32__
300 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { 342 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
343#else
344 if (mingw_get_terminal_width_height(&ws) == 0) {
345#endif
301 rows = ws.ws_row; 346 rows = ws.ws_row;
302 cols = ws.ws_col; 347 cols = ws.ws_col;
303 } 348 }
@@ -459,8 +504,198 @@ static void winch_handler(int sig)
459} 504}
460#endif 505#endif
461 506
507#ifdef __MINGW32__
508static char *
509quote_arg(const char *arg)
510{
511 int len = 0, n = 0;
512 int force_quotes = 0;
513 char *q, *d;
514 const char *p = arg;
515
516 /* empty arguments must be quoted */
517 if (!*p) {
518 force_quotes = 1;
519 }
520
521 while (*p) {
522 if (isspace(*p)) {
523 /* arguments containing whitespace must be quoted */
524 force_quotes = 1;
525 }
526 else if (*p == '"') {
527 /* double quotes in arguments need to be escaped */
528 n++;
529 }
530 else if (*p == '\\') {
531 /* count contiguous backslashes */
532 int count = 0;
533 while (*p == '\\') {
534 count++;
535 p++;
536 len++;
537 }
538
539 /*
540 * Only escape backslashes before explicit double quotes or
541 * or where the backslashes are at the end of an argument
542 * that is scheduled to be quoted.
543 */
544 if (*p == '"' || (force_quotes && *p == '\0')) {
545 n += count*2 + 1;
546 }
547
548 if (*p == '\0') {
549 break;
550 }
551 continue;
552 }
553 len++;
554 p++;
555 }
556
557 if (!force_quotes && n == 0) {
558 return (char*)strdup(arg);
559 }
560
561 /* insert double quotes and backslashes where necessary */
562 d = q = malloc(len+n+3);
563 if (q == NULL)
564 return NULL;
565 if (force_quotes) {
566 *d++ = '"';
567 }
568
569 while (*arg) {
570 if (*arg == '"') {
571 *d++ = '\\';
572 }
573 else if (*arg == '\\') {
574 int count = 0;
575 while (*arg == '\\') {
576 count++;
577 *d++ = *arg++;
578 }
579
580 if (*arg == '"' || (force_quotes && *arg == '\0')) {
581 while (count-- > 0) {
582 *d++ = '\\';
583 }
584 if (*arg == '"') {
585 *d++ = '\\';
586 }
587 }
588 }
589 if (*arg != '\0') {
590 *d++ = *arg++;
591 }
592 }
593 if (force_quotes) {
594 *d++ = '"';
595 }
596 *d = '\0';
597
598 return q;
599}
600
601static int mingw_pipe(HANDLE *pipe)
602{
603 SECURITY_ATTRIBUTES sa;
604
605 sa.nLength = sizeof(sa); /* Length in bytes */
606 sa.bInheritHandle = 1; /* the child must inherit these handles */
607 sa.lpSecurityDescriptor = NULL;
608
609 /* pipe[0] is the read handle, pipe[i] the write handle */
610 if ( !CreatePipe (&pipe[0], &pipe[1], &sa, 1 << 13) ) {
611 return -1;
612 }
613
614 return (pipe[0] == INVALID_HANDLE_VALUE ||
615 pipe[1] == INVALID_HANDLE_VALUE) ? -1 : 0;
616}
617#endif
618
462static int exec_conf(void) 619static int exec_conf(void)
463{ 620{
621#ifdef __MINGW32__
622 char **a, *cmd;
623 int fd, size, len = 0;
624 STARTUPINFO siStartInfo;
625 PROCESS_INFORMATION piProcInfo;
626 HANDLE hPipe[2];
627 DWORD stat = 0;
628
629 // Quote each argument if necessary
630 *argptr++ = NULL;
631 for (a = args; *a; a++) {
632 *a = quote_arg(*a);
633 if (*a == NULL)
634 _exit(EXIT_FAILURE);
635 len += strlen(*a) + 1;
636 }
637
638 // Make a command line from the arguments
639 cmd = malloc(len + 1);
640 if (cmd == NULL)
641 _exit(EXIT_FAILURE);
642 for (a = args; *a; a++) {
643 if (a == args) {
644 strcpy(cmd, *a);
645 } else {
646 strcat(cmd, " ");
647 strcat(cmd, *a);
648 }
649 free(*a);
650 }
651
652 // Create a pipe to communicate with the dialog
653 if (mingw_pipe(hPipe) == -1)
654 _exit(EXIT_FAILURE);
655
656 // Make the parent end of the pipe non-inheritable
657 SetHandleInformation(hPipe[0], HANDLE_FLAG_INHERIT, 0);
658
659 ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
660 siStartInfo.cb = sizeof(STARTUPINFO);
661 siStartInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
662 siStartInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
663 siStartInfo.hStdError = hPipe[1];
664 siStartInfo.dwFlags = STARTF_USESTDHANDLES;
665 CreateProcess(NULL, (LPSTR)cmd, NULL, NULL, TRUE, 0, NULL, NULL,
666 &siStartInfo, &piProcInfo);
667 free(cmd);
668
669 // Close child end of pipe
670 CloseHandle(hPipe[1]);
671 hPipe[1] = INVALID_HANDLE_VALUE;
672
673 fd = _open_osfhandle((intptr_t)hPipe[0], _O_RDONLY | _O_BINARY);
674 if (fd == -1)
675 _exit(EXIT_FAILURE);
676
677 bufptr = input_buf;
678 while (1) {
679 size = input_buf + sizeof(input_buf) - bufptr;
680 size = _read(fd, bufptr, size);
681 if (size <= 0) {
682 if (size < 0) {
683 if (errno == EINTR || errno == EAGAIN)
684 continue;
685 perror("read");
686 }
687 break;
688 }
689 bufptr += size;
690 }
691 *bufptr++ = 0;
692 close(fd);
693
694 WaitForSingleObject(piProcInfo.hProcess, INFINITE);
695 GetExitCodeProcess(piProcInfo.hProcess, &stat);
696
697 return (int)(stat &0xff);
698#else
464 int pipefd[2], stat, size; 699 int pipefd[2], stat, size;
465 sigset_t sset, osset; 700 sigset_t sset, osset;
466 701
@@ -535,6 +770,7 @@ static int exec_conf(void)
535 sigprocmask(SIG_SETMASK, &osset, NULL); 770 sigprocmask(SIG_SETMASK, &osset, NULL);
536 771
537 return WEXITSTATUS(stat); 772 return WEXITSTATUS(stat);
773#endif
538} 774}
539 775
540static void search_conf(void) 776static void search_conf(void)
@@ -788,7 +1024,7 @@ static void conf(struct menu *menu)
788 switch (type) { 1024 switch (type) {
789 case 'm': 1025 case 'm':
790 if (single_menu_mode) 1026 if (single_menu_mode)
791 submenu->data = (void *) (long) !submenu->data; 1027 submenu->data = (void *) (intptr_t) !submenu->data;
792 else 1028 else
793 conf(submenu); 1029 conf(submenu);
794 break; 1030 break;
@@ -1051,7 +1287,9 @@ static void conf_save(void)
1051 1287
1052static void conf_cleanup(void) 1288static void conf_cleanup(void)
1053{ 1289{
1290#ifndef __MINGW32__
1054 tcsetattr(1, TCSAFLUSH, &ios_org); 1291 tcsetattr(1, TCSAFLUSH, &ios_org);
1292#endif
1055 unlink(".help.tmp"); 1293 unlink(".help.tmp");
1056 unlink("lxdialog.scrltmp"); 1294 unlink("lxdialog.scrltmp");
1057} 1295}
@@ -1080,7 +1318,9 @@ int main(int ac, char **av)
1080 single_menu_mode = 1; 1318 single_menu_mode = 1;
1081 } 1319 }
1082 1320
1321#ifndef __MINGW32__
1083 tcgetattr(1, &ios_org); 1322 tcgetattr(1, &ios_org);
1323#endif
1084 atexit(conf_cleanup); 1324 atexit(conf_cleanup);
1085 init_wsize(); 1325 init_wsize();
1086 conf(&rootmenu); 1326 conf(&rootmenu);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 3d7877afc..31d5fbbfc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -6,8 +6,10 @@
6#include <ctype.h> 6#include <ctype.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h> 8#include <string.h>
9#ifndef __MINGW32__
9#include <regex.h> 10#include <regex.h>
10#include <sys/utsname.h> 11#include <sys/utsname.h>
12#endif
11 13
12#define LKC_DIRECT_LINK 14#define LKC_DIRECT_LINK
13#include "lkc.h" 15#include "lkc.h"
@@ -44,7 +46,9 @@ void sym_add_default(struct symbol *sym, const char *def)
44void sym_init(void) 46void sym_init(void)
45{ 47{
46 struct symbol *sym; 48 struct symbol *sym;
49#ifndef __MINGW32__
47 struct utsname uts; 50 struct utsname uts;
51#endif
48 char *p; 52 char *p;
49 static bool inited = false; 53 static bool inited = false;
50 54
@@ -52,7 +56,9 @@ void sym_init(void)
52 return; 56 return;
53 inited = true; 57 inited = true;
54 58
59#ifndef __MINGW32__
55 uname(&uts); 60 uname(&uts);
61#endif
56 62
57 sym = sym_lookup("ARCH", 0); 63 sym = sym_lookup("ARCH", 0);
58 sym->type = S_STRING; 64 sym->type = S_STRING;
@@ -71,7 +77,11 @@ void sym_init(void)
71 sym = sym_lookup("UNAME_RELEASE", 0); 77 sym = sym_lookup("UNAME_RELEASE", 0);
72 sym->type = S_STRING; 78 sym->type = S_STRING;
73 sym->flags |= SYMBOL_AUTO; 79 sym->flags |= SYMBOL_AUTO;
80#ifdef __MINGW32__
81 sym_add_default(sym, "UNKNOWN");
82#else
74 sym_add_default(sym, uts.release); 83 sym_add_default(sym, uts.release);
84#endif
75} 85}
76 86
77enum symbol_type sym_get_type(struct symbol *sym) 87enum symbol_type sym_get_type(struct symbol *sym)
@@ -718,24 +728,43 @@ struct symbol *sym_find(const char *name)
718 return symbol; 728 return symbol;
719} 729}
720 730
731#if !defined HAVE_RE && !defined __MINGW32__
732#define HAVE_RE 1
733#endif
734
721struct symbol **sym_re_search(const char *pattern) 735struct symbol **sym_re_search(const char *pattern)
722{ 736{
723 struct symbol *sym, **sym_arr = NULL; 737 struct symbol *sym, **sym_arr = NULL;
724 int i, cnt, size; 738 int i, cnt, size;
739#if HAVE_RE
725 regex_t re; 740 regex_t re;
741#else
742 /* without re support use: strstr(sym->name, upper(pattern)) */
743 /* sym->name is a config, e.g. "SHELL_ASH" or "FEATURE_UTMP" */
744 char upat[256] = {0};
745 for (i = 0; i < 255 && pattern[i]; ++i)
746 upat[i] = toupper(pattern[i]);
747#endif
726 748
727 cnt = size = 0; 749 cnt = size = 0;
728 /* Skip if empty */ 750 /* Skip if empty */
729 if (strlen(pattern) == 0) 751 if (strlen(pattern) == 0)
730 return NULL; 752 return NULL;
753#if HAVE_RE
731 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) 754 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
732 return NULL; 755 return NULL;
756#endif
733 757
734 for_all_symbols(i, sym) { 758 for_all_symbols(i, sym) {
735 if (sym->flags & SYMBOL_CONST || !sym->name) 759 if (sym->flags & SYMBOL_CONST || !sym->name)
736 continue; 760 continue;
761#if HAVE_RE
737 if (regexec(&re, sym->name, 0, NULL, 0)) 762 if (regexec(&re, sym->name, 0, NULL, 0))
738 continue; 763 continue;
764#else
765 if (!strstr(sym->name, upat))
766 continue;
767#endif
739 if (cnt + 1 >= size) { 768 if (cnt + 1 >= size) {
740 void *tmp = sym_arr; 769 void *tmp = sym_arr;
741 size += 16; 770 size += 16;
@@ -749,7 +778,9 @@ struct symbol **sym_re_search(const char *pattern)
749 } 778 }
750 if (sym_arr) 779 if (sym_arr)
751 sym_arr[cnt] = NULL; 780 sym_arr[cnt] = NULL;
781#if HAVE_RE
752 regfree(&re); 782 regfree(&re);
783#endif
753 784
754 return sym_arr; 785 return sym_arr;
755} 786}
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
index 29d9cf6cc..6996aba7f 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -161,43 +161,43 @@ kconf_id_lookup (register const char *str, register unsigned int len)
161 static struct kconf_id wordlist[] = 161 static struct kconf_id wordlist[] =
162 { 162 {
163 {-1}, {-1}, 163 {-1}, {-1},
164 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM}, 164 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
165 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT}, 165 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
166 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str4, T_HELP, TF_COMMAND}, 166 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str4, T_HELP, TF_COMMAND},
167 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, 167 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
168 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_SELECT, TF_COMMAND}, 168 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_SELECT, TF_COMMAND},
169 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND}, 169 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
170 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE}, 170 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
171 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, 171 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
172 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND}, 172 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND},
173 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_TYPE, TF_COMMAND, S_STRING}, 173 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_TYPE, TF_COMMAND, S_STRING},
174 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, 174 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
175 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, 175 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
176 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_MENU, TF_COMMAND}, 176 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_MENU, TF_COMMAND},
177 {-1}, 177 {-1},
178 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, 178 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
179 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, 179 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
180 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_MAINMENU, TF_COMMAND}, 180 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_MAINMENU, TF_COMMAND},
181 {-1}, 181 {-1},
182 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_MENUCONFIG, TF_COMMAND}, 182 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_MENUCONFIG, TF_COMMAND},
183 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_CONFIG, TF_COMMAND}, 183 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_CONFIG, TF_COMMAND},
184 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ON, TF_PARAM}, 184 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ON, TF_PARAM},
185 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_HEX}, 185 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_HEX},
186 {-1}, {-1}, 186 {-1}, {-1},
187 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SOURCE, TF_COMMAND}, 187 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SOURCE, TF_COMMAND},
188 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_DEPENDS, TF_COMMAND}, 188 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_DEPENDS, TF_COMMAND},
189 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPTIONAL, TF_COMMAND}, 189 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPTIONAL, TF_COMMAND},
190 {-1}, {-1}, 190 {-1}, {-1},
191 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND}, 191 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
192 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, 192 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
193 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_REQUIRES, TF_COMMAND}, 193 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_REQUIRES, TF_COMMAND},
194 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_TYPE, TF_COMMAND, S_BOOLEAN}, 194 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_TYPE, TF_COMMAND, S_BOOLEAN},
195 {-1}, {-1}, 195 {-1}, {-1},
196 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_TYPE, TF_COMMAND, S_BOOLEAN}, 196 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_TYPE, TF_COMMAND, S_BOOLEAN},
197 {-1}, {-1}, {-1}, 197 {-1}, {-1}, {-1},
198 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_CHOICE, TF_COMMAND}, 198 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_CHOICE, TF_COMMAND},
199 {-1}, {-1}, {-1}, {-1}, 199 {-1}, {-1}, {-1}, {-1},
200 {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_PROMPT, TF_COMMAND} 200 {(int)(intptr_t)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_PROMPT, TF_COMMAND}
201 }; 201 };
202 202
203 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 203 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index a27d256d6..863f375be 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -143,6 +143,7 @@
143#include <stdarg.h> 143#include <stdarg.h>
144#include <stdio.h> 144#include <stdio.h>
145#include <stdlib.h> 145#include <stdlib.h>
146#include <stdint.h>
146#include <string.h> 147#include <string.h>
147#include <stdbool.h> 148#include <stdbool.h>
148 149