curses 1.4.4 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/macos.yml +1 -1
- data/.github/workflows/push_gem.yml +48 -0
- data/.github/workflows/ubuntu.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/History.md +23 -0
- data/README.md +7 -0
- data/curses.gemspec +1 -1
- data/ext/curses/curses.c +7 -7
- data/sample/colors.rb +6 -1
- data/sample/form.rb +1 -1
- data/sample/menu.rb +2 -0
- metadata +9 -251
- data/vendor/PDCurses/.gitignore +0 -47
- data/vendor/PDCurses/.travis.yml +0 -49
- data/vendor/PDCurses/CMakeLists.txt +0 -68
- data/vendor/PDCurses/HISTORY.md +0 -2036
- data/vendor/PDCurses/IMPLEMNT.md +0 -327
- data/vendor/PDCurses/Makefile +0 -27
- data/vendor/PDCurses/README.md +0 -77
- data/vendor/PDCurses/acs_defs.h +0 -265
- data/vendor/PDCurses/appveyor.yml +0 -218
- data/vendor/PDCurses/cmake/README.md +0 -71
- data/vendor/PDCurses/cmake/build_dependencies.cmake +0 -178
- data/vendor/PDCurses/cmake/build_options.cmake +0 -25
- data/vendor/PDCurses/cmake/dll_version.cmake +0 -26
- data/vendor/PDCurses/cmake/gen_config_header.cmake +0 -43
- data/vendor/PDCurses/cmake/get_version.cmake +0 -17
- data/vendor/PDCurses/cmake/make_uninstall.cmake +0 -19
- data/vendor/PDCurses/cmake/project_common.cmake +0 -121
- data/vendor/PDCurses/cmake/resource.in.cmake +0 -52
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +0 -83
- data/vendor/PDCurses/cmake/target_arch.cmake +0 -36
- data/vendor/PDCurses/cmake/version.in.cmake +0 -73
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +0 -96
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +0 -106
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +0 -105
- data/vendor/PDCurses/curses.h +0 -1846
- data/vendor/PDCurses/curspriv.h +0 -134
- data/vendor/PDCurses/demos/README.md +0 -25
- data/vendor/PDCurses/demos/firework.c +0 -144
- data/vendor/PDCurses/demos/newtest.c +0 -581
- data/vendor/PDCurses/demos/ozdemo.c +0 -447
- data/vendor/PDCurses/demos/ptest.c +0 -283
- data/vendor/PDCurses/demos/rain.c +0 -157
- data/vendor/PDCurses/demos/testcurs.c +0 -1607
- data/vendor/PDCurses/demos/tui.c +0 -1048
- data/vendor/PDCurses/demos/tui.h +0 -65
- data/vendor/PDCurses/demos/tuidemo.c +0 -233
- data/vendor/PDCurses/demos/version.c +0 -61
- data/vendor/PDCurses/demos/worm.c +0 -432
- data/vendor/PDCurses/demos/xmas.c +0 -955
- data/vendor/PDCurses/dos/CMakeLists.txt +0 -47
- data/vendor/PDCurses/dos/Makefile +0 -105
- data/vendor/PDCurses/dos/Makefile.bcc +0 -83
- data/vendor/PDCurses/dos/Makefile.dmc +0 -257
- data/vendor/PDCurses/dos/Makefile.msc +0 -113
- data/vendor/PDCurses/dos/Makefile.wcc +0 -107
- data/vendor/PDCurses/dos/README.md +0 -51
- data/vendor/PDCurses/dos/bccdos.lrf +0 -9
- data/vendor/PDCurses/dos/mscdos.lrf +0 -50
- data/vendor/PDCurses/dos/pdcclip.c +0 -132
- data/vendor/PDCurses/dos/pdcdisp.c +0 -135
- data/vendor/PDCurses/dos/pdcdos.h +0 -194
- data/vendor/PDCurses/dos/pdcgetsc.c +0 -98
- data/vendor/PDCurses/dos/pdckbd.c +0 -513
- data/vendor/PDCurses/dos/pdcscrn.c +0 -785
- data/vendor/PDCurses/dos/pdcsetsc.c +0 -101
- data/vendor/PDCurses/dos/pdcutil.c +0 -212
- data/vendor/PDCurses/libobjs.mif +0 -26
- data/vendor/PDCurses/makedist.mif +0 -20
- data/vendor/PDCurses/man/Makefile +0 -37
- data/vendor/PDCurses/man/README.md +0 -21
- data/vendor/PDCurses/man/intro.md +0 -361
- data/vendor/PDCurses/man/manext.c +0 -119
- data/vendor/PDCurses/man/sdl.md +0 -152
- data/vendor/PDCurses/man/sdl2.md +0 -58
- data/vendor/PDCurses/man/x11.md +0 -407
- data/vendor/PDCurses/ncurses/CMakeLists.txt +0 -66
- data/vendor/PDCurses/ncurses/README.md +0 -26
- data/vendor/PDCurses/ncurses/makefile +0 -29
- data/vendor/PDCurses/os2/CMakeLists.txt +0 -41
- data/vendor/PDCurses/os2/Makefile +0 -132
- data/vendor/PDCurses/os2/Makefile.bcc +0 -90
- data/vendor/PDCurses/os2/Makefile.wcc +0 -43
- data/vendor/PDCurses/os2/README.md +0 -43
- data/vendor/PDCurses/os2/iccos2.lrf +0 -50
- data/vendor/PDCurses/os2/iccos2.mak +0 -256
- data/vendor/PDCurses/os2/pdcclip.c +0 -188
- data/vendor/PDCurses/os2/pdcdisp.c +0 -93
- data/vendor/PDCurses/os2/pdcgetsc.c +0 -89
- data/vendor/PDCurses/os2/pdckbd.c +0 -521
- data/vendor/PDCurses/os2/pdcos2.h +0 -55
- data/vendor/PDCurses/os2/pdcscrn.c +0 -449
- data/vendor/PDCurses/os2/pdcsetsc.c +0 -112
- data/vendor/PDCurses/os2/pdcutil.c +0 -52
- data/vendor/PDCurses/panel.h +0 -56
- data/vendor/PDCurses/pdcurses/README.md +0 -25
- data/vendor/PDCurses/pdcurses/addch.c +0 -693
- data/vendor/PDCurses/pdcurses/addchstr.c +0 -245
- data/vendor/PDCurses/pdcurses/addstr.c +0 -240
- data/vendor/PDCurses/pdcurses/attr.c +0 -359
- data/vendor/PDCurses/pdcurses/beep.c +0 -68
- data/vendor/PDCurses/pdcurses/bkgd.c +0 -223
- data/vendor/PDCurses/pdcurses/border.c +0 -411
- data/vendor/PDCurses/pdcurses/clear.c +0 -159
- data/vendor/PDCurses/pdcurses/color.c +0 -298
- data/vendor/PDCurses/pdcurses/debug.c +0 -109
- data/vendor/PDCurses/pdcurses/delch.c +0 -96
- data/vendor/PDCurses/pdcurses/deleteln.c +0 -211
- data/vendor/PDCurses/pdcurses/deprec.c +0 -27
- data/vendor/PDCurses/pdcurses/getch.c +0 -417
- data/vendor/PDCurses/pdcurses/getstr.c +0 -474
- data/vendor/PDCurses/pdcurses/getyx.c +0 -139
- data/vendor/PDCurses/pdcurses/inch.c +0 -127
- data/vendor/PDCurses/pdcurses/inchstr.c +0 -214
- data/vendor/PDCurses/pdcurses/initscr.c +0 -367
- data/vendor/PDCurses/pdcurses/inopts.c +0 -324
- data/vendor/PDCurses/pdcurses/insch.c +0 -271
- data/vendor/PDCurses/pdcurses/insstr.c +0 -264
- data/vendor/PDCurses/pdcurses/instr.c +0 -246
- data/vendor/PDCurses/pdcurses/kernel.c +0 -259
- data/vendor/PDCurses/pdcurses/keyname.c +0 -157
- data/vendor/PDCurses/pdcurses/mouse.c +0 -438
- data/vendor/PDCurses/pdcurses/move.c +0 -57
- data/vendor/PDCurses/pdcurses/outopts.c +0 -159
- data/vendor/PDCurses/pdcurses/overlay.c +0 -214
- data/vendor/PDCurses/pdcurses/pad.c +0 -260
- data/vendor/PDCurses/pdcurses/panel.c +0 -633
- data/vendor/PDCurses/pdcurses/printw.c +0 -126
- data/vendor/PDCurses/pdcurses/refresh.c +0 -279
- data/vendor/PDCurses/pdcurses/scanw.c +0 -578
- data/vendor/PDCurses/pdcurses/scr_dump.c +0 -213
- data/vendor/PDCurses/pdcurses/scroll.c +0 -101
- data/vendor/PDCurses/pdcurses/slk.c +0 -591
- data/vendor/PDCurses/pdcurses/termattr.c +0 -182
- data/vendor/PDCurses/pdcurses/terminfo.c +0 -217
- data/vendor/PDCurses/pdcurses/touch.c +0 -163
- data/vendor/PDCurses/pdcurses/util.c +0 -312
- data/vendor/PDCurses/pdcurses/window.c +0 -569
- data/vendor/PDCurses/sdl1/Makefile +0 -129
- data/vendor/PDCurses/sdl1/Makefile.mng +0 -110
- data/vendor/PDCurses/sdl1/README.md +0 -31
- data/vendor/PDCurses/sdl1/deffont.h +0 -385
- data/vendor/PDCurses/sdl1/deficon.h +0 -23
- data/vendor/PDCurses/sdl1/pdcclip.c +0 -131
- data/vendor/PDCurses/sdl1/pdcdisp.c +0 -373
- data/vendor/PDCurses/sdl1/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl1/pdckbd.c +0 -405
- data/vendor/PDCurses/sdl1/pdcscrn.c +0 -414
- data/vendor/PDCurses/sdl1/pdcsdl.h +0 -31
- data/vendor/PDCurses/sdl1/pdcsetsc.c +0 -64
- data/vendor/PDCurses/sdl1/pdcutil.c +0 -40
- data/vendor/PDCurses/sdl1/sdltest.c +0 -79
- data/vendor/PDCurses/sdl2/CMakeLists.txt +0 -76
- data/vendor/PDCurses/sdl2/Makefile +0 -135
- data/vendor/PDCurses/sdl2/Makefile.vc +0 -164
- data/vendor/PDCurses/sdl2/README.md +0 -34
- data/vendor/PDCurses/sdl2/deffont.h +0 -385
- data/vendor/PDCurses/sdl2/deficon.h +0 -23
- data/vendor/PDCurses/sdl2/pdcclip.c +0 -93
- data/vendor/PDCurses/sdl2/pdcdisp.c +0 -534
- data/vendor/PDCurses/sdl2/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl2/pdckbd.c +0 -480
- data/vendor/PDCurses/sdl2/pdcscrn.c +0 -443
- data/vendor/PDCurses/sdl2/pdcsdl.h +0 -33
- data/vendor/PDCurses/sdl2/pdcsetsc.c +0 -67
- data/vendor/PDCurses/sdl2/pdcutil.c +0 -39
- data/vendor/PDCurses/sdl2/sdltest.c +0 -81
- data/vendor/PDCurses/term.h +0 -48
- data/vendor/PDCurses/version.mif +0 -7
- data/vendor/PDCurses/vt/CMakeLists.txt +0 -28
- data/vendor/PDCurses/vt/Makefile +0 -135
- data/vendor/PDCurses/vt/Makefile.bcc +0 -111
- data/vendor/PDCurses/vt/Makefile.dmc +0 -258
- data/vendor/PDCurses/vt/Makefile.vc +0 -144
- data/vendor/PDCurses/vt/Makefile.wcc +0 -107
- data/vendor/PDCurses/vt/README.md +0 -64
- data/vendor/PDCurses/vt/pdcclip.c +0 -20
- data/vendor/PDCurses/vt/pdcdisp.c +0 -284
- data/vendor/PDCurses/vt/pdcgetsc.c +0 -27
- data/vendor/PDCurses/vt/pdckbd.c +0 -394
- data/vendor/PDCurses/vt/pdcscrn.c +0 -434
- data/vendor/PDCurses/vt/pdcsetsc.c +0 -45
- data/vendor/PDCurses/vt/pdcutil.c +0 -43
- data/vendor/PDCurses/vt/pdcvt.h +0 -16
- data/vendor/PDCurses/watcom.mif +0 -68
- data/vendor/PDCurses/wincon/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wincon/Makefile.bcc +0 -88
- data/vendor/PDCurses/wincon/Makefile.dmc +0 -256
- data/vendor/PDCurses/wincon/Makefile.lcc +0 -273
- data/vendor/PDCurses/wincon/Makefile.mng +0 -176
- data/vendor/PDCurses/wincon/Makefile.vc +0 -144
- data/vendor/PDCurses/wincon/Makefile.wcc +0 -51
- data/vendor/PDCurses/wincon/README.md +0 -85
- data/vendor/PDCurses/wincon/pdcclip.c +0 -174
- data/vendor/PDCurses/wincon/pdcdisp.c +0 -143
- data/vendor/PDCurses/wincon/pdcgetsc.c +0 -55
- data/vendor/PDCurses/wincon/pdckbd.c +0 -786
- data/vendor/PDCurses/wincon/pdcscrn.c +0 -717
- data/vendor/PDCurses/wincon/pdcsetsc.c +0 -91
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +0 -28
- data/vendor/PDCurses/wincon/pdcutil.c +0 -41
- data/vendor/PDCurses/wincon/pdcwin.h +0 -31
- data/vendor/PDCurses/wingui/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wingui/Makefile.bcc +0 -85
- data/vendor/PDCurses/wingui/Makefile.dmc +0 -259
- data/vendor/PDCurses/wingui/Makefile.lcc +0 -273
- data/vendor/PDCurses/wingui/Makefile.mng +0 -171
- data/vendor/PDCurses/wingui/Makefile.vc +0 -144
- data/vendor/PDCurses/wingui/Makefile.wcc +0 -51
- data/vendor/PDCurses/wingui/README.md +0 -93
- data/vendor/PDCurses/wingui/pdcclip.c +0 -174
- data/vendor/PDCurses/wingui/pdcdisp.c +0 -718
- data/vendor/PDCurses/wingui/pdcgetsc.c +0 -30
- data/vendor/PDCurses/wingui/pdckbd.c +0 -143
- data/vendor/PDCurses/wingui/pdcscrn.c +0 -2797
- data/vendor/PDCurses/wingui/pdcsetsc.c +0 -89
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +0 -28
- data/vendor/PDCurses/wingui/pdcutil.c +0 -61
- data/vendor/PDCurses/wingui/pdcwin.h +0 -122
- data/vendor/PDCurses/x11/Makefile.in +0 -754
- data/vendor/PDCurses/x11/PDCurses.spec +0 -82
- data/vendor/PDCurses/x11/README.md +0 -62
- data/vendor/PDCurses/x11/ScrollBox.c +0 -319
- data/vendor/PDCurses/x11/ScrollBox.h +0 -51
- data/vendor/PDCurses/x11/ScrollBoxP.h +0 -70
- data/vendor/PDCurses/x11/aclocal.m4 +0 -994
- data/vendor/PDCurses/x11/big_icon.xbm +0 -46
- data/vendor/PDCurses/x11/compose.h +0 -201
- data/vendor/PDCurses/x11/config.guess +0 -1500
- data/vendor/PDCurses/x11/config.h.in +0 -100
- data/vendor/PDCurses/x11/config.sub +0 -1616
- data/vendor/PDCurses/x11/configure +0 -6700
- data/vendor/PDCurses/x11/configure.ac +0 -295
- data/vendor/PDCurses/x11/debian/changelog +0 -6
- data/vendor/PDCurses/x11/debian/compat +0 -1
- data/vendor/PDCurses/x11/debian/control +0 -11
- data/vendor/PDCurses/x11/debian/copyright +0 -27
- data/vendor/PDCurses/x11/debian/rules +0 -98
- data/vendor/PDCurses/x11/install-sh +0 -253
- data/vendor/PDCurses/x11/little_icon.xbm +0 -14
- data/vendor/PDCurses/x11/ncurses_cfg.h +0 -45
- data/vendor/PDCurses/x11/pdcclip.c +0 -173
- data/vendor/PDCurses/x11/pdcdisp.c +0 -85
- data/vendor/PDCurses/x11/pdcgetsc.c +0 -28
- data/vendor/PDCurses/x11/pdckbd.c +0 -104
- data/vendor/PDCurses/x11/pdcscrn.c +0 -258
- data/vendor/PDCurses/x11/pdcsetsc.c +0 -95
- data/vendor/PDCurses/x11/pdcutil.c +0 -52
- data/vendor/PDCurses/x11/pdcx11.c +0 -316
- data/vendor/PDCurses/x11/pdcx11.h +0 -191
- data/vendor/PDCurses/x11/sb.c +0 -155
- data/vendor/PDCurses/x11/x11.c +0 -3686
- data/vendor/PDCurses/x11/xcurses-config.in +0 -81
@@ -1,447 +0,0 @@
|
|
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
|
-
}
|
@@ -1,283 +0,0 @@
|
|
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 */
|