curses 1.2.7 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -0
  3. data/.github/workflows/ubuntu.yml +26 -0
  4. data/.github/workflows/windows.yml +25 -0
  5. data/.gitmodules +1 -1
  6. data/History.md +41 -0
  7. data/README.md +14 -46
  8. data/Rakefile +0 -83
  9. data/curses.gemspec +2 -3
  10. data/ext/curses/curses.c +1314 -176
  11. data/ext/curses/extconf.rb +140 -17
  12. data/lib/curses.rb +5 -12
  13. data/sample/form.rb +52 -0
  14. data/sample/menu.rb +1 -1
  15. data/vendor/PDCurses/.gitignore +47 -0
  16. data/vendor/PDCurses/.travis.yml +49 -0
  17. data/vendor/PDCurses/CMakeLists.txt +68 -0
  18. data/vendor/PDCurses/HISTORY.md +2036 -0
  19. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  20. data/vendor/PDCurses/README.md +77 -0
  21. data/vendor/PDCurses/acs_defs.h +265 -0
  22. data/vendor/PDCurses/appveyor.yml +218 -0
  23. data/vendor/PDCurses/cmake/README.md +71 -0
  24. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  25. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  26. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  27. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  28. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  29. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  30. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  31. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  32. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  33. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  34. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  35. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  36. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  37. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  38. data/vendor/PDCurses/curses.h +1846 -0
  39. data/vendor/PDCurses/curspriv.h +134 -0
  40. data/vendor/PDCurses/demos/README.md +25 -0
  41. data/vendor/PDCurses/demos/firework.c +144 -0
  42. data/vendor/PDCurses/demos/newtest.c +581 -0
  43. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  44. data/vendor/PDCurses/demos/ptest.c +283 -0
  45. data/vendor/PDCurses/demos/rain.c +157 -0
  46. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  47. data/vendor/PDCurses/demos/tui.c +1048 -0
  48. data/vendor/PDCurses/demos/tui.h +65 -0
  49. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  50. data/vendor/PDCurses/demos/version.c +61 -0
  51. data/vendor/PDCurses/demos/worm.c +432 -0
  52. data/vendor/PDCurses/demos/xmas.c +955 -0
  53. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  54. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  55. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  56. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  57. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  58. data/vendor/PDCurses/dos/README.md +51 -0
  59. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  60. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  61. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  62. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  63. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  64. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  65. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  66. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  67. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  68. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  69. data/vendor/PDCurses/libobjs.mif +26 -0
  70. data/vendor/PDCurses/makedist.mif +20 -0
  71. data/vendor/PDCurses/man/README.md +21 -0
  72. data/vendor/PDCurses/man/intro.md +361 -0
  73. data/vendor/PDCurses/man/manext.c +119 -0
  74. data/vendor/PDCurses/man/sdl.md +152 -0
  75. data/vendor/PDCurses/man/sdl2.md +58 -0
  76. data/vendor/PDCurses/man/x11.md +407 -0
  77. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  78. data/vendor/PDCurses/ncurses/README.md +26 -0
  79. data/vendor/PDCurses/ncurses/makefile +29 -0
  80. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  81. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  82. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  83. data/vendor/PDCurses/os2/README.md +43 -0
  84. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  85. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  86. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  87. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  88. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  89. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  90. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  91. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  92. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  93. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  94. data/vendor/PDCurses/panel.h +56 -0
  95. data/vendor/PDCurses/pdcurses/README.md +25 -0
  96. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  97. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  98. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  99. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  100. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  101. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  102. data/vendor/PDCurses/pdcurses/border.c +411 -0
  103. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  104. data/vendor/PDCurses/pdcurses/color.c +298 -0
  105. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  106. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  107. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  108. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  109. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  110. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  111. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  112. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  113. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  114. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  115. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  116. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  117. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  118. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  119. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  120. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  121. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  122. data/vendor/PDCurses/pdcurses/move.c +57 -0
  123. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  124. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  125. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  126. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  127. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  128. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  129. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  130. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  131. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  132. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  133. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  134. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  135. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  136. data/vendor/PDCurses/pdcurses/util.c +312 -0
  137. data/vendor/PDCurses/pdcurses/window.c +569 -0
  138. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  139. data/vendor/PDCurses/sdl1/README.md +31 -0
  140. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  141. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  142. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  143. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  144. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  145. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  146. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  147. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  148. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  149. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  150. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  151. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  152. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  153. data/vendor/PDCurses/sdl2/README.md +34 -0
  154. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  155. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  156. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  157. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  158. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  159. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  160. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  161. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  162. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  163. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  164. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  165. data/vendor/PDCurses/term.h +48 -0
  166. data/vendor/PDCurses/version.mif +7 -0
  167. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  168. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  169. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  170. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  171. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  172. data/vendor/PDCurses/vt/README.md +64 -0
  173. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  174. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  175. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  176. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  177. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  178. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  179. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  180. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  181. data/vendor/PDCurses/watcom.mif +68 -0
  182. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  183. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  184. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  185. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  186. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  187. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  188. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  189. data/vendor/PDCurses/wincon/README.md +85 -0
  190. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  191. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  192. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  193. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  194. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  195. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  196. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  197. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  198. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  199. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  200. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  201. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  202. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  203. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  204. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  205. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  206. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  207. data/vendor/PDCurses/wingui/README.md +93 -0
  208. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  209. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  210. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  211. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  212. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  213. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  214. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  215. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  216. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  217. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  218. data/vendor/PDCurses/x11/Makefile.in +754 -0
  219. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  220. data/vendor/PDCurses/x11/README.md +62 -0
  221. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  222. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  223. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  224. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  225. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  226. data/vendor/PDCurses/x11/compose.h +201 -0
  227. data/vendor/PDCurses/x11/config.guess +1500 -0
  228. data/vendor/PDCurses/x11/config.h.in +100 -0
  229. data/vendor/PDCurses/x11/config.sub +1616 -0
  230. data/vendor/PDCurses/x11/configure +6700 -0
  231. data/vendor/PDCurses/x11/configure.ac +295 -0
  232. data/vendor/PDCurses/x11/debian/changelog +6 -0
  233. data/vendor/PDCurses/x11/debian/compat +1 -0
  234. data/vendor/PDCurses/x11/debian/control +11 -0
  235. data/vendor/PDCurses/x11/debian/copyright +27 -0
  236. data/vendor/PDCurses/x11/debian/rules +98 -0
  237. data/vendor/PDCurses/x11/install-sh +253 -0
  238. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  239. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  240. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  241. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  242. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  243. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  244. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  245. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  246. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  247. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  248. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  249. data/vendor/PDCurses/x11/sb.c +155 -0
  250. data/vendor/PDCurses/x11/x11.c +3686 -0
  251. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  252. metadata +255 -24
  253. data/.travis.yml +0 -13
  254. data/appveyor.yml +0 -16
