curses 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) 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/History.md +34 -0
  6. data/README.md +14 -46
  7. data/Rakefile +0 -86
  8. data/curses.gemspec +2 -3
  9. data/ext/curses/curses.c +70 -58
  10. data/ext/curses/extconf.rb +134 -21
  11. data/lib/curses.rb +5 -12
  12. data/sample/addch.rb +16 -0
  13. data/sample/attr_demo.rb +32 -0
  14. data/sample/colors.rb +26 -0
  15. data/sample/menu.rb +3 -3
  16. data/sample/mouse_move.rb +75 -0
  17. data/vendor/PDCurses/.gitignore +47 -0
  18. data/vendor/PDCurses/.travis.yml +49 -0
  19. data/vendor/PDCurses/CMakeLists.txt +68 -0
  20. data/vendor/PDCurses/HISTORY.md +2036 -0
  21. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  22. data/vendor/PDCurses/README.md +77 -0
  23. data/vendor/PDCurses/acs_defs.h +265 -0
  24. data/vendor/PDCurses/appveyor.yml +218 -0
  25. data/vendor/PDCurses/cmake/README.md +71 -0
  26. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  27. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  28. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  29. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  30. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  31. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  32. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  33. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  34. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  35. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  36. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  38. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  39. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  40. data/vendor/PDCurses/curses.h +1846 -0
  41. data/vendor/PDCurses/curspriv.h +134 -0
  42. data/vendor/PDCurses/demos/README.md +25 -0
  43. data/vendor/PDCurses/demos/firework.c +144 -0
  44. data/vendor/PDCurses/demos/newtest.c +581 -0
  45. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  46. data/vendor/PDCurses/demos/ptest.c +283 -0
  47. data/vendor/PDCurses/demos/rain.c +157 -0
  48. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  49. data/vendor/PDCurses/demos/tui.c +1048 -0
  50. data/vendor/PDCurses/demos/tui.h +65 -0
  51. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  52. data/vendor/PDCurses/demos/version.c +61 -0
  53. data/vendor/PDCurses/demos/worm.c +432 -0
  54. data/vendor/PDCurses/demos/xmas.c +955 -0
  55. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  56. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  57. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  58. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  59. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  60. data/vendor/PDCurses/dos/README.md +51 -0
  61. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  62. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  63. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  64. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  65. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  66. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  67. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  68. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  69. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  70. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  71. data/vendor/PDCurses/libobjs.mif +26 -0
  72. data/vendor/PDCurses/makedist.mif +20 -0
  73. data/vendor/PDCurses/man/README.md +21 -0
  74. data/vendor/PDCurses/man/intro.md +361 -0
  75. data/vendor/PDCurses/man/manext.c +119 -0
  76. data/vendor/PDCurses/man/sdl.md +152 -0
  77. data/vendor/PDCurses/man/sdl2.md +58 -0
  78. data/vendor/PDCurses/man/x11.md +407 -0
  79. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  80. data/vendor/PDCurses/ncurses/README.md +26 -0
  81. data/vendor/PDCurses/ncurses/makefile +29 -0
  82. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  83. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  84. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  85. data/vendor/PDCurses/os2/README.md +43 -0
  86. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  87. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  88. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  89. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  90. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  91. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  92. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  93. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  94. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  95. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  96. data/vendor/PDCurses/panel.h +56 -0
  97. data/vendor/PDCurses/pdcurses/README.md +25 -0
  98. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  99. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  100. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  101. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  102. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  103. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  104. data/vendor/PDCurses/pdcurses/border.c +411 -0
  105. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  106. data/vendor/PDCurses/pdcurses/color.c +298 -0
  107. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  108. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  109. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  110. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  111. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  112. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  113. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  114. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  115. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  116. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  117. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  118. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  119. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  120. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  121. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  122. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  123. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  124. data/vendor/PDCurses/pdcurses/move.c +57 -0
  125. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  126. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  127. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  128. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  129. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  130. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  131. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  132. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  133. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  134. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  135. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  136. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  137. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  138. data/vendor/PDCurses/pdcurses/util.c +312 -0
  139. data/vendor/PDCurses/pdcurses/window.c +569 -0
  140. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  141. data/vendor/PDCurses/sdl1/README.md +31 -0
  142. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  143. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  144. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  145. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  146. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  147. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  148. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  149. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  150. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  151. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  152. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  153. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  154. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  155. data/vendor/PDCurses/sdl2/README.md +34 -0
  156. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  157. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  158. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  159. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  160. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  161. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  162. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  163. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  164. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  165. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  166. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  167. data/vendor/PDCurses/term.h +48 -0
  168. data/vendor/PDCurses/version.mif +7 -0
  169. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  170. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  171. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  172. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  173. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  174. data/vendor/PDCurses/vt/README.md +64 -0
  175. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  176. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  177. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  178. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  179. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  180. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  181. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  182. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  183. data/vendor/PDCurses/watcom.mif +68 -0
  184. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  185. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  186. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  187. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  188. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  189. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  190. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  191. data/vendor/PDCurses/wincon/README.md +85 -0
  192. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  193. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  194. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  195. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  196. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  197. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  198. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  199. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  200. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  201. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  202. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  203. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  204. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  205. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  206. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  207. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  208. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  209. data/vendor/PDCurses/wingui/README.md +93 -0
  210. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  211. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  212. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  213. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  214. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  215. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  216. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  217. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  218. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  219. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  220. data/vendor/PDCurses/x11/Makefile.in +754 -0
  221. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  222. data/vendor/PDCurses/x11/README.md +62 -0
  223. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  224. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  225. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  226. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  227. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  228. data/vendor/PDCurses/x11/compose.h +201 -0
  229. data/vendor/PDCurses/x11/config.guess +1500 -0
  230. data/vendor/PDCurses/x11/config.h.in +100 -0
  231. data/vendor/PDCurses/x11/config.sub +1616 -0
  232. data/vendor/PDCurses/x11/configure +6700 -0
  233. data/vendor/PDCurses/x11/configure.ac +295 -0
  234. data/vendor/PDCurses/x11/debian/changelog +6 -0
  235. data/vendor/PDCurses/x11/debian/compat +1 -0
  236. data/vendor/PDCurses/x11/debian/control +11 -0
  237. data/vendor/PDCurses/x11/debian/copyright +27 -0
  238. data/vendor/PDCurses/x11/debian/rules +98 -0
  239. data/vendor/PDCurses/x11/install-sh +253 -0
  240. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  241. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  242. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  243. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  244. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  245. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  246. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  247. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  248. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  249. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  250. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  251. data/vendor/PDCurses/x11/sb.c +155 -0
  252. data/vendor/PDCurses/x11/x11.c +3686 -0
  253. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  254. metadata +258 -24
  255. data/.travis.yml +0 -16
  256. data/appveyor.yml +0 -16