@@ -0,0 +1,157 @@
1
+ /****************************************************************************
2
+ * Copyright (c) 2002 Free Software Foundation, Inc. *
3
+ * *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a *
5
+ * copy of this software and associated documentation files (the *
6
+ * "Software"), to deal in the Software without restriction, including *
7
+ * without limitation the rights to use, copy, modify, merge, publish, *
8
+ * distribute, distribute with modifications, sublicense, and/or sell *
9
+ * copies of the Software, and to permit persons to whom the Software is *
10
+ * furnished to do so, subject to the following conditions: *
11
+ * *
12
+ * The above copyright notice and this permission notice shall be included *
13
+ * in all copies or substantial portions of the Software. *
14
+ * *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22
+ * *
23
+ * Except as contained in this notice, the name(s) of the above copyright *
24
+ * holders shall not be used in advertising or otherwise to promote the *
25
+ * sale, use or other dealings in this Software without prior written *
26
+ * authorization. *
27
+ ****************************************************************************/
28
+
29
+ #include <curses.h>
30
+ #include <stdlib.h>
31
+ #include <time.h>
32
+
33
+ /* rain 11/3/1980 EPS/CITHEP */
34
+
35
+ static int next_j(int j)
36
+ {
37
+ if (j == 0)
38
+ j = 4;
39
+ else
40
+ --j;
41
+
42
+ if (has_colors())
43
+ {
44
+ int z = rand() % 3;
45
+ chtype color = COLOR_PAIR(z);
46
+
47
+ if (z)
48
+ color |= A_BOLD;
49
+
50
+ attrset(color);
51
+ }
52
+
53
+ return j;
54
+ }
55
+
56
+ int main(int argc, char *argv[])
57
+ {
58
+ int x, y, j, r, c, seed;
59
+ static int xpos[5], ypos[5];
60
+
61
+ #ifdef XCURSES
62
+ Xinitscr(argc, argv);
63
+ #else
64
+ initscr();
65
+ #endif
66
+ seed = (int)time((time_t *)0);
67
+ srand(seed);
68
+
69
+ if (has_colors())
70
+ {
71
+ short bg = COLOR_BLACK;
72
+
73
+ start_color();
74
+
75
+ #if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
76
+ if (use_default_colors() == OK)
77
+ bg = -1;
78
+ #endif
79
+ init_pair(1, COLOR_BLUE, bg);
80
+ init_pair(2, COLOR_CYAN, bg);
81
+ }
82
+
83
+ nl();
84
+ noecho();
85
+ curs_set(0);
86
+ timeout(0);
87
+ keypad(stdscr, TRUE);
88
+
89
+ r = LINES - 4;
90
+ c = COLS - 4;
91
+
92
+ for (j = 5; --j >= 0;)
93
+ {
94
+ xpos[j] = rand() % c + 2;
95
+ ypos[j] = rand() % r + 2;
96
+ }
97
+
98
+ for (j = 0;;)
99
+ {
100
+ x = rand() % c + 2;
101
+ y = rand() % r + 2;
102
+
103
+ mvaddch(y, x, '.');
104
+
105
+ mvaddch(ypos[j], xpos[j], 'o');
106
+
107
+ j = next_j(j);
108
+ mvaddch(ypos[j], xpos[j], 'O');
109
+
110
+ j = next_j(j);
111
+ mvaddch(ypos[j] - 1, xpos[j], '-');
112
+ mvaddstr(ypos[j], xpos[j] - 1, "|.|");
113
+ mvaddch(ypos[j] + 1, xpos[j], '-');
114
+
115
+ j = next_j(j);
116
+ mvaddch(ypos[j] - 2, xpos[j], '-');
117
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
118
+ mvaddstr(ypos[j], xpos[j] - 2, "| O |");
119
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
120
+ mvaddch(ypos[j] + 2, xpos[j], '-');
121
+
122
+ j = next_j(j);
123
+ mvaddch(ypos[j] - 2, xpos[j], ' ');
124
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
125
+ mvaddstr(ypos[j], xpos[j] - 2, " ");
126
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
127
+ mvaddch(ypos[j] + 2, xpos[j], ' ');
128
+
129
+ xpos[j] = x;
130
+ ypos[j] = y;
131
+
132
+ switch (getch())
133
+ {
134
+ case 'q':
135
+ case 'Q':
136
+ curs_set(1);
137
+ endwin();
138
+ return EXIT_SUCCESS;
139
+ case 's':
140
+ nodelay(stdscr, FALSE);
141
+ break;
142
+ case ' ':
143
+ nodelay(stdscr, TRUE);
144
+ #ifdef KEY_RESIZE
145
+ break;
146
+ case KEY_RESIZE:
147
+ # ifdef PDCURSES
148
+ resize_term(0, 0);
149
+ erase();
150
+ # endif
151
+ r = LINES - 4;
152
+ c = COLS - 4;
153
+ #endif
154
+ }
155
+ napms(50);
156
+ }
157
+ }
@@ -0,0 +1,1607 @@
1
+ /*
2
+ * This is a test program for PDCurses. Originally by
3
+ * John Burnell <johnb@kea.am.dsir.govt.nz>
4
+ *
5
+ * wrs(5/28/93) -- modified to be consistent (perform identically)
6
+ * with either PDCurses or under Unix System V, R4
7
+ */
8
+
9
+ #ifndef _XOPEN_SOURCE_EXTENDED
10
+ # define _XOPEN_SOURCE_EXTENDED 1
11
+ #endif
12
+
13
+ #ifdef HAVE_NCURSESW
14
+ #define HAVE_WIDE 1
15
+ #include <wchar.h>
16
+ #include <ncursesw/curses.h>
17
+ #endif
18
+ #ifdef PDC_WIDE
19
+ #define HAVE_WIDE 1
20
+ #include <wchar.h>
21
+ #include <curses.h>
22
+ #endif
23
+
24
+ #ifndef HAVE_WIDE
25
+ #include <curses.h>
26
+ #define HAVE_WIDE 0
27
+ #endif
28
+
29
+ #include <stdio.h>
30
+ #include <stdlib.h>
31
+ #include <ctype.h>
32
+ #include <string.h>
33
+ #include <locale.h>
34
+
35
+ #if defined( PDCURSES)
36
+ #define getmouse nc_getmouse
37
+ #else
38
+ #define NCURSES_MOUSE_INTERFACE
39
+ #endif
40
+
41
+
42
+ #if defined(PDCURSES) && !defined(XCURSES)
43
+ # define HAVE_RESIZE 1
44
+ #else
45
+ # define HAVE_RESIZE 0
46
+ #endif
47
+
48
+ #ifdef A_COLOR
49
+ # define HAVE_COLOR 1
50
+ #else
51
+ # define HAVE_COLOR 0
52
+ #endif
53
+
54
+ /* Set to non-zero if you want to test the PDCurses clipboard */
55
+ /* (obviously, can't do that with ncurses) */
56
+
57
+ #if defined( PDCURSES)
58
+ #define HAVE_CLIPBOARD 1
59
+ #else
60
+ #define HAVE_CLIPBOARD 0
61
+ #endif
62
+
63
+ void inputTest(WINDOW *);
64
+ void scrollTest(WINDOW *);
65
+ void introTest(WINDOW *);
66
+ int initTest(WINDOW **, int, char **);
67
+ void outputTest(WINDOW *);
68
+ void padTest(WINDOW *);
69
+ void acsTest(WINDOW *);
70
+
71
+ #if HAVE_COLOR
72
+ void colorTest(WINDOW *);
73
+ #endif
74
+
75
+ #if HAVE_RESIZE
76
+ void resizeTest(WINDOW *);
77
+ #endif
78
+
79
+ #if HAVE_CLIPBOARD
80
+ void clipboardTest(WINDOW *);
81
+ #endif
82
+
83
+ #if HAVE_WIDE
84
+ void wideTest(WINDOW *);
85
+ #endif
86
+
87
+ void display_menu(int, int);
88
+
89
+ struct commands
90
+ {
91
+ const char *text;
92
+ void (*function)(WINDOW *);
93
+ };
94
+
95
+ typedef struct commands COMMAND;
96
+
97
+ #define MAX_OPTIONS (6 + HAVE_COLOR + HAVE_RESIZE + HAVE_CLIPBOARD + HAVE_WIDE)
98
+
99
+ COMMAND command[MAX_OPTIONS] =
100
+ {
101
+ {"Intro Test", introTest},
102
+ {"Pad Test", padTest},
103
+ #if HAVE_RESIZE
104
+ {"Resize Test", resizeTest},
105
+ #endif
106
+ {"Scroll Test", scrollTest},
107
+ {"Input Test", inputTest},
108
+ {"Output Test", outputTest},
109
+ {"ACS Test", acsTest},
110
+ #if HAVE_COLOR
111
+ {"Color Test", colorTest},
112
+ #endif
113
+ #if HAVE_CLIPBOARD
114
+ {"Clipboard Test", clipboardTest},
115
+ #endif
116
+ #if HAVE_WIDE
117
+ {"Wide Input", wideTest}
118
+ #endif
119
+ };
120
+
121
+ int width, height;
122
+ static short background_index = COLOR_BLACK;
123
+ static bool report_mouse_movement = FALSE;
124
+
125
+ int main(int argc, char *argv[])
126
+ {
127
+ WINDOW *win;
128
+ int key, old_option = -1, new_option = 0, i;
129
+ bool quit = FALSE;
130
+
131
+ setlocale(LC_ALL, "");
132
+
133
+ #ifdef PDCURSES
134
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
135
+ PDC_set_resize_limits( 20, 50, 70, 200);
136
+ #endif
137
+ #endif
138
+
139
+ if (initTest(&win, argc, argv))
140
+ return 1;
141
+
142
+ for( i = 1; i < argc; i++)
143
+ if( argv[i][0] == '-')
144
+ switch( argv[i][1])
145
+ {
146
+ case 'l': case 'L':
147
+ setlocale( LC_ALL, argv[i] + 2);
148
+ break;
149
+ case 'i': case 'I':
150
+ background_index = (short)atoi( argv[i] + 2);
151
+ break;
152
+ #ifdef PDCURSES
153
+ case 'b': case 'B':
154
+ PDC_set_blink( TRUE);
155
+ break;
156
+ case 'm': case 'M':
157
+ PDC_return_key_modifiers( TRUE);
158
+ break;
159
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
160
+ case 'r': /* allow user-resizable windows */
161
+ {
162
+ int min_lines, max_lines, min_cols, max_cols;
163
+
164
+ if( sscanf( argv[i] + 2, "%d,%d,%d,%d",
165
+ &min_lines, &max_lines,
166
+ &min_cols, &max_cols) == 4)
167
+ PDC_set_resize_limits( min_lines, max_lines,
168
+ min_cols, max_cols);
169
+ }
170
+ break;
171
+ #endif
172
+ #endif
173
+ case 'z':
174
+ report_mouse_movement = TRUE;
175
+ break;
176
+ default:
177
+ break;
178
+ }
179
+
180
+ #ifdef A_COLOR
181
+ if (has_colors())
182
+ {
183
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
184
+ wbkgd(win, COLOR_PAIR(1));
185
+ }
186
+ else
187
+ #endif
188
+ wbkgd(win, A_REVERSE);
189
+
190
+ #ifdef PDCURSES
191
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
192
+ PDC_set_function_key( FUNCTION_KEY_ABORT, 3 ); /* ctrl-C aborts */
193
+ #endif
194
+ #endif
195
+
196
+ erase();
197
+ display_menu(old_option, new_option);
198
+
199
+ while (1)
200
+ {
201
+ bool run_option = FALSE;
202
+
203
+ noecho();
204
+ keypad(stdscr, TRUE);
205
+ raw();
206
+ #ifdef PDCURSES
207
+ mouse_set( ALL_MOUSE_EVENTS);
208
+ #else
209
+ mousemask( ALL_MOUSE_EVENTS, NULL);
210
+ #endif
211
+
212
+ key = getch();
213
+
214
+ switch(key)
215
+ {
216
+ case KEY_MOUSE:
217
+ {
218
+ const int tmarg = (LINES - (MAX_OPTIONS + 2)) / 2;
219
+ int selected_opt;
220
+ MEVENT mouse_event;
221
+
222
+ getmouse( &mouse_event);
223
+ #if defined( BUTTON4_PRESSED) && defined( BUTTON5_PRESSED)
224
+ if( mouse_event.bstate & BUTTON4_PRESSED)
225
+ selected_opt = new_option - 1; /* wheel up */
226
+ else if( mouse_event.bstate & BUTTON5_PRESSED)
227
+ selected_opt = new_option + 1; /* wheel down */
228
+ else
229
+ #endif
230
+ selected_opt = mouse_event.y - tmarg;
231
+ if( selected_opt >= 0 && selected_opt < MAX_OPTIONS)
232
+ {
233
+ old_option = new_option;
234
+ new_option = selected_opt;
235
+ display_menu( old_option, new_option);
236
+ }
237
+ if( mouse_event.bstate & BUTTON1_DOUBLE_CLICKED)
238
+ run_option = TRUE;
239
+ }
240
+ break;
241
+ case 10:
242
+ case 13:
243
+ case KEY_ENTER:
244
+ run_option = TRUE;
245
+ break;
246
+
247
+ case KEY_PPAGE:
248
+ case KEY_HOME:
249
+ old_option = new_option;
250
+ new_option = 0;
251
+ display_menu(old_option, new_option);
252
+ break;
253
+
254
+ case KEY_NPAGE:
255
+ case KEY_END:
256
+ old_option = new_option;
257
+ new_option = MAX_OPTIONS - 1;
258
+ display_menu(old_option, new_option);
259
+ break;
260
+
261
+ case KEY_UP:
262
+ old_option = new_option;
263
+ new_option = (new_option == 0) ?
264
+ new_option : new_option - 1;
265
+ display_menu(old_option, new_option);
266
+ break;
267
+
268
+ case KEY_DOWN:
269
+ old_option = new_option;
270
+ new_option = (new_option == MAX_OPTIONS - 1) ?
271
+ new_option : new_option + 1;
272
+ display_menu(old_option, new_option);
273
+ break;
274
+ case KEY_RESIZE:
275
+ # ifdef PDCURSES
276
+ resize_term(0, 0);
277
+ # endif
278
+ old_option = -1;
279
+ erase();
280
+ display_menu(old_option, new_option);
281
+ break;
282
+ case 'Q':
283
+ case 'q':
284
+ quit = TRUE;
285
+ }
286
+ if( run_option)
287
+ {
288
+ old_option = -1;
289
+ erase();
290
+ refresh();
291
+ (*command[new_option].function)(win);
292
+ erase();
293
+ display_menu(old_option, new_option);
294
+ }
295
+
296
+ if (quit == TRUE)
297
+ break;
298
+ }
299
+
300
+ delwin(win);
301
+ endwin();
302
+
303
+ return 0;
304
+ }
305
+
306
+ void Continue(WINDOW *win)
307
+ {
308
+ mvwaddstr(win, 10, 1, " Press any key to continue");
309
+ wrefresh(win);
310
+ raw();
311
+ wgetch(win);
312
+ wrefresh(win);
313
+ }
314
+
315
+ void Continue2(void)
316
+ {
317
+ move(LINES - 1, 1);
318
+ clrtoeol();
319
+ mvaddstr(LINES - 2, 1, " Press any key to continue");
320
+ refresh();
321
+ raw();
322
+ getch();
323
+ }
324
+
325
+ int initTest(WINDOW **win, int argc, char *argv[])
326
+ {
327
+ #ifdef XCURSES
328
+ Xinitscr(argc, argv);
329
+ #else
330
+ initscr();
331
+ #endif
332
+ #ifdef A_COLOR
333
+ if (has_colors())
334
+ start_color();
335
+ #endif
336
+ /* Create a drawing window */
337
+
338
+ width = 60;
339
+ height = 19;
340
+
341
+ *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
342
+
343
+ if (*win == NULL)
344
+ {
345
+ endwin();
346
+ return 1;
347
+ }
348
+
349
+ return 0;
350
+ }
351
+
352
+ void introTest(WINDOW *win)
353
+ {
354
+ werase(win);
355
+ wmove(win, height / 2 - 5, width / 2);
356
+ wvline(win, ACS_VLINE, 10);
357
+ wmove(win, height / 2, width / 2 - 10);
358
+ whline(win, ACS_HLINE, 20);
359
+ Continue(win);
360
+
361
+ beep();
362
+ werase(win);
363
+
364
+ box(win, ACS_VLINE, ACS_HLINE);
365
+ wrefresh(win);
366
+
367
+ cbreak();
368
+ mvwaddstr(win, 1, 1,
369
+ "You should have a rectangle in the middle of the screen");
370
+ mvwaddstr(win, 2, 1, "You should have heard a beep");
371
+ Continue(win);
372
+
373
+ flash();
374
+ mvwaddstr(win, 3, 1, "You should have seen a flash");
375
+ Continue(win);
376
+ }
377
+
378
+ void scrollTest(WINDOW *win)
379
+ {
380
+ int i, OldY;
381
+ #if !defined (PDCURSES) && !defined (NCURSES_VERSION)
382
+ int OldX;
383
+ #endif
384
+ werase(win);
385
+ mvwaddstr(win, height - 2, 1, "The window will now scroll slowly");
386
+ box(win, ACS_VLINE, ACS_HLINE);
387
+ wrefresh(win);
388
+ scrollok(win, TRUE);
389
+ napms(500);
390
+
391
+ for (i = 1; i <= height; i++)
392
+ {
393
+ napms(150);
394
+ scroll(win);
395
+ wrefresh(win);
396
+ };
397
+
398
+ #if defined (PDCURSES) || defined (NCURSES_VERSION)
399
+ OldY = getmaxy(win);
400
+ #else
401
+ getmaxyx(win, OldY, OldX);
402
+ #endif
403
+ mvwaddstr(win, 6, 1, "The top of the window will scroll");
404
+ wmove(win, 1, 1);
405
+ wsetscrreg(win, 0, 4);
406
+ box(win, ACS_VLINE, ACS_HLINE);
407
+ wrefresh(win);
408
+
409
+ for (i = 1; i <= 5; i++)
410
+ {
411
+ napms(500);
412
+ scroll(win);
413
+ wrefresh(win);
414
+ }
415
+
416
+ mvwaddstr(win, 3, 1, "The bottom of the window will scroll");
417
+ wmove(win, 8, 1);
418
+ wsetscrreg(win, 5, --OldY);
419
+ box(win, ACS_VLINE, ACS_HLINE);
420
+ wrefresh(win);
421
+
422
+ for (i = 5; i <= OldY; i++)
423
+ {
424
+ napms(300);
425
+ wscrl(win, -1);
426
+ wrefresh(win);
427
+ }
428
+
429
+ wsetscrreg(win, 0, OldY);
430
+ }
431
+
432
+ void inputTest(WINDOW *win)
433
+ {
434
+ int w, h, bx, by, sw, sh, i, c, num = 0;
435
+ int line_to_use = 3;
436
+ char buffer[80];
437
+ WINDOW *subWin;
438
+ static const char spinner[4] = "/-\\|";
439
+ int spinner_count = 0;
440
+
441
+ wclear(win);
442
+
443
+ getmaxyx(win, h, w);
444
+ getbegyx(win, by, bx);
445
+
446
+ sw = w / 3;
447
+ sh = h / 3;
448
+
449
+ if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2))
450
+ == NULL)
451
+ return;
452
+
453
+ #ifdef A_COLOR
454
+ if (has_colors())
455
+ {
456
+ init_pair(2, COLOR_WHITE, COLOR_RED);
457
+ wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
458
+ }
459
+ else
460
+ #endif
461
+ wbkgd(subWin, A_BOLD);
462
+
463
+ box(subWin, ACS_VLINE, ACS_HLINE);
464
+ wrefresh(win);
465
+
466
+ nocbreak();
467
+
468
+ wclear (win);
469
+ mvwaddstr(win, 1, 1,
470
+ "Press keys (or mouse buttons) to show their names");
471
+ mvwaddstr(win, 2, 1, "Press spacebar to finish, Ctrl-A to return to main menu");
472
+ wrefresh(win);
473
+
474
+ keypad(win, TRUE);
475
+ raw();
476
+ noecho();
477
+
478
+ wtimeout(win, 200);
479
+
480
+
481
+ #ifdef PDCURSES
482
+ mouse_set( ALL_MOUSE_EVENTS |
483
+ (report_mouse_movement ? REPORT_MOUSE_POSITION : 0));
484
+ PDC_save_key_modifiers(TRUE);
485
+ #else
486
+ mousemask( ALL_MOUSE_EVENTS |
487
+ (report_mouse_movement ? REPORT_MOUSE_POSITION : 0), NULL);
488
+ if( report_mouse_movement)
489
+ printf("\033[?1003h\n"); /* used in ncurses with some X-based */
490
+ #endif /* terms to enable mouse move events */
491
+ curs_set(0); /* turn cursor off */
492
+
493
+ while (1)
494
+ {
495
+ while (1)
496
+ {
497
+ c = wgetch(win);
498
+
499
+ if (c == ERR)
500
+ {
501
+ spinner_count++;
502
+ if (spinner_count == 4)
503
+ spinner_count = 0;
504
+ mvwaddch(win, line_to_use, 3, spinner[spinner_count]);
505
+ wrefresh(win);
506
+ }
507
+ else
508
+ break;
509
+ }
510
+ #ifdef PDCURSES
511
+ /* wmove(win, line_to_use + 1, 18);
512
+ wclrtoeol(win); */
513
+ #endif
514
+ mvwaddstr(win, line_to_use, 5, "Key Pressed: ");
515
+ wclrtoeol(win);
516
+
517
+ wprintw( win, "(%x) ", c);
518
+ if( has_key( c))
519
+ wprintw(win, "%s", keyname(c));
520
+ else if (isprint(c) || c > 0xff)
521
+ waddch( win, c);
522
+ else
523
+ wprintw(win, "%s", unctrl(c));
524
+ if (c == KEY_MOUSE)
525
+ {
526
+ #ifdef NCURSES_MOUSE_INTERFACE
527
+ const mmask_t masks[ ] = {
528
+ BUTTON1_RELEASED, BUTTON1_PRESSED, BUTTON1_CLICKED,
529
+ BUTTON1_DOUBLE_CLICKED, BUTTON1_TRIPLE_CLICKED,
530
+ BUTTON2_RELEASED, BUTTON2_PRESSED, BUTTON2_CLICKED,
531
+ BUTTON2_DOUBLE_CLICKED, BUTTON2_TRIPLE_CLICKED,
532
+ BUTTON3_RELEASED, BUTTON3_PRESSED, BUTTON3_CLICKED,
533
+ BUTTON3_DOUBLE_CLICKED, BUTTON3_TRIPLE_CLICKED,
534
+ BUTTON4_RELEASED, BUTTON4_PRESSED, BUTTON4_CLICKED,
535
+ BUTTON4_DOUBLE_CLICKED, BUTTON4_TRIPLE_CLICKED,
536
+ #ifdef BUTTON5_RELEASED
537
+ BUTTON5_RELEASED, BUTTON5_PRESSED, BUTTON5_CLICKED,
538
+ BUTTON5_DOUBLE_CLICKED, BUTTON5_TRIPLE_CLICKED,
539
+ #endif
540
+ };
541
+ #ifdef BUTTON4_RESERVED_EVENT
542
+ const mmask_t reserved_masks[] = {
543
+ BUTTON1_RESERVED_EVENT, BUTTON2_RESERVED_EVENT,
544
+ BUTTON3_RESERVED_EVENT, BUTTON4_RESERVED_EVENT };
545
+ #endif
546
+ MEVENT mouse_event;
547
+
548
+ getmouse( &mouse_event);
549
+ wmove(win, line_to_use, 5);
550
+ wclrtoeol(win);
551
+ wprintw(win, "Posn: Y: %d X: %d", mouse_event.y, mouse_event.x);
552
+ for( i = 0; i < sizeof( masks) / sizeof( masks[0]); i++)
553
+ if( mouse_event.bstate & masks[i])
554
+ {
555
+ const char *event_names[] = { "released", "pressed", "clicked",
556
+ "double-clicked", "triple-clicked" };
557
+
558
+ wprintw( win, " Button %d %s", i / 5 + 1, event_names[i % 5]);
559
+ }
560
+ #ifdef BUTTON_CTRL
561
+ if( mouse_event.bstate & BUTTON_CTRL)
562
+ wprintw( win, " Ctrl");
563
+ #endif
564
+ if( mouse_event.bstate & BUTTON_ALT)
565
+ wprintw( win, " Alt");
566
+ if( mouse_event.bstate & BUTTON_SHIFT)
567
+ wprintw( win, " Shift");
568
+ if( mouse_event.bstate & REPORT_MOUSE_POSITION)
569
+ wprintw( win, " Moved");
570
+ #ifdef BUTTON4_RESERVED_EVENT
571
+ for( i = 0; i < sizeof( reserved_masks) / sizeof( reserved_masks[0]); i++)
572
+ if( mouse_event.bstate & reserved_masks[i])
573
+ wprintw( win, " Reserved %d", i + 1);
574
+ #endif
575
+
576
+ #else /* using the 'classic' (undocumented) Sys V mouse functions */
577
+ int button = 0, status = 0;
578
+ request_mouse_pos();
579
+
580
+ if (BUTTON_CHANGED(1))
581
+ button = 1;
582
+ else if (BUTTON_CHANGED(2))
583
+ button = 2;
584
+ else if (BUTTON_CHANGED(3))
585
+ button = 3;
586
+ else if (BUTTON_CHANGED(4)) /* added 21 Jan 2011: BJG */
587
+ button = 4;
588
+ else if (BUTTON_CHANGED(5))
589
+ button = 5;
590
+ if( button)
591
+ #ifdef PDC_N_EXTENDED_MOUSE_BUTTONS
592
+ status = (button > 3 ? Mouse_status.xbutton[(button) - 4] :
593
+ Mouse_status.button[(button) - 1]);
594
+ #else
595
+ status = (button > 3 ? 0 :
596
+ Mouse_status.button[(button) - 1]);
597
+ #endif
598
+
599
+ wmove(win, line_to_use, 5);
600
+ wclrtoeol(win);
601
+ wprintw(win, "Button %d: ", button);
602
+
603
+ if (MOUSE_MOVED)
604
+ waddstr(win, "moved: ");
605
+ else if (MOUSE_WHEEL_UP)
606
+ waddstr(win, "wheel up: ");
607
+ else if (MOUSE_WHEEL_DOWN)
608
+ waddstr(win, "wheel dn: ");
609
+ #ifdef MOUSE_WHEEL_LEFT
610
+ else if (MOUSE_WHEEL_LEFT)
611
+ waddstr(win, "wheel lt: ");
612
+ #endif
613
+ #ifdef MOUSE_WHEEL_RIGHT
614
+ else if (MOUSE_WHEEL_RIGHT)
615
+ waddstr(win, "wheel rt: ");
616
+ #endif
617
+ else if ((status & BUTTON_ACTION_MASK) == BUTTON_PRESSED)
618
+ waddstr(win, "pressed: ");
619
+ else if ((status & BUTTON_ACTION_MASK) == BUTTON_CLICKED)
620
+ waddstr(win, "clicked: ");
621
+ else if ((status & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
622
+ waddstr(win, "double: ");
623
+ else if ((status & BUTTON_ACTION_MASK) == BUTTON_TRIPLE_CLICKED)
624
+ waddstr(win, "triple: ");
625
+ else if( button)
626
+ waddstr(win, "released: ");
627
+
628
+ wprintw(win, "Posn: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
629
+ if( !button) /* just to get shift/alt/ctrl status */
630
+ status = Mouse_status.button[0];
631
+ if (status & BUTTON_SHIFT)
632
+ waddstr(win, " SHIFT");
633
+
634
+ if (status & BUTTON_CONTROL)
635
+ waddstr(win, " CONTROL");
636
+
637
+ if (status & BUTTON_ALT)
638
+ waddstr(win, " ALT");
639
+ }
640
+ else if (PDC_get_key_modifiers())
641
+ {
642
+ waddstr(win, " Modifier(s):");
643
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT)
644
+ waddstr(win, " SHIFT");
645
+
646
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL)
647
+ waddstr(win, " CONTROL");
648
+
649
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT)
650
+ waddstr(win, " ALT");
651
+
652
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK)
653
+ waddstr(win, " NUMLOCK");
654
+
655
+ #ifdef PDC_KEY_MODIFIER_REPEAT
656
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_REPEAT)
657
+ waddstr(win, " REPEAT");
658
+ #endif
659
+ #endif /* end of mouse display */
660
+ }
661
+ wrefresh(win);
662
+
663
+ if (c == ' ' || c == 1)
664
+ break;
665
+ line_to_use++;
666
+ if( line_to_use == 17)
667
+ line_to_use = 3;
668
+ }
669
+
670
+ wtimeout(win, -1); /* turn off timeout() */
671
+ curs_set(1); /* turn cursor back on */
672
+
673
+ #ifdef PDCURSES
674
+ mouse_set(0L);
675
+ PDC_save_key_modifiers(FALSE);
676
+ /* PDC_return_key_modifiers(FALSE); */
677
+ #endif
678
+ wclear(win);
679
+ if( c == 1)
680
+ return;
681
+ #ifdef PDCURSES
682
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
683
+ PDC_set_function_key( FUNCTION_KEY_ABORT, 0 ); /* un-abortable */
684
+ #endif
685
+ #endif
686
+ mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
687
+ mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
688
+ wrefresh(win);
689
+
690
+ werase(subWin);
691
+ box(subWin, ACS_VLINE, ACS_HLINE);
692
+
693
+ for (i = 0; i < 5; i++)
694
+ {
695
+ mvwprintw(subWin, 1, 1, "Time = %d", i);
696
+ wrefresh(subWin);
697
+ napms(1000);
698
+ flushinp();
699
+ }
700
+
701
+ #ifdef PDCURSES
702
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
703
+ PDC_set_function_key( FUNCTION_KEY_ABORT, 3 ); /* ctrl-C aborts */
704
+ #endif
705
+ #endif
706
+
707
+ delwin(subWin);
708
+ werase(win);
709
+ flash();
710
+ wrefresh(win);
711
+ napms(500);
712
+ flushinp();
713
+
714
+ mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
715
+ wmove(win, 9, 10);
716
+ wrefresh(win);
717
+ echo();
718
+
719
+ keypad(win, TRUE);
720
+ raw();
721
+ wgetnstr(win, buffer, 3);
722
+ flushinp();
723
+
724
+ wmove(win, 9, 10);
725
+ wdelch(win);
726
+ mvwaddstr(win, 4, 1, "The character should now have been deleted");
727
+ Continue(win);
728
+
729
+ refresh();
730
+ wclear(win);
731
+ echo();
732
+ buffer[0] = '\0';
733
+ mvwaddstr(win, 3, 2, "The window should have moved");
734
+ mvwaddstr(win, 4, 2,
735
+ "This text should have appeared without you pressing a key");
736
+ mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
737
+ mvwin(win, 2, 1);
738
+ wrefresh(win);
739
+ mvwscanw(win, 7, 6, "%d %s", &num, buffer);
740
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
741
+ Continue(win);
742
+
743
+ refresh();
744
+ wclear(win);
745
+ echo();
746
+ mvwaddstr(win, 3, 2, "Enter a 5 character string: ");
747
+ wgetnstr(win, buffer, 5);
748
+ mvwprintw(win, 4, 2, "String: %s", buffer);
749
+ Continue(win);
750
+ }
751
+
752
+ void outputTest(WINDOW *win)
753
+ {
754
+ WINDOW *win1;
755
+ char Buffer[80];
756
+ chtype ch;
757
+ int by, bx;
758
+
759
+ nl();
760
+ wclear(win);
761
+ mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
762
+ "left corner, and this text should have wrapped");
763
+ waddstr(win,"\nThis text should be down\n");
764
+ waddstr(win, "and broken into two here ^");
765
+ Continue(win);
766
+
767
+ wclear(win);
768
+ wattron(win, A_BOLD);
769
+ mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
770
+ mvwaddstr(win, 8, 1, "Press any key to continue");
771
+ wrefresh(win);
772
+ wgetch(win);
773
+
774
+ getbegyx(win, by, bx);
775
+
776
+ if (LINES < 24 || COLS < 75)
777
+ {
778
+ mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
779
+ mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
780
+ Continue(win);
781
+ }
782
+ else
783
+ {
784
+ win1 = newwin(10, 50, 14, 25);
785
+
786
+ if (win1 == NULL)
787
+ {
788
+ endwin();
789
+ return;
790
+ }
791
+
792
+ #ifdef A_COLOR
793
+ if (has_colors())
794
+ {
795
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
796
+ wbkgd(win1, COLOR_PAIR(3));
797
+ }
798
+ else
799
+ #endif
800
+ wbkgd(win1, A_NORMAL);
801
+
802
+ wclear(win1);
803
+ mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
804
+ copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
805
+ box(win1, ACS_VLINE, ACS_HLINE);
806
+ wmove(win1, 8, 26);
807
+ wrefresh(win1);
808
+ wgetch(win1);
809
+
810
+ wclear(win1);
811
+
812
+ wattron(win1, A_BLINK);
813
+ mvwaddstr(win1, 4, 1,
814
+ "This blinking text should appear in only the second window");
815
+ wattroff(win1, A_BLINK);
816
+
817
+ mvwin(win1, by, bx);
818
+ overlay(win, win1);
819
+ mvwin(win1, 14, 25);
820
+ wmove(win1, 8, 26);
821
+ wrefresh(win1);
822
+ wgetch(win1);
823
+
824
+ delwin(win1);
825
+ }
826
+
827
+ clear();
828
+ wclear(win);
829
+ wrefresh(win);
830
+ mvwaddstr(win, 6, 2, "This line shouldn't appear");
831
+ mvwaddstr(win, 4, 2, "Only half of the next line is visible");
832
+ mvwaddstr(win, 5, 2, "Only half of the next line is visible");
833
+ wmove(win, 6, 1);
834
+ wclrtobot(win);
835
+ wmove(win, 5, 20);
836
+ wclrtoeol(win);
837
+ mvwaddstr(win, 8, 2, "This line also shouldn't appear");
838
+ wmove(win, 8, 1);
839
+ winsdelln(win, -1);
840
+ Continue(win);
841
+
842
+ wmove(win, 5, 9);
843
+ ch = winch(win);
844
+
845
+ wclear(win);
846
+ wmove(win, 6, 2);
847
+ waddstr(win, "The next char should be l: ");
848
+ winsch(win, ch);
849
+ Continue(win);
850
+
851
+ mvwinsstr(win, 6, 2, "A1B2C3D4E5");
852
+ Continue(win);
853
+
854
+ wmove(win, 5, 1);
855
+ winsdelln(win, 1);
856
+ mvwaddstr(win, 5, 2, "The lines below should have moved down");
857
+ Continue(win);
858
+
859
+ wclear(win);
860
+ wmove(win, 2, 2);
861
+ wprintw(win, "This is a formatted string in a window: %d %s\n",
862
+ 42, "is it");
863
+ mvwaddstr(win, 10, 1, "Enter a string: ");
864
+ wrefresh(win);
865
+ echo();
866
+ wscanw(win, "%s", Buffer);
867
+
868
+ printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
869
+ mvaddstr(10, 1, "Enter a string: ");
870
+ scanw("%s", Buffer);
871
+
872
+ wclear(win);
873
+ curs_set(2);
874
+ mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
875
+ Continue(win);
876
+
877
+ wclear(win);
878
+ curs_set(0);
879
+ mvwaddstr(win, 1, 1, "The cursor should have disappeared");
880
+ Continue(win);
881
+
882
+ wclear(win);
883
+ curs_set(1);
884
+ mvwaddstr(win, 1, 1, "The cursor should be normal");
885
+ Continue(win);
886
+
887
+ #ifdef A_COLOR
888
+ if (has_colors())
889
+ {
890
+ wclear(win);
891
+ mvwaddstr(win, 1, 1, "Colors should change after you press a key");
892
+ Continue(win);
893
+
894
+ init_pair(1, COLOR_RED, COLOR_WHITE);
895
+ wrefresh(win);
896
+ }
897
+ #endif
898
+ werase(win);
899
+ mvwaddstr(win, 1, 1, "Information About Your Terminal");
900
+ mvwaddstr(win, 3, 1, termname());
901
+ mvwaddstr(win, 4, 1, longname());
902
+
903
+ if (termattrs() & A_BLINK)
904
+ mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
905
+ else
906
+ mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
907
+
908
+ mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
909
+ wrefresh(win);
910
+
911
+ mvwinnstr(win, 7, 5, Buffer, 18);
912
+ mvaddstr(LINES - 2, 10, Buffer);
913
+ refresh();
914
+ Continue(win);
915
+ }
916
+
917
+ #if HAVE_RESIZE
918
+ void resizeTest(WINDOW *dummy)
919
+ {
920
+ WINDOW *win1;
921
+ int nwidth = 135, nheight = 52;
922
+ int owidth = COLS, oheight = LINES;
923
+
924
+ savetty();
925
+
926
+ resize_term(nheight, nwidth);
927
+
928
+ clear();
929
+ refresh();
930
+
931
+ win1 = newwin(10, 50, 14, 25);
932
+
933
+ if (win1 == NULL)
934
+ {
935
+ endwin();
936
+ return;
937
+ }
938
+
939
+ #ifdef A_COLOR
940
+ if (has_colors())
941
+ {
942
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
943
+ wattrset(win1, COLOR_PAIR(3));
944
+ }
945
+
946
+ wclear(win1);
947
+ #endif
948
+ mvwaddstr(win1, 0, 0, "The screen may now be resized");
949
+ mvwprintw(win1, 1, 4, "Given size: %d by %d", nwidth, nheight);
950
+ mvwprintw(win1, 2, 4, "Actual size: %d by %d", COLS, LINES);
951
+ Continue(win1);
952
+
953
+ wclear(win1);
954
+ resetty();
955
+
956
+ mvwaddstr(win1, 0, 0, "The screen should now be reset");
957
+ mvwprintw(win1, 1, 6, "Old size: %d by %d", owidth, oheight);
958
+ mvwprintw(win1, 2, 6, "Size now: %d by %d", COLS, LINES);
959
+ Continue(win1);
960
+
961
+ delwin(win1);
962
+
963
+ clear();
964
+ refresh();
965
+ }
966
+ #endif /* HAVE_RESIZE */
967
+
968
+ void padTest(WINDOW *dummy)
969
+ {
970
+ WINDOW *pad, *spad;
971
+
972
+ pad = newpad(50, 100);
973
+ wattron(pad, A_REVERSE);
974
+ mvwaddstr(pad, 5, 2, "This is a new pad");
975
+ wattrset(pad, 0);
976
+ mvwaddstr(pad, 8, 0,
977
+ "The end of this line should be truncated here:except now");
978
+ mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
979
+ wmove(pad, 10, 1);
980
+ wclrtoeol(pad);
981
+ mvwaddstr(pad, 10, 1, " Press any key to continue");
982
+ prefresh(pad, 0, 0, 0, 0, 10, 45);
983
+ keypad(pad, TRUE);
984
+ raw();
985
+ wgetch(pad);
986
+
987
+ spad = subpad(pad, 12, 25, 7, 52);
988
+ mvwaddstr(spad, 2, 2, "This is a new subpad");
989
+ box(spad, 0, 0);
990
+ prefresh(pad, 0, 0, 0, 0, 15, 75);
991
+ keypad(pad, TRUE);
992
+ raw();
993
+ wgetch(pad);
994
+
995
+ mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
996
+ mvwaddstr(pad, 40, 1, " Press any key to continue");
997
+ prefresh(pad, 30, 0, 0, 0, 10, 45);
998
+ keypad(pad, TRUE);
999
+ raw();
1000
+ wgetch(pad);
1001
+
1002
+ delwin(pad);
1003
+ }
1004
+
1005
+ #if HAVE_CLIPBOARD
1006
+ void clipboardTest(WINDOW *win)
1007
+ {
1008
+ static const char *text =
1009
+ "This string placed in clipboard by PDCurses test program, testcurs.";
1010
+ char *ptr = NULL;
1011
+ long i, length = 0;
1012
+
1013
+ mvaddstr(1, 1,
1014
+ "This test will display the contents of the system clipboard");
1015
+
1016
+ Continue2();
1017
+
1018
+ scrollok(stdscr, TRUE);
1019
+ i = PDC_getclipboard(&ptr, &length);
1020
+
1021
+ switch(i)
1022
+ {
1023
+ case PDC_CLIP_ACCESS_ERROR:
1024
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
1025
+ refresh();
1026
+ break;
1027
+
1028
+ case PDC_CLIP_MEMORY_ERROR:
1029
+ mvaddstr(3, 1,
1030
+ "Unable to allocate memory for clipboard contents");
1031
+ break;
1032
+
1033
+ case PDC_CLIP_EMPTY:
1034
+ mvaddstr(3, 1, "There was no text in the clipboard");
1035
+ break;
1036
+
1037
+ default:
1038
+ wsetscrreg(stdscr, 0, LINES - 1);
1039
+ clear();
1040
+ mvaddstr(1, 1, "Clipboard contents...");
1041
+ mvprintw(2, 1, "%s\n", ptr);
1042
+ }
1043
+
1044
+ Continue2();
1045
+
1046
+ clear();
1047
+ mvaddstr(1, 1,
1048
+ "This test will place the following string in the system clipboard:");
1049
+ mvaddstr(2, 1, text);
1050
+
1051
+ i = PDC_setclipboard(text, (long)strlen(text));
1052
+
1053
+ switch(i)
1054
+ {
1055
+ case PDC_CLIP_ACCESS_ERROR:
1056
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
1057
+ break;
1058
+
1059
+ case PDC_CLIP_MEMORY_ERROR:
1060
+ mvaddstr(3, 1, "Unable to allocate memory for clipboard contents");
1061
+ break;
1062
+
1063
+ default:
1064
+ mvaddstr(3, 1, "The string was placed in the clipboard successfully");
1065
+ }
1066
+
1067
+ Continue2();
1068
+ }
1069
+ #endif /* HAVE_CLIPBOARD */
1070
+
1071
+ void acsTest(WINDOW *win)
1072
+ {
1073
+ static const char *acs_names[] =
1074
+ {
1075
+ "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
1076
+ "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
1077
+ "ACS_VLINE", "ACS_PLUS",
1078
+
1079
+ #ifdef ACS_D_ULCORNER
1080
+ "ACS_D_ULCORNER", "ACS_D_URCORNER", "ACS_D_LLCORNER", "ACS_D_LRCORNER",
1081
+ "ACS_D_LTEE", "ACS_D_RTEE", "ACS_D_TTEE", "ACS_D_BTEE", "ACS_D_HLINE",
1082
+ "ACS_D_VLINE", "ACS_D_PLUS",
1083
+ #endif
1084
+ #ifdef ACS_SD_ULCORNER
1085
+ "ACS_SD_ULCORNER", "ACS_SD_URCORNER", "ACS_SD_LLCORNER",
1086
+ "ACS_SD_LRCORNER", "ACS_SD_LTEE",
1087
+ "ACS_SD_RTEE", "ACS_SD_TTEE", "ACS_SD_BTEE", "ACS_SD_PLUS",
1088
+ "ACS_DS_ULCORNER", "ACS_DS_URCORNER", "ACS_DS_LLCORNER",
1089
+ "ACS_DS_LRCORNER", "ACS_DS_LTEE", "ACS_DS_RTEE", "ACS_DS_TTEE",
1090
+ "ACS_DS_BTEE", "ACS_DS_PLUS",
1091
+ #endif
1092
+ "ACS_S1",
1093
+ #ifdef ACS_S3
1094
+ "ACS_S3", "ACS_S7",
1095
+ #endif
1096
+ "ACS_S9", "ACS_DIAMOND",
1097
+ #ifdef ACS_CLUB
1098
+ "ACS_CLUB", "ACS_SPADE", "ACS_HEART",
1099
+ "ACS_LTBOARD",
1100
+ #endif
1101
+ "ACS_BOARD", "ACS_CKBOARD", "ACS_DEGREE", "ACS_PLMINUS",
1102
+ "ACS_BULLET",
1103
+ #ifdef ACS_SM_BULLET
1104
+ "ACS_SM_BULLET", "ACS_MED_BULLET", "ACS_WHITE_BULLET",
1105
+ "ACS_PILCROW", "ACS_SECTION", "ACS_SMILE", "ACS_REV_SMILE",
1106
+ #endif
1107
+ "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
1108
+ "ACS_LANTERN", "ACS_BLOCK",
1109
+ #ifdef ACS_LEQUAL
1110
+ "ACS_LEQUAL", "ACS_GEQUAL", "ACS_NEQUAL",
1111
+ "ACS_PI", "ACS_STERLING",
1112
+ #endif
1113
+ #ifdef ACS_CENT
1114
+ "ACS_CENT", "ACS_YEN", "ACS_PESETA",
1115
+ "ACS_ALPHA", "ACS_BETA", "ACS_GAMMA", "ACS_UP_SIGMA",
1116
+ "ACS_LO_SIGMA", "ACS_MU", "ACS_TAU", "ACS_UP_PHI", "ACS_LO_PHI",
1117
+ "ACS_OMEGA", "ACS_DELTA", "ACS_INFINITY", "ACS_THETA", "ACS_EPSILON",
1118
+ "ACS_INTERSECT", "ACS_SUP2", "ACS_SUP_N", "ACS_TRIPLE_BAR",
1119
+ "ACS_APPROX_EQ", "ACS_SQUARE_ROOT", "ACS_NOT", "ACS_REV_NOT",
1120
+ "ACS_HALF", "ACS_QUARTER", "ACS_DIVISION",
1121
+ "ACS_UP_INTEGRAL", "ACS_LO_INTEGRAL",
1122
+ "ACS_UBLOCK", "ACS_BBLOCK",
1123
+ "ACS_LBLOCK", "ACS_RBLOCK",
1124
+ "ACS_A_ORDINAL", "ACS_O_ORDINAL",
1125
+ "ACS_INV_BANG", "ACS_INV_QUERY",
1126
+ "ACS_LEFT_ANG_QU", "ACS_RIGHT_ANG_QU",
1127
+ "ACS_CENTER_SQU", "ACS_F_WITH_HOOK",
1128
+ #endif
1129
+ };
1130
+
1131
+ const chtype acs_values[] =
1132
+ {
1133
+ ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER,
1134
+ ACS_LTEE, ACS_RTEE, ACS_TTEE, ACS_BTEE, ACS_HLINE,
1135
+ ACS_VLINE, ACS_PLUS,
1136
+
1137
+ #ifdef ACS_D_ULCORNER
1138
+ ACS_D_ULCORNER, ACS_D_URCORNER, ACS_D_LLCORNER, ACS_D_LRCORNER,
1139
+ ACS_D_LTEE, ACS_D_RTEE, ACS_D_TTEE, ACS_D_BTEE, ACS_D_HLINE,
1140
+ ACS_D_VLINE, ACS_D_PLUS,
1141
+ #endif
1142
+ #ifdef ACS_SD_ULCORNER
1143
+ ACS_SD_ULCORNER, ACS_SD_URCORNER, ACS_SD_LLCORNER,
1144
+ ACS_SD_LRCORNER, ACS_SD_LTEE,
1145
+ ACS_SD_RTEE, ACS_SD_TTEE, ACS_SD_BTEE, ACS_SD_PLUS,
1146
+ ACS_DS_ULCORNER, ACS_DS_URCORNER, ACS_DS_LLCORNER,
1147
+ ACS_DS_LRCORNER, ACS_DS_LTEE, ACS_DS_RTEE, ACS_DS_TTEE,
1148
+ ACS_DS_BTEE, ACS_DS_PLUS,
1149
+ #endif
1150
+ ACS_S1,
1151
+ #ifdef ACS_S3
1152
+ ACS_S3, ACS_S7,
1153
+ #endif
1154
+ ACS_S9, ACS_DIAMOND,
1155
+ #ifdef ACS_CLUB
1156
+ ACS_CLUB, ACS_SPADE, ACS_HEART, ACS_LTBOARD,
1157
+ #endif
1158
+ ACS_BOARD, ACS_CKBOARD, ACS_DEGREE, ACS_PLMINUS, ACS_BULLET,
1159
+ #ifdef ACS_SM_BULLET
1160
+ ACS_SM_BULLET, ACS_MED_BULLET, ACS_WHITE_BULLET,
1161
+ ACS_PILCROW, ACS_SECTION, ACS_SMILE, ACS_REV_SMILE,
1162
+ #endif
1163
+ ACS_LARROW, ACS_RARROW, ACS_UARROW, ACS_DARROW,
1164
+ ACS_LANTERN, ACS_BLOCK,
1165
+ #ifdef ACS_LEQUAL
1166
+ ACS_LEQUAL, ACS_GEQUAL, ACS_NEQUAL,
1167
+ ACS_PI, ACS_STERLING,
1168
+ #endif
1169
+ #ifdef ACS_CENT
1170
+ ACS_CENT, ACS_YEN, ACS_PESETA,
1171
+ ACS_ALPHA, ACS_BETA, ACS_GAMMA, ACS_UP_SIGMA,
1172
+ ACS_LO_SIGMA, ACS_MU, ACS_TAU, ACS_UP_PHI, ACS_LO_PHI,
1173
+ ACS_OMEGA, ACS_DELTA, ACS_INFINITY, ACS_THETA, ACS_EPSILON,
1174
+ ACS_INTERSECT, ACS_SUP2, ACS_SUP_N, ACS_TRIPLE_BAR,
1175
+ ACS_APPROX_EQ, ACS_SQUARE_ROOT, ACS_NOT, ACS_REV_NOT,
1176
+ ACS_HALF, ACS_QUARTER, ACS_DIVISION,
1177
+ ACS_UP_INTEGRAL, ACS_LO_INTEGRAL,
1178
+ ACS_UBLOCK, ACS_BBLOCK,
1179
+ ACS_LBLOCK, ACS_RBLOCK,
1180
+ ACS_A_ORDINAL, ACS_O_ORDINAL,
1181
+ ACS_INV_BANG, ACS_INV_QUERY,
1182
+ ACS_LEFT_ANG_QU, ACS_RIGHT_ANG_QU,
1183
+ ACS_CENTER_SQU, ACS_F_WITH_HOOK,
1184
+ #endif
1185
+ };
1186
+
1187
+ #ifdef WACS_S1
1188
+ const cchar_t *wacs_values[] =
1189
+ {
1190
+ WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
1191
+ WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
1192
+ WACS_VLINE, WACS_PLUS,
1193
+
1194
+ #ifdef WACS_D_ULCORNER
1195
+ WACS_D_ULCORNER, WACS_D_URCORNER, WACS_D_LLCORNER, WACS_D_LRCORNER,
1196
+ WACS_D_LTEE, WACS_D_RTEE, WACS_D_TTEE, WACS_D_BTEE, WACS_D_HLINE,
1197
+ WACS_D_VLINE, WACS_D_PLUS,
1198
+ #endif
1199
+ #ifdef WACS_SD_ULCORNER
1200
+ WACS_SD_ULCORNER, WACS_SD_URCORNER, WACS_SD_LLCORNER,
1201
+ WACS_SD_LRCORNER, WACS_SD_LTEE,
1202
+ WACS_SD_RTEE, WACS_SD_TTEE, WACS_SD_BTEE, WACS_SD_PLUS,
1203
+ WACS_DS_ULCORNER, WACS_DS_URCORNER, WACS_DS_LLCORNER,
1204
+ WACS_DS_LRCORNER, WACS_DS_LTEE, WACS_DS_RTEE, WACS_DS_TTEE,
1205
+ WACS_DS_BTEE, WACS_DS_PLUS,
1206
+ #endif
1207
+ WACS_S1,
1208
+ #ifdef WACS_S3
1209
+ WACS_S3, WACS_S7,
1210
+ #endif
1211
+ WACS_S9, WACS_DIAMOND,
1212
+ #ifdef WACS_CLUB
1213
+ WACS_CLUB, WACS_SPADE, WACS_HEART, WACS_LTBOARD,
1214
+ #endif
1215
+ WACS_BOARD, WACS_CKBOARD, WACS_DEGREE, WACS_PLMINUS, WACS_BULLET,
1216
+ #ifdef WACS_SM_BULLET
1217
+ WACS_SM_BULLET, WACS_MED_BULLET, WACS_WHITE_BULLET,
1218
+ WACS_PILCROW, WACS_SECTION, WACS_SMILE, WACS_REV_SMILE,
1219
+ #endif
1220
+ WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW,
1221
+ WACS_LANTERN, WACS_BLOCK,
1222
+ #ifdef WACS_LEQUAL
1223
+ WACS_LEQUAL, WACS_GEQUAL, WACS_NEQUAL,
1224
+ WACS_PI, WACS_STERLING,
1225
+ #endif
1226
+ #ifdef WACS_CENT
1227
+ WACS_CENT, WACS_YEN, WACS_PESETA,
1228
+ WACS_ALPHA, WACS_BETA, WACS_GAMMA, WACS_UP_SIGMA,
1229
+ WACS_LO_SIGMA, WACS_MU, WACS_TAU, WACS_UP_PHI, WACS_LO_PHI,
1230
+ WACS_OMEGA, WACS_DELTA, WACS_INFINITY, WACS_THETA, WACS_EPSILON,
1231
+ WACS_INTERSECT, WACS_SUP2, WACS_SUP_N, WACS_TRIPLE_BAR,
1232
+ WACS_APPROX_EQ, WACS_SQUARE_ROOT, WACS_NOT, WACS_REV_NOT,
1233
+ WACS_HALF, WACS_QUARTER, WACS_DIVISION,
1234
+ WACS_UP_INTEGRAL, WACS_LO_INTEGRAL,
1235
+ WACS_UBLOCK, WACS_BBLOCK,
1236
+ WACS_LBLOCK, WACS_RBLOCK,
1237
+ WACS_A_ORDINAL, WACS_O_ORDINAL,
1238
+ WACS_INV_BANG, WACS_INV_QUERY,
1239
+ WACS_LEFT_ANG_QU, WACS_RIGHT_ANG_QU,
1240
+ WACS_CENTER_SQU, WACS_F_WITH_HOOK,
1241
+ #endif /* #if WACS_CENT */
1242
+ };
1243
+ #endif /* #ifdef WACS_S1 */
1244
+
1245
+ #ifdef WACS_S1
1246
+ static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
1247
+ 0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0};
1248
+
1249
+ static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
1250
+ 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0};
1251
+
1252
+ static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
1253
+ 0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0};
1254
+
1255
+ static const wchar_t fullwidth[] = { 0xff26, 0xff55, 0xff4c, 0xff4c,
1256
+ 0xff57, 0xff49, 0xff44, 0xff54, 0xff48, 0 }; /* "Fullwidth" */
1257
+
1258
+ static const wchar_t combining_marks[] = { L'C', L'o', 0x35c, L'm',
1259
+ L'b', 0x30a, L'i', L'n', L'i', 0x304, L'n', 0x30b, 0x329,
1260
+ L'g', 0x310,
1261
+ L' ', L'C', 0x338, L'h', 0x306, L'a', 0x361, L'r', L's',
1262
+ 0x30e, 0x348, 0 };
1263
+
1264
+ #endif
1265
+
1266
+ int i, tmarg = 1, ncols = (COLS - 4) / 19;
1267
+ int col_size = (COLS - 4) / ncols;
1268
+ int n_items = sizeof( acs_names) / sizeof( acs_names[0]);
1269
+ int n_rows = LINES / 2 - 4;
1270
+
1271
+ i = 0;
1272
+ while( i < n_items)
1273
+ {
1274
+ int j, xloc = 3;
1275
+
1276
+ attrset(A_BOLD);
1277
+ mvaddstr( 1, (COLS - 23) / 2, "Alternate Character Set");
1278
+ attrset(A_NORMAL);
1279
+ tmarg = 4;
1280
+ while( i < n_items && xloc < COLS - col_size)
1281
+ {
1282
+ for( j = 0; i < n_items && j < n_rows; j++, i++)
1283
+ {
1284
+ move( j * 2 + tmarg, xloc);
1285
+ addch(acs_values[i]);
1286
+ printw(" %s", acs_names[i]);
1287
+ }
1288
+ xloc += col_size;
1289
+ }
1290
+
1291
+ mvaddstr( tmarg + n_rows * 2, 3, curses_version( ));
1292
+ move( tmarg + n_rows * 2 + 1, 3);
1293
+ printw( "sizeof( chtype) = %d; sizeof( mmask_t) = %d",
1294
+ (int)sizeof( chtype), (int)sizeof( mmask_t));
1295
+ mvaddstr(tmarg + n_rows * 2 + 2, 3, "Press any key to continue");
1296
+ getch();
1297
+ clear( );
1298
+ }
1299
+
1300
+ #if HAVE_WIDE
1301
+ i = 0;
1302
+ while( i < n_items)
1303
+ {
1304
+ int j, xloc = 3;
1305
+
1306
+ attrset(A_BOLD);
1307
+ mvaddstr( 1, (COLS - 28) / 2, "Wide Alternate Character Set");
1308
+ attrset(A_NORMAL);
1309
+ tmarg = 4;
1310
+ #ifdef WACS_S1
1311
+ while( i < n_items && xloc < COLS - col_size)
1312
+ {
1313
+ for( j = 0; i < n_items && j < n_rows; j++, i++)
1314
+ {
1315
+ move( j * 2 + tmarg, xloc);
1316
+ add_wch( wacs_values[i]);
1317
+ printw(" W%s", acs_names[i]);
1318
+ }
1319
+ xloc += col_size;
1320
+ }
1321
+ #endif
1322
+ /* Spanish, Russian, Greek, Georgian, fullwidth, combining */
1323
+
1324
+ tmarg += n_rows * 2;
1325
+ mvaddwstr(tmarg, COLS / 8 - 5, L"Espa\xf1ol");
1326
+ mvaddwstr(tmarg, 3 * (COLS / 8) - 5, russian);
1327
+ mvaddwstr(tmarg, 5 * (COLS / 8) - 5, greek);
1328
+ mvaddwstr(tmarg, 7 * (COLS / 8) - 5, georgian);
1329
+ mvaddwstr(tmarg + 1, COLS / 8 - 5, fullwidth);
1330
+
1331
+ mvaddwstr(tmarg + 1, 3 * (COLS / 8) - 5, combining_marks);
1332
+ #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */
1333
+ mvaddch( tmarg + 1, 7 * (COLS / 8) - 5, (chtype)0x1d11e);
1334
+ #endif /* U+1D11E = musical symbol G clef */
1335
+
1336
+ mvaddstr(tmarg + 2, 3, "Press any key to continue");
1337
+ getch();
1338
+ clear( );
1339
+ }
1340
+ #endif
1341
+ }
1342
+
1343
+ #if HAVE_COLOR
1344
+
1345
+ #if CHTYPE_LONG >= 2 || (CHTYPE_LONG == 1 && !defined( PDC_WIDE))
1346
+ #define GOT_DIM
1347
+ #ifdef A_OVERLINE
1348
+ #define GOT_OVERLINE
1349
+ #endif
1350
+ #ifdef A_STIKEOUT
1351
+ #define GOT_STRIKEOUT
1352
+ #endif
1353
+ #endif
1354
+
1355
+ void colorTest(WINDOW *win)
1356
+ {
1357
+ static const short colors[] =
1358
+ {
1359
+ COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE,
1360
+ COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
1361
+ };
1362
+
1363
+ static const char *colornames[] =
1364
+ {
1365
+ "COLOR_BLACK", "COLOR_RED", "COLOR_GREEN", "COLOR_BLUE",
1366
+ "COLOR_CYAN", "COLOR_MAGENTA", "COLOR_YELLOW", "COLOR_WHITE"
1367
+ };
1368
+
1369
+ chtype fill = ACS_BLOCK;
1370
+
1371
+ int i, j, tmarg, col1, col2, col3, col4, ch;
1372
+
1373
+ if (!has_colors())
1374
+ return;
1375
+
1376
+ do
1377
+ {
1378
+ tmarg = (LINES - 19) / 2;
1379
+ col1 = (COLS - 60) / 2;
1380
+ col2 = col1 + 15;
1381
+ col3 = col2 + 15;
1382
+ col4 = col3 + 15;
1383
+
1384
+ attrset(A_BOLD);
1385
+ mvaddstr(tmarg, (COLS - 22) / 2, "Color Attribute Macros");
1386
+ attrset(A_NORMAL);
1387
+
1388
+ mvaddstr(tmarg + 3, col2 + 2, "A_NORMAL");
1389
+ mvaddstr(tmarg + 3, col3 + 3, "A_BOLD");
1390
+ mvaddstr(tmarg + 3, col4 + 3, "A_BLINK");
1391
+
1392
+ for (i = 0; i < 8; i++)
1393
+ {
1394
+ init_pair((short)(i + 4), colors[i], background_index);
1395
+ mvaddstr(tmarg + i + 5, col1, colornames[i]);
1396
+
1397
+ for (j = 0; j < 12; j++)
1398
+ {
1399
+ mvaddch(tmarg + i + 5, col2 + j, fill | COLOR_PAIR(i + 4));
1400
+ mvaddch(tmarg + i + 5, col3 + j, fill | COLOR_PAIR(i + 4) | A_BOLD);
1401
+ mvaddch(tmarg + i + 5, col4 + j, fill | COLOR_PAIR(i + 4) | A_BLINK);
1402
+ }
1403
+ attrset( COLOR_PAIR( i + 4) | A_BLINK);
1404
+ mvaddstr( tmarg + i + 5, col4 + 5, "Text");
1405
+ attrset( COLOR_PAIR( i + 4) | A_BOLD);
1406
+ mvaddstr( tmarg + i + 5, col3 + 5, "Text");
1407
+ attroff( A_BOLD);
1408
+ mvaddstr( tmarg + i + 5, col2 + 5, "Text");
1409
+ attrset( A_NORMAL);
1410
+ }
1411
+
1412
+ mvprintw(tmarg + 15, col1, "COLORS = %d", COLORS);
1413
+ mvprintw(tmarg + 16, col1, "COLOR_PAIRS = %d", COLOR_PAIRS);
1414
+
1415
+ #ifdef CHTYPE_LONG
1416
+ attrset(A_ITALIC);
1417
+ mvprintw( tmarg + 15, col3, "Italic");
1418
+ attrset(A_ITALIC | A_BLINK);
1419
+ mvprintw( tmarg + 15, col4, "Italic Blink");
1420
+ attrset(A_BOLD | A_ITALIC);
1421
+ mvprintw( tmarg + 17, col4, "Italic Bold");
1422
+ attrset(A_BOLD | A_ITALIC | A_BLINK);
1423
+ mvprintw( tmarg + 18, col4, "Italic Blink Bold");
1424
+ #endif
1425
+ attrset(A_BOLD);
1426
+ mvprintw( tmarg + 16, col3, "Bold");
1427
+ attrset(A_BLINK);
1428
+ mvprintw( tmarg + 17, col3, "Blink");
1429
+
1430
+ attrset(A_BLINK | A_BOLD);
1431
+ mvprintw( tmarg + 16, col4, "Blink Bold");
1432
+ /* end BJG addenda */
1433
+ attrset(A_NORMAL);
1434
+
1435
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
1436
+ ch = getch();
1437
+ # ifdef PDCURSES
1438
+ if( ch == KEY_RESIZE)
1439
+ {
1440
+ erase();
1441
+ resize_term(0, 0);
1442
+ }
1443
+ # endif
1444
+ } while( ch == KEY_RESIZE);
1445
+
1446
+ if (can_change_color())
1447
+ {
1448
+ struct
1449
+ {
1450
+ short red, green, blue;
1451
+ } orgcolors[16];
1452
+
1453
+ int MAXCOL = (COLORS >= 16) ? 16 : 8;
1454
+
1455
+ if (MAXCOL < 8)
1456
+ return;
1457
+
1458
+ for (i = 0; i < MAXCOL; i++)
1459
+ color_content((short)i, &(orgcolors[i].red),
1460
+ &(orgcolors[i].green),
1461
+ &(orgcolors[i].blue));
1462
+
1463
+ attrset(A_BOLD);
1464
+ mvaddstr(tmarg, (COLS - 22) / 2, " init_color() Example ");
1465
+ attrset(A_NORMAL);
1466
+
1467
+ refresh();
1468
+
1469
+ for (i = 0; i < 8; i++)
1470
+ {
1471
+ init_color(colors[i], (short)(i * 125), 0, (short)(i * 125));
1472
+
1473
+ if (MAXCOL == 16)
1474
+ init_color((short)(colors[i] + 8), 0, (short)(i * 125), 0);
1475
+ }
1476
+
1477
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
1478
+ getch();
1479
+ for (i = 0; i < MAXCOL; i++)
1480
+ init_color((short)i, orgcolors[i].red,
1481
+ orgcolors[i].green,
1482
+ orgcolors[i].blue);
1483
+ }
1484
+
1485
+ if (COLORS >= 256) do
1486
+ {
1487
+ int x, y, z, lmarg = (COLS - 77) / 2;
1488
+
1489
+ erase();
1490
+
1491
+ attrset(A_BOLD);
1492
+ mvaddstr(tmarg, (COLS - 15) / 2, "Extended Colors");
1493
+ attrset(A_NORMAL);
1494
+
1495
+ mvaddstr(tmarg + 3, lmarg, "6x6x6 Color Cube (16-231):");
1496
+
1497
+ for (i = 16; i < 256; i++)
1498
+ init_pair(i, COLOR_BLACK, i);
1499
+
1500
+ for (i = 16, z = 0; z < 6; z++)
1501
+ for (y = 0; y < 6; y++)
1502
+ for (x = 0; x < 6; x++)
1503
+ {
1504
+ chtype ch = ' ' | COLOR_PAIR(i++);
1505
+
1506
+ mvaddch(tmarg + 5 + y, z * 13 + x * 2 + lmarg, ch);
1507
+ addch(ch);
1508
+ }
1509
+
1510
+ mvaddstr(tmarg + 13, lmarg, "Greyscale (232-255):");
1511
+
1512
+ for (x = 0; x < 24; x++)
1513
+ {
1514
+ chtype ch = ' ' | COLOR_PAIR(232 + x);
1515
+
1516
+ mvaddch(tmarg + 15, x * 2 + lmarg, ch);
1517
+ addch(ch);
1518
+ }
1519
+
1520
+ #ifdef CHTYPE_LONG
1521
+ attrset( A_LEFTLINE);
1522
+ mvaddstr( tmarg + 17, col1, "A_LEFTLINE");
1523
+ attrset( A_UNDERLINE);
1524
+ mvaddstr( tmarg + 18, col1, "A_UNDERLINE");
1525
+ attrset( A_RIGHTLINE);
1526
+ mvaddstr( tmarg + 19, col1, "A_RIGHTLINE");
1527
+ #endif
1528
+ #ifdef GOT_OVERLINE
1529
+ attrset( A_OVERLINE);
1530
+ mvaddstr( tmarg + 17, col2, "A_OVERLINE");
1531
+ #ifdef GOT_STRIKEOUT
1532
+ attrset( A_STRIKEOUT);
1533
+ mvaddstr( tmarg + 18, col2, "A_STRIKEOUT");
1534
+ #endif
1535
+ attrset( A_OVERLINE | A_UNDERLINE);
1536
+ mvaddstr( tmarg + 19, col2, "Over/underlined");
1537
+ #endif
1538
+ attrset(A_NORMAL);
1539
+ refresh( );
1540
+ ch = getch( );
1541
+ # ifdef PDCURSES
1542
+ if( ch == KEY_RESIZE)
1543
+ resize_term(0, 0);
1544
+ # endif
1545
+ } while( ch == KEY_RESIZE);
1546
+ }
1547
+ #endif
1548
+
1549
+ #if HAVE_WIDE
1550
+ void wideTest(WINDOW *win)
1551
+ {
1552
+ wchar_t tmp[513];
1553
+ size_t i;
1554
+
1555
+ attrset(A_BOLD);
1556
+ mvaddstr(1, (COLS - 25) / 2, "Wide Character Input Test");
1557
+ attrset(A_NORMAL);
1558
+
1559
+ mvaddstr(4, 1, "Enter a string: ");
1560
+
1561
+ echo();
1562
+
1563
+ get_wstr((wint_t *)tmp);
1564
+ addstr("\n\n String:\n\n ");
1565
+ addwstr(tmp);
1566
+ addstr("\n\n\n Hex:\n\n ");
1567
+
1568
+ for (i = 0; i < wcslen(tmp); i++)
1569
+ {
1570
+ printw("%04x ", tmp[i]);
1571
+ addnwstr(tmp + i, 1);
1572
+ addstr(" ");
1573
+ }
1574
+
1575
+ noecho();
1576
+
1577
+ Continue2();
1578
+ }
1579
+ #endif
1580
+
1581
+ void display_menu(int old_option, int new_option)
1582
+ {
1583
+ int lmarg = (COLS - 14) / 2,
1584
+ tmarg = (LINES - (MAX_OPTIONS + 2)) / 2;
1585
+
1586
+ if (old_option == -1)
1587
+ {
1588
+ int i;
1589
+
1590
+ attrset(A_BOLD);
1591
+ mvaddstr(tmarg - 3, lmarg - 5, "PDCurses Test Program");
1592
+ attrset(A_NORMAL);
1593
+
1594
+ for (i = 0; i < MAX_OPTIONS; i++)
1595
+ mvaddstr(tmarg + i, lmarg, command[i].text);
1596
+ }
1597
+ else
1598
+ mvaddstr(tmarg + old_option, lmarg, command[old_option].text);
1599
+
1600
+ attrset(A_REVERSE);
1601
+ mvaddstr(tmarg + new_option, lmarg, command[new_option].text);
1602
+ attrset(A_NORMAL);
1603
+
1604
+ mvaddstr(tmarg + MAX_OPTIONS + 2, lmarg - 23,
1605
+ "Use Up and Down Arrows to select - Enter to run - Q to quit");
1606
+ refresh();
1607
+ }