@@ -0,0 +1,447 @@
1
+ /*
2
+ * ozdemo.c - A demo program using PDCurses. The program
3
+ * illustrates the use of colors for text output.
4
+ *
5
+ * Hacks by jbuhler@cs.washington.edu on 12/29/96
6
+ */
7
+
8
+ #include <stdio.h>
9
+ #include <signal.h>
10
+ #include <string.h>
11
+ #include <curses.h>
12
+ #include <stdlib.h>
13
+ #include <assert.h>
14
+ #include <time.h>
15
+
16
+ int WaitForUser(void);
17
+ int SubWinTest(WINDOW *);
18
+ int BouncingBalls(WINDOW *);
19
+ void trap(int);
20
+
21
+ /* An ASCII map of Australia */
22
+
23
+ char *AusMap[17] =
24
+ {
25
+ " A ",
26
+ " AA AA ",
27
+ " N.T. AAAAA AAAA ",
28
+ " AAAAAAAAAAA AAAAAAAA ",
29
+ " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
30
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
31
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
32
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
33
+ " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
34
+ "W.A. AAAAAAAAA AAAAAA Vic.",
35
+ " AAA S.A. AA",
36
+ " A Tas.",
37
+ ""
38
+ };
39
+
40
+ /* Funny messages for the scroller */
41
+
42
+ char *messages[] =
43
+ {
44
+ "Hello from the Land Down Under",
45
+ "The Land of crocs, and a big Red Rock",
46
+ "Where the sunflower runs along the highways",
47
+ "The dusty red roads lead one to loneliness",
48
+ "Blue sky in the morning and",
49
+ "Freezing nights and twinkling stars",
50
+ NULL
51
+ };
52
+
53
+ int WaitForUser(void)
54
+ {
55
+ chtype ch;
56
+
57
+ nodelay(stdscr, TRUE);
58
+ halfdelay(50);
59
+
60
+ ch = getch();
61
+
62
+ nodelay(stdscr, FALSE);
63
+ nocbreak(); /* Reset the halfdelay() value */
64
+ cbreak();
65
+
66
+ return (ch == '\033') ? '\033' : 0;
67
+ }
68
+
69
+ int SubWinTest(WINDOW *win)
70
+ {
71
+ WINDOW *swin1, *swin2, *swin3;
72
+ int w, h, sw, sh, bx, by;
73
+
74
+ wattrset(win, 0);
75
+ getmaxyx(win, h, w);
76
+ getbegyx(win, by, bx);
77
+
78
+ sw = w / 3;
79
+ sh = h / 3;
80
+
81
+ if ((swin1 = derwin(win, sh, sw, 3, 5)) == NULL)
82
+ return 1;
83
+ if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL)
84
+ return 1;
85
+ if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL)
86
+ return 1;
87
+
88
+ init_pair(8, COLOR_RED, COLOR_BLUE);
89
+ wbkgd(swin1, COLOR_PAIR(8));
90
+ werase(swin1);
91
+ mvwaddstr(swin1, 0, 3, "Sub-window 1");
92
+ wrefresh(swin1);
93
+
94
+ init_pair(9, COLOR_CYAN, COLOR_MAGENTA);
95
+ wbkgd(swin2, COLOR_PAIR(9));
96
+ werase(swin2);
97
+ mvwaddstr(swin2, 0, 3, "Sub-window 2");
98
+ wrefresh(swin2);
99
+
100
+ init_pair(10, COLOR_YELLOW, COLOR_GREEN);
101
+ wbkgd(swin3, COLOR_PAIR(10));
102
+ werase(swin3);
103
+ mvwaddstr(swin3, 0, 3, "Sub-window 3");
104
+ wrefresh(swin3);
105
+
106
+ delwin(swin1);
107
+ delwin(swin2);
108
+ delwin(swin3);
109
+ WaitForUser();
110
+
111
+ return 0;
112
+ }
113
+
114
+ int BouncingBalls(WINDOW *win)
115
+ {
116
+ chtype c1, c2, c3, ball1, ball2, ball3;
117
+ int w, h, x1, y1, xd1, yd1, x2, y2, xd2, yd2, x3, y3, xd3, yd3, c;
118
+
119
+ curs_set(0);
120
+
121
+ wbkgd(win, COLOR_PAIR(1));
122
+ wrefresh(win);
123
+ wattrset(win, 0);
124
+
125
+ init_pair(11, COLOR_RED, COLOR_GREEN);
126
+ init_pair(12, COLOR_BLUE, COLOR_RED);
127
+ init_pair(13, COLOR_YELLOW, COLOR_WHITE);
128
+
129
+ ball1 = 'O' | COLOR_PAIR(11);
130
+ ball2 = '*' | COLOR_PAIR(12);
131
+ ball3 = '@' | COLOR_PAIR(13);
132
+
133
+ getmaxyx(win, h, w);
134
+
135
+ x1 = 2 + rand() % (w - 4);
136
+ y1 = 2 + rand() % (h - 4);
137
+ x2 = 2 + rand() % (w - 4);
138
+ y2 = 2 + rand() % (h - 4);
139
+ x3 = 2 + rand() % (w - 4);
140
+ y3 = 2 + rand() % (h - 4);
141
+
142
+ xd1 = 1;
143
+ yd1 = 1;
144
+ xd2 = 1;
145
+ yd2 = -1;
146
+ xd3 = -1;
147
+ yd3 = 1;
148
+
149
+ nodelay(stdscr, TRUE);
150
+
151
+ while ((c = getch()) == ERR)
152
+ {
153
+ x1 += xd1;
154
+ if (x1 <= 1 || x1 >= w - 2)
155
+ xd1 *= -1;
156
+
157
+ y1 += yd1;
158
+ if (y1 <= 1 || y1 >= h - 2)
159
+ yd1 *= -1;
160
+
161
+ x2 += xd2;
162
+ if (x2 <= 1 || x2 >= w - 2)
163
+ xd2 *= -1;
164
+
165
+ y2 += yd2;
166
+ if (y2 <= 1 || y2 >= h - 2)
167
+ yd2 *= -1;
168
+
169
+ x3 += xd3;
170
+ if (x3 <= 1 || x3 >= w - 2)
171
+ xd3 *= -1;
172
+
173
+ y3 += yd3;
174
+ if (y3 <= 1 || y3 >= h - 2)
175
+ yd3 *= -1;
176
+
177
+ c1 = mvwinch(win, y1, x1);
178
+ c2 = mvwinch(win, y2, x2);
179
+ c3 = mvwinch(win, y3, x3);
180
+
181
+ mvwaddch(win, y1, x1, ball1);
182
+ mvwaddch(win, y2, x2, ball2);
183
+ mvwaddch(win, y3, x3, ball3);
184
+
185
+ wmove(win, 0, 0);
186
+ wrefresh(win);
187
+
188
+ mvwaddch(win, y1, x1, c1);
189
+ mvwaddch(win, y2, x2, c2);
190
+ mvwaddch(win, y3, x3, c3);
191
+
192
+ napms(150);
193
+ }
194
+
195
+ nodelay(stdscr, FALSE);
196
+ ungetch(c);
197
+ return 0;
198
+ }
199
+
200
+ /* Trap interrupt */
201
+
202
+ void trap(int sig)
203
+ {
204
+ if (sig == SIGINT)
205
+ {
206
+ endwin();
207
+
208
+ exit(0);
209
+ }
210
+ }
211
+
212
+ int main(int argc, char **argv)
213
+ {
214
+ WINDOW *win;
215
+ chtype save[80], ch;
216
+ int width, height, w, x, y, i, j, seed;
217
+ const char *versions =
218
+ " DOS, OS/2, Windows console & GUI, X11, SDL 1/2, VT";
219
+ const char *hit_any_key =
220
+ " Type a key to continue or ESC to quit ";
221
+
222
+ assert( strlen( versions) == strlen( hit_any_key));
223
+ #ifdef PDCURSES
224
+ #ifdef PDC_VER_MAJOR /* so far only seen in 4.0+ */
225
+ PDC_set_resize_limits( 20, 50, 70, 200);
226
+ #endif
227
+ #endif
228
+
229
+ #ifdef XCURSES
230
+ Xinitscr(argc, argv);
231
+ #else
232
+ initscr();
233
+ #endif
234
+ seed = (int)time((time_t *)0);
235
+ srand(seed);
236
+
237
+ start_color();
238
+ # if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
239
+ use_default_colors();
240
+ # endif
241
+ cbreak();
242
+ noecho();
243
+
244
+ curs_set(0);
245
+
246
+ #if !defined(__TURBOC__) && !defined(OS2)
247
+ signal(SIGINT, trap);
248
+ #endif
249
+ noecho();
250
+
251
+ /* refresh stdscr so that reading from it will not cause it to
252
+ overwrite the other windows that are being created */
253
+
254
+ refresh();
255
+
256
+ /* Create a drawing window */
257
+
258
+ width = strlen( versions) + 4;
259
+ height = 18;
260
+
261
+ win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
262
+
263
+ if (win == NULL)
264
+ {
265
+ endwin();
266
+
267
+ return 1;
268
+ }
269
+
270
+ for (;;)
271
+ {
272
+
273
+
274
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
275
+ wbkgd(win, COLOR_PAIR(1));
276
+ werase(win);
277
+
278
+ init_pair(2, COLOR_RED, COLOR_RED);
279
+ wattrset(win, COLOR_PAIR(2));
280
+ box(win, ' ', ' ');
281
+ wrefresh(win);
282
+
283
+ wattrset(win, 0);
284
+
285
+ /* Do random output of a character */
286
+
287
+ ch = 'a';
288
+
289
+ nodelay(stdscr, TRUE);
290
+
291
+ for (i = 0; i < 5000; ++i)
292
+ {
293
+ x = rand() % (width - 2) + 1;
294
+ y = rand() % (height - 2) + 1;
295
+
296
+ mvwaddch(win, y, x, ch);
297
+ wrefresh(win);
298
+
299
+ if (getch() != ERR)
300
+ break;
301
+ napms( 1);
302
+
303
+ if (i == 2000)
304
+ {
305
+ ch = 'b';
306
+ init_pair(3, COLOR_CYAN, COLOR_YELLOW);
307
+ wattrset(win, COLOR_PAIR(3));
308
+ }
309
+ }
310
+
311
+ nodelay(stdscr, FALSE);
312
+
313
+ SubWinTest(win);
314
+
315
+ /* Erase and draw green window */
316
+
317
+ init_pair(4, COLOR_YELLOW, COLOR_GREEN);
318
+ wbkgd(win, COLOR_PAIR(4));
319
+ wattrset(win, A_BOLD);
320
+ werase(win);
321
+ wrefresh(win);
322
+
323
+ /* Draw RED bounding box */
324
+
325
+ wattrset(win, COLOR_PAIR(2));
326
+ box(win, ' ', ' ');
327
+ wrefresh(win);
328
+
329
+ /* Display Australia map */
330
+
331
+ wattrset(win, A_BOLD);
332
+ i = 0;
333
+
334
+ while (*AusMap[i])
335
+ {
336
+ mvwaddstr(win, i + 1, 8, AusMap[i]);
337
+ wrefresh(win);
338
+ napms(100);
339
+ ++i;
340
+ }
341
+
342
+ init_pair(5, COLOR_BLUE, COLOR_WHITE);
343
+ wattrset(win, COLOR_PAIR(5) | A_BLINK);
344
+ mvwaddstr( win, height - 4, 2, longname( ));
345
+ mvwaddstr( win, height - 3, 2, curses_version( ));
346
+ mvwaddstr( win, height - 2, 2, versions);
347
+ wrefresh(win);
348
+
349
+ /* Draw running messages */
350
+
351
+ init_pair(6, COLOR_BLACK, COLOR_WHITE);
352
+ wattrset(win, COLOR_PAIR(6));
353
+ w = width - 2;
354
+ nodelay(win, TRUE);
355
+
356
+ mvwhline(win, height / 2, 1, ' ', w);
357
+
358
+ for (j = 0; messages[j] != NULL; j++)
359
+ {
360
+ char *message = messages[j];
361
+ int msg_len = strlen(message);
362
+ int stop = 0;
363
+ int xpos, start, count, n;
364
+
365
+ for (n = 0; n <= w + msg_len; n++)
366
+ {
367
+ if (n < w)
368
+ {
369
+ xpos = w - n;
370
+ start = 0;
371
+ count = (n > msg_len) ? msg_len : n;
372
+ }
373
+ else
374
+ {
375
+ xpos = 0;
376
+ start = n - w;
377
+ count = (w > msg_len - start) ? msg_len - start : w;
378
+ }
379
+
380
+ mvwaddnstr(win, height / 2, xpos + 1, message + start, count);
381
+ if (xpos + count < w)
382
+ waddstr(win, " ");
383
+
384
+ wrefresh(win);
385
+
386
+ if (wgetch(win) != ERR)
387
+ {
388
+ flushinp();
389
+ stop = 1;
390
+ break;
391
+ }
392
+
393
+ napms(100);
394
+ }
395
+
396
+ if (stop)
397
+ break;
398
+ }
399
+
400
+ j = 0;
401
+
402
+ /* Draw running 'A's across in RED */
403
+
404
+ init_pair(7, COLOR_RED, COLOR_GREEN);
405
+ wattron(win, COLOR_PAIR(7));
406
+
407
+ for (i = 2; i < width - 4; ++i)
408
+ {
409
+ ch = mvwinch(win, 5, i);
410
+ save[j++] = ch;
411
+ ch = ch & 0x7f;
412
+ mvwaddch(win, 5, i, ch);
413
+ }
414
+
415
+ wrefresh(win);
416
+
417
+ /* Put a message up; wait for a key */
418
+
419
+ i = height - 2;
420
+ wattrset(win, COLOR_PAIR(5));
421
+ mvwaddstr(win, i, 2, hit_any_key);
422
+ wrefresh(win);
423
+
424
+ if (WaitForUser() == '\033')
425
+ break;
426
+
427
+ /* Restore the old line */
428
+
429
+ wattrset(win, 0);
430
+
431
+ for (i = 2, j = 0; i < width - 4; ++i)
432
+ mvwaddch(win, 5, i, save[j++]);
433
+
434
+ wrefresh(win);
435
+
436
+ BouncingBalls(win);
437
+
438
+ /* BouncingBalls() leaves a keystroke in the queue */
439
+
440
+ if (WaitForUser() == '\033')
441
+ break;
442
+ }
443
+
444
+ endwin();
445
+
446
+ return 0;
447
+ }
@@ -0,0 +1,283 @@
1
+ #include <curses.h>
2
+ #include <panel.h>
3
+ #include <stdlib.h>
4
+
5
+ PANEL *p1, *p2, *p3, *p4, *p5;
6
+ WINDOW *w4, *w5;
7
+
8
+ long nap_msec = 1;
9
+
10
+ char *mod[] =
11
+ {
12
+ "test ", "TEST ", "(**) ", "*()* ", "<--> ", "LAST "
13
+ };
14
+
15
+ void pflush(void)
16
+ {
17
+ update_panels();
18
+ doupdate();
19
+ }
20
+
21
+ void backfill(void)
22
+ {
23
+ int y, x;
24
+
25
+ erase();
26
+
27
+ for (y = 0; y < LINES - 1; y++)
28
+ for (x = 0; x < COLS; x++)
29
+ printw("%d", (y + x) % 10);
30
+ }
31
+
32
+ void wait_a_while(long msec)
33
+ {
34
+ int c;
35
+
36
+ if (msec != 1)
37
+ timeout(msec);
38
+
39
+ c = getch();
40
+
41
+ if (c == 'q')
42
+ {
43
+ endwin();
44
+ exit(1);
45
+ }
46
+ }
47
+
48
+ void saywhat(const char *text)
49
+ {
50
+ mvprintw(LINES - 1, 0, "%-20.20s", text);
51
+ }
52
+
53
+ /* mkpanel - alloc a win and panel and associate them */
54
+
55
+ PANEL *mkpanel(int rows, int cols, int tly, int tlx)
56
+ {
57
+ WINDOW *win = newwin(rows, cols, tly, tlx);
58
+ PANEL *pan = (PANEL *)0;
59
+
60
+ if (win)
61
+ {
62
+ pan = new_panel(win);
63
+
64
+ if (!pan)
65
+ delwin(win);
66
+ }
67
+
68
+ return pan;
69
+ }
70
+
71
+ void rmpanel(PANEL *pan)
72
+ {
73
+ WINDOW *win = pan->win;
74
+
75
+ del_panel(pan);
76
+ delwin(win);
77
+ }
78
+
79
+ void fill_panel(PANEL *pan)
80
+ {
81
+ WINDOW *win = pan->win;
82
+ char num = *((char *)pan->user + 1);
83
+ int y, x, maxy, maxx;
84
+
85
+ box(win, 0, 0);
86
+ mvwprintw(win, 1, 1, "-pan%c-", num);
87
+ getmaxyx(win, maxy, maxx);
88
+
89
+ for (y = 2; y < maxy - 1; y++)
90
+ for (x = 1; x < maxx - 1; x++)
91
+ mvwaddch(win, y, x, num);
92
+ }
93
+
94
+ int main(int argc, char **argv)
95
+ {
96
+ int itmp, y;
97
+
98
+ if (argc > 1 && atol(argv[1]))
99
+ nap_msec = atol(argv[1]);
100
+
101
+ #ifdef XCURSES
102
+ Xinitscr(argc, argv);
103
+ #else
104
+ initscr();
105
+ #endif
106
+ backfill();
107
+
108
+ for (y = 0; y < 5; y++)
109
+ {
110
+ p1 = mkpanel(10, 10, 0, 0);
111
+ set_panel_userptr(p1, "p1");
112
+
113
+ p2 = mkpanel(14, 14, 5, 5);
114
+ set_panel_userptr(p2, "p2");
115
+
116
+ p3 = mkpanel(6, 8, 12, 12);
117
+ set_panel_userptr(p3, "p3");
118
+
119
+ p4 = mkpanel(10, 10, 10, 30);
120
+ w4 = panel_window(p4);
121
+ set_panel_userptr(p4, "p4");
122
+
123
+ p5 = mkpanel(10, 10, 13, 37);
124
+ w5 = panel_window(p5);
125
+ set_panel_userptr(p5, "p5");
126
+
127
+ fill_panel(p1);
128
+ fill_panel(p2);
129
+ fill_panel(p3);
130
+ fill_panel(p4);
131
+ fill_panel(p5);
132
+ hide_panel(p4);
133
+ hide_panel(p5);
134
+ pflush();
135
+ wait_a_while(nap_msec);
136
+
137
+ saywhat("h3 s1 s2 s4 s5;");
138
+ move_panel(p1, 0, 0);
139
+ hide_panel(p3);
140
+ show_panel(p1);
141
+ show_panel(p2);
142
+ show_panel(p4);
143
+ show_panel(p5);
144
+ pflush();
145
+ wait_a_while(nap_msec);
146
+
147
+ saywhat("s1;");
148
+ show_panel(p1);
149
+ pflush();
150
+ wait_a_while(nap_msec);
151
+
152
+ saywhat("s2;");
153
+ show_panel(p2);
154
+ pflush();
155
+ wait_a_while(nap_msec);
156
+
157
+ saywhat("m2;");
158
+ move_panel(p2, 10, 10);
159
+ pflush();
160
+ wait_a_while(nap_msec);
161
+
162
+ saywhat("s3;");
163
+ show_panel(p3);
164
+ pflush();
165
+ wait_a_while(nap_msec);
166
+
167
+ saywhat("m3;");
168
+ move_panel(p3, 5, 5);
169
+ pflush();
170
+ wait_a_while(nap_msec);
171
+
172
+ saywhat("b3;");
173
+ bottom_panel(p3);
174
+ pflush();
175
+ wait_a_while(nap_msec);
176
+
177
+ saywhat("s4;");
178
+ show_panel(p4);
179
+ pflush();
180
+ wait_a_while(nap_msec);
181
+
182
+ saywhat("s5;");
183
+ show_panel(p5);
184
+ pflush();
185
+ wait_a_while(nap_msec);
186
+
187
+ saywhat("t3;");
188
+ top_panel(p3);
189
+ pflush();
190
+ wait_a_while(nap_msec);
191
+
192
+ saywhat("t1;");
193
+ top_panel(p1);
194
+ pflush();
195
+ wait_a_while(nap_msec);
196
+
197
+ saywhat("t2;");
198
+ top_panel(p2);
199
+ pflush();
200
+ wait_a_while(nap_msec);
201
+
202
+ saywhat("t3;");
203
+ top_panel(p3);
204
+ pflush();
205
+ wait_a_while(nap_msec);
206
+
207
+ saywhat("t4;");
208
+ top_panel(p4);
209
+ pflush();
210
+ wait_a_while(nap_msec);
211
+
212
+ for (itmp = 0; itmp < 6; itmp++)
213
+ {
214
+ saywhat("m4;");
215
+ mvwaddstr(w4, 3, 1, mod[itmp]);
216
+ move_panel(p4, 4, itmp * 10);
217
+ mvwaddstr(w5, 4, 1, mod[itmp]);
218
+ pflush();
219
+ wait_a_while(nap_msec);
220
+
221
+ saywhat("m5;");
222
+ mvwaddstr(w4, 4, 1, mod[itmp]);
223
+ move_panel(p5, 7, itmp * 10 + 6);
224
+ mvwaddstr(w5, 3, 1, mod[itmp]);
225
+ pflush();
226
+ wait_a_while(nap_msec);
227
+ }
228
+
229
+ saywhat("m4;");
230
+ move_panel(p4, 4, itmp * 10);
231
+ pflush();
232
+ wait_a_while(nap_msec);
233
+
234
+ saywhat("t5;");
235
+ top_panel(p5);
236
+ pflush();
237
+ wait_a_while(nap_msec);
238
+
239
+ saywhat("t2;");
240
+ top_panel(p2);
241
+ pflush();
242
+ wait_a_while(nap_msec);
243
+
244
+ saywhat("t1;");
245
+ top_panel(p1);
246
+ pflush();
247
+ wait_a_while(nap_msec);
248
+
249
+ saywhat("d2;");
250
+ rmpanel(p2);
251
+ pflush();
252
+ wait_a_while(nap_msec);
253
+
254
+ saywhat("h3;");
255
+ hide_panel(p3);
256
+ pflush();
257
+ wait_a_while(nap_msec);
258
+
259
+ saywhat("d1;");
260
+ rmpanel(p1);
261
+ pflush();
262
+ wait_a_while(nap_msec);
263
+
264
+ saywhat("d4; ");
265
+ rmpanel(p4);
266
+ pflush();
267
+ wait_a_while(nap_msec);
268
+
269
+ saywhat("d5; ");
270
+ rmpanel(p5);
271
+ pflush();
272
+ wait_a_while(nap_msec);
273
+
274
+ if (nap_msec == 1)
275
+ break;
276
+
277
+ nap_msec = 100L;
278
+ }
279
+
280
+ endwin();
281
+
282
+ return 0;
283
+ } /* end of main */