diff options
| author | Peter Wemm <peter@FreeBSD.org> | 1999-08-30 07:58:08 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 1999-08-30 07:58:08 +0000 |
| commit | 99af2e21c73f07587da16d34eb6795f4a46cc5be (patch) | |
| tree | 5df591f7e443330146099aa76e2f474a81669ebf /lib/libncurses/TESTS | |
| parent | 02e1576966f0a3b9300a7269c3e6894e62b1f3ba (diff) | |
Notes
Diffstat (limited to 'lib/libncurses/TESTS')
| -rw-r--r-- | lib/libncurses/TESTS/Makefile | 35 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/README | 21 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/battle.c | 705 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/copy.c | 39 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/corner.c | 16 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/ensor.c | 52 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/firework.c | 113 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/getch.c | 29 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/hanoi.c | 275 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/knight.c | 320 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/ncurses.c | 1121 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/newdemo.c | 350 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/over.c | 120 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/rain.c | 96 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/scroll.c | 30 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/scroll2.c | 91 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/scroll3.c | 51 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/test.c | 27 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/testcurs.c | 532 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/worm.c | 268 | ||||
| -rw-r--r-- | lib/libncurses/TESTS/xmas.c | 1192 |
21 files changed, 0 insertions, 5483 deletions
diff --git a/lib/libncurses/TESTS/Makefile b/lib/libncurses/TESTS/Makefile deleted file mode 100644 index ef6cb997a54c6..0000000000000 --- a/lib/libncurses/TESTS/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -TESTS = test corner ensor getch ncurses hanoi knight rain worm \ - over scroll2 battle newdemo scroll3 xmas copy firework testcurs \ - scroll - -CLEANFILES += $(TESTS) - -LIBS += -lncurses -lmytinfo - -all: $(TESTS) - -$(TESTS): - $(CC) $(CFLAGS) $(LDFLAGS) ${.CURDIR}/${.TARGET}.c -o ${.TARGET} $(LIBS) - -test: test.c -corner: corner.c -ensor: ensor.c -getch: getch.c -ncurses: ncurses.c -hanoi: hanoi.c -knight: knight.c -rain: rain.c -worm: worm.c -over: over.c -scroll2: scroll2.c -battle: battle.c -newdemo: newdemo.c -scroll3: scroll3.c -xmas: xmas.c -copy: copy.c -firework: firework.c -testcurs: testcurs.c -scroll: scroll.c - -.include <bsd.prog.mk> - diff --git a/lib/libncurses/TESTS/README b/lib/libncurses/TESTS/README deleted file mode 100644 index 279c6d8479ba0..0000000000000 --- a/lib/libncurses/TESTS/README +++ /dev/null @@ -1,21 +0,0 @@ -The programs in this directory are designed to test your newest toy :-) -Check the sources for any further details. - -asc.c - tests the line drawing functions -attr.c - display attributes available on the terminal -bs.c - the game of battleship -battle.c - older version of battleship with different interface -caps.c - output a list of all capabilites to stderr (redirect to a file - or it will screw up the terminal) -copy.c - test overlay -gdc.c - Great Digital Clock, gives an example of usng color -getch.c - tests ketpad() and getch() -hanoi.c - the game of hanoi, also an example of using color -knight.c - the game of Knight's Tour -rain.c - rain drops are falling on my head.. -scroll.c - test scrolling region -slk.c - test soft labels -worm.c - worms run all over your screen -firework.c - multi-colored fireworks -newdemo.c - a demo from the PDCurses people -testcurs.c - a test from the PDCurses people diff --git a/lib/libncurses/TESTS/battle.c b/lib/libncurses/TESTS/battle.c deleted file mode 100644 index 5b5a9610def55..0000000000000 --- a/lib/libncurses/TESTS/battle.c +++ /dev/null @@ -1,705 +0,0 @@ -/* - * battle.c - original author: Bruce Holloway - * mods by: Chuck A DeGaul - */ - -#include <unistd.h> -#include <stdlib.h> -#include <ctype.h> -#include <time.h> -#include <signal.h> -#include <ncurses.h> - -#define OTHER 1-turn - -char numbers[] = " 0 1 2 3 4 5 6 7 8 9"; - -char carrier[] = "Aircraft Carrier"; -char battle[] = "Battleship"; -char sub[] = "Submarine"; -char destroy[] = "Destroyer"; -char ptboat[] = "PT Boat"; - -char name[40]; -char dftname[] = "Stranger"; - -struct _ships { - char *name; - char symbol; - char length; - char start; /* Coordinates - 0,0=0; 10,10=100. */ - char dir; /* Direction - 0 = right; 1 = down. */ - char hits; /* How many times has this ship been hit? (-1==sunk) */ -}; - -struct _ships plyship[] = { - { carrier,'A',5,0,0,0 }, - { battle,'B',4,0,0,0 }, - { destroy,'D',3,0,0,0 }, - { sub,'S',3,0,0,0 }, - { ptboat,'P',2,0,0,0 }, -}; - -struct _ships cpuship[] = { - { carrier,'A',5,0,0,0 }, - { battle,'B',4,0,0,0 }, - { destroy,'D',3,0,0,0 }, - { sub,'S',3,0,0,0 }, - { ptboat,'P',2,0,0,0 }, -}; - -char hits[2][100], board[2][100]; /* "Hits" board, and main board. */ - -int srchstep; -int cpuhits; -int cstart, cdir; -int plywon=0, cpuwon=0; /* How many games has each won? */ -int turn; /* 0=player, 1=computer */ -int huntoffs; /* Offset on search strategy */ - -int salvo, blitz, ask, seemiss; /* options */ - -void intro(void); -void initgame(void); -int rnd(int); -void plyplace(struct _ships *); -int getdir(void); -void placeship(struct _ships *, int, int); -int checkplace(struct _ships *, int, int); -void error(char *); -void prompt(void); -char getcoord(void); -void cpuplace(struct _ships *); -int awinna(void); -int plyturn(void); -int hitship(int); -int cputurn(void); -int playagain(void); -void uninitgame(); -int sgetc(char *); -int do_options(int, char *[]); -int scount(int); - -int -main(int argc, char **argv) -{ - do_options(argc, argv); - - intro(); - do { - initgame(); - while(awinna() == -1) { - if (!blitz) { - if (!salvo) { - if (turn) - cputurn(); - else plyturn(); - } else { - register int i; - - i = scount(turn); - while (i--) { - if (turn) - if (cputurn()) - if (awinna() != -1) - i = 0; - else - if(plyturn()) - if (awinna() != -1) - i = 0; - } - } - } else { - while((turn) ? cputurn() : plyturn()); - } - turn = OTHER; - } - } while(playagain()); - uninitgame(); - exit(0); -} - -#define PR addstr - -void -intro() -{ -char *tmpname; - - srand(time(0L)); /* Kick the random number generator */ - - signal(SIGINT,uninitgame); - if(signal(SIGQUIT,SIG_IGN) != SIG_IGN) signal(SIGQUIT,uninitgame); -#if 1 - /* for some bizzare reason, getlogin or cuserid cause havoc with the terminal */ - if ((tmpname = getlogin()) != NULL) { - strcpy(name, tmpname); - } else -#endif - strcpy(name,dftname); - name[0] = toupper(name[0]); - - initscr(); - savetty(); - nonl(); - cbreak(); - noecho(); - clear(); - mvaddstr(4,29,"Welcome to Battleship!"); - move(8,0); -PR(" \\\n"); -PR(" \\ \\ \\\n"); -PR(" \\ \\ \\ \\ \\_____________\n"); -PR(" \\ \\ \\_____________ \\ \\/ |\n"); -PR(" \\ \\/ \\ \\/ |\n"); -PR(" \\/ \\_____/ |__\n"); -PR(" ________________/ |\n"); -PR(" \\ S.S. Penguin |\n"); -PR(" \\ /\n"); -PR(" \\___________________________________________________/\n"); - mvaddstr(20,27,"Hit any key to continue..."); refresh(); - getch(); -} - -void -initgame() -{ -int i; - - clear(); - mvaddstr(0,35,"BATTLESHIP"); - mvaddstr(4,12,"Main Board"); - mvaddstr(6,0,numbers); - move(7,0); - for(i=0; i<10; ++i){ - printw("%c . . . . . . . . . . %c\n",i+'A',i+'A'); - } - mvaddstr(17,0,numbers); - mvaddstr(4,55,"Hit/Miss Board"); - mvaddstr(6,45,numbers); - for(i=0; i<10; ++i){ - mvprintw(7+i,45,"%c . . . . . . . . . . %c",i+'A',i+'A'); - } - mvaddstr(17,45,numbers); - for(turn=0; turn<2; ++turn) - for(i=0; i<100; ++i){ - hits[turn][i] = board[turn][i] = 0; - } - for(turn=0; turn<2; ++turn){ - for(i=0; i<5; ++i) - if (!turn) - plyplace(&plyship[i]); - else - cpuplace(&cpuship[i]); - } - turn = rnd(2); - cstart = cdir = -1; - cpuhits = 0; - srchstep = 3; - huntoffs = rnd(srchstep); -} - -int -rnd(int n) -{ - return(((rand() & 0x7FFF) % n)); -} - -void -plyplace(ss) -struct _ships *ss; -{ -int c, d; - - do { - prompt(); - printw("Place your %s (ex.%c%d) ? ",ss->name,rnd(10)+'A',rnd(10)); - c = getcoord(); - d = getdir(); - } while(!checkplace(ss,c,d)); - placeship(ss,c,d); -} - -int -getdir() -{ - - prompt(); - addstr("What direction (0=right, 1=down) ? "); - return(sgetc("01")-'0'); -} - -void -placeship(ss,c,d) -struct _ships *ss; -int c, d; -{ -int x, y, l, i; - - for(l=0; l<ss->length; ++l){ - i = c + l * ((d) ? 10 : 1); - board[turn][i] = ss->symbol; - x = (i % 10) * 3 + 3; - y = (i / 10) + 7; - if(!turn) mvaddch(y,x,ss->symbol); - } - ss->start = c; - ss->dir = d; - ss->hits = 0; -} - -int -checkplace(ss,c,d) -struct _ships *ss; -int c, d; -{ -int x, y, l; - - x = c%10; y = c/10; - if(((x+ss->length) > 10 && !d) || ((y+ss->length) > 10 && d==1)){ - if(!turn) - switch(rnd(3)){ - case 0: - error("Ship is hanging from the edge of the world"); - break; - case 1: - error("Try fitting it on the board"); - break; - case 2: - error("Figure I won't find it if you put it there?"); - break; - } - return(0); - } - for(l=0; l<ss->length; ++l){ - x = c + l * ((d) ? 10 : 1); - if(board[turn][x]){ - if(!turn) - switch(rnd(3)){ - case 0: - error("There's already a ship there"); - break; - case 1: - error("Collision alert! Aaaaaagh!"); - break; - case 2: - error("Er, Admiral, what about the other ship?"); - break; - } - return(0); - } - } - return(1); -} - -void -error(s) -char *s; -{ - prompt(); - beep(); - printw("%s -- hit any key to continue --",s); - refresh(); - getch(); -} - -void -prompt(){ - move(22,0); - clrtoeol(); -} - -char -getcoord() -{ -int ch, x, y; - -redo: - y = sgetc("ABCDEFGHIJ"); - do { - ch = getch(); - if (ch == 0x7F || ch == 8) { - addstr("\b \b"); - refresh(); - goto redo; - } - } while(ch < '0' || ch > '9'); - addch(x = ch); - refresh(); - return((y-'A')*10+x-'0'); -} - -void -cpuplace(ss) -struct _ships *ss; -{ -int c, d; - - do{ - c = rnd(100); - d = rnd(2); - } while(!checkplace(ss,c,d)); - placeship(ss,c,d); -} - -int -awinna() -{ -int i, j; -struct _ships *ss; - - for (i = 0; i < 2; ++i) { - ss = (i) ? cpuship : plyship; - for(j=0; j<5; ++j, ++ss) - if(ss->length != ss->hits) - break; - if(j == 5) return(OTHER); - } - return(-1); -} - -int -plyturn() -{ -int c, res; -char *m; - - prompt(); - addstr("Where do you want to shoot? "); - c = getcoord(); - if(!(res = hits[turn][c])){ - hits[turn][c] = res = (board[OTHER][c]) ? 'H' : 'M'; - mvaddch(7+c/10,48+3*(c%10),(res=='H') ? 'H' : 'o'); - if(c = hitship(c)){ - prompt(); - switch(rnd(3)){ - case 0: - m = "You sank my %s!"; - break; - case 1: - m = "I have this sinking feeling about my %s...."; - break; - case 2: - m = "Have some mercy for my %s!"; - break; - } - move(23,0); - clrtoeol(); - beep(); - printw(m,cpuship[c-1].name); refresh(); - return(awinna() == -1); - } - } - prompt(); - move(23,0); clrtoeol(); - printw("You %s.",(res=='M')?"missed":"scored a hit"); refresh(); - return(res == 'H'); -} - -int -hitship(c) -int c; -{ -struct _ships *ss; -int sym, i, j; - - ss = (turn) ? plyship : cpuship; - if (!(sym = board[OTHER][c])) return(0); - for (i = 0; i < 5; ++i, ++ss) - if (ss->symbol == sym) { - j = ss->hits; - ++j; - ss->hits = j; - if (j == ss->length) - return(i+1); - return(0); - } -} - -int -cputurn() -{ -int c, res, x, y, i, d; - -redo: - if (cstart == -1){ - if (cpuhits){ - for(i=0, c=rnd(100); i<100; ++i, c = (c+1) % 100) - if(hits[turn][c] == 'H') - break; - if(i != 100){ - cstart = c; - cdir = -1; - goto fndir; - } - } - do { - i = 0; - do{ - while(hits[turn][c=rnd(100)]); - x = c % 10; y = c / 10; - if(++i == 1000) break; - } while(((x+huntoffs) % srchstep) != (y % srchstep)); - if(i == 1000) --srchstep; - } while(i == 1000); - } - else if(cdir == -1){ -fndir: for(i=0, d=rnd(4); i++ < 4; d = (d+1) % 4){ - x = cstart%10; y = cstart/10; - switch(d){ - case 0: ++x; break; - case 1: ++y; break; - case 2: --x; break; - case 3: --y; break; - } - if(x<0 || x>9 || y<0 || y>9) continue; - if(hits[turn][c=y*10+x]) continue; - cdir = -2; - break; - } - if(i == 4){ - cstart = -1; - goto redo; - } - } - else{ - x = cstart%10; y = cstart/10; - switch(cdir){ - case 0: ++x; break; - case 1: ++y; break; - case 2: --x; break; - case 3: --y; break; - } - if(x<0 || x>9 || y<0 || y>9 || hits[turn][y*10+x]){ - cdir = (cdir+2) % 4; - for(;;){ - switch(cdir){ - case 0: ++x; break; - case 1: ++y; break; - case 2: --x; break; - case 3: --y; break; - } - if(x<0 || x>9 || y<0 || y>9){ cstart = -1; - goto redo; - } - if(!hits[turn][y*10+x]) break; - } - } - c = y*10 + x; - } - - if (!ask) { - res = (board[OTHER][c]) ? 'H' : 'M'; - move(21,0); clrtoeol(); - printw("I shoot at %c%d. I %s!",c/10+'A',c%10,(res=='H')?"hit":"miss"); - } else { - for(;;){ - prompt(); - printw("I shoot at %c%d. Do I (H)it or (M)iss? ",c/10+'A',c%10); - res = sgetc("HM"); - if((res=='H' && !board[OTHER][c]) || (res=='M' && board[OTHER][c])){ - error("You lie!"); - continue; - } - break; - } - addch(res); - } - hits[turn][c] = res; - if(res == 'H') { - ++cpuhits; - if(cstart == -1) cdir = -1; - cstart = c; - if(cdir == -2) cdir = d; - mvaddch(7+(c/10),3+3*(c%10),'*'); - if (blitz && !ask) { - refresh(); - sleep(1); - } - } - else { - if (seemiss) { - mvaddch(7+(c/10),3+3*(c%10),' '); - } else { - if(cdir == -2) cdir = -1; - } - } - if(c=hitship(c)){ - cstart = -1; - cpuhits -= plyship[c-1].length; - x = plyship[c-1].start; - d = plyship[c-1].dir; - y = plyship[c-1].length; - for(i=0; i<y; ++i){ - hits[turn][x] = '*'; - x += (d) ? 10 : 1; - } - } - if (salvo && !ask) { - refresh(); - sleep(1); - } - if(awinna() != -1) return(0); - return(res == 'H'); -} - -int -playagain() -{ -int i, x, y, dx, dy, j; - - for(i=0; i<5; ++i){ - x = cpuship[i].start; y = x/10+7; x = (x % 10) * 3 + 48; - dx = (cpuship[i].dir) ? 0 : 3; - dy = (cpuship[i].dir) ? 1 : 0; - for(j=0; j < cpuship[i].length; ++j){ - mvaddch(y,x,cpuship[i].symbol); - x += dx; y += dy; - } - } - - if(awinna()) ++cpuwon; else ++plywon; - i = 18 + strlen(name); - if(plywon >= 10) ++i; - if(cpuwon >= 10) ++i; - mvprintw(2,(80-i)/2,"%s: %d Computer: %d",name,plywon,cpuwon); - - prompt(); - printw((awinna()) ? "Want to be humiliated again, %s? " - : "Going to give me a chance for revenge, %s? ",name); - return(sgetc("YN") == 'Y'); -} - -void -uninitgame(int sig) -{ - refresh(); - endwin(); - exit(0); -} - -int -sgetc(s) -char *s; -{ -char *s1; -int ch; - - refresh(); - for (;;) { - ch = toupper(getch()); - for (s1 = s; *s1 && ch != *s1; ++s1); - if (*s1) { - addch(ch); - refresh(); - return(ch); - } - } -} - -/* - * I should use getopts() from libc.a, but I'm leary that other UNIX - * systems might not have it, although I'd love to use it. - */ - -int -do_options(c,op) -int c; -char *op[]; -{ -register int i; - - if (c > 1) { - for (i=1; i<c; i++) { - switch(op[i][0]) { - default: - case '?': - fprintf(stderr, "Usage: battle [ -s | -b ] [ -a ] [ -m ]\n"); - fprintf(stderr, "\tWhere the options are:\n"); - fprintf(stderr, "\t-s : play a salvo game (mutex with -b)\n"); - fprintf(stderr, "\t-b : play a blitz game (mutex with -s)\n"); - fprintf(stderr, "\t-a : computer asks you for hit/miss\n"); - fprintf(stderr, "\t-m : computer misses are displayed\n"); - exit(1); - break; - case '-': - switch(op[i][1]) { - case 'b': - blitz = 1; - if (salvo == 1) { - fprintf(stderr, - "Bad Arg: -b and -s are mutually exclusive\n"); - exit(1); - } - break; - case 's': - salvo = 1; - if (blitz == 1) { - fprintf(stderr, - "Bad Arg: -s and -b are mutually exclusive\n"); - exit(1); - } - break; - case 'a': - ask = 1; - break; - case 'm': - seemiss = 1; - break; - default: - fprintf(stderr, - "Bad Arg: type \"%s ?\" for usage message\n", op[0]); - exit(1); - } - } - } - fprintf(stdout, "Playing optional game ("); - if (salvo) - fprintf(stdout, "salvo, noblitz, "); - else if (blitz) - fprintf(stdout, "blitz, nosalvo, "); - else - fprintf(stdout, "noblitz, nosalvo, "); - - if (ask) - fprintf(stdout, "ask, "); - else - fprintf(stdout, "noask, "); - - if (seemiss) - fprintf(stdout, "seemiss)\n"); - else - fprintf(stdout, "noseemiss)\n"); - } - else - fprintf(stdout, - "Playing standard game (no blitz, no slavo, no ask, no seemiss)\n"); - sleep(2); - return(0); -} - -int -scount(who) -int who; -{ -int i, shots; -struct _ships *sp; - - if (who) { - /* count cpu shots */ - sp = cpuship; - } else { - /* count player shots */ - sp = plyship; - } - for (i=0, shots = 0; i<5; i++, sp++) { - /* extra test for machines with unsigned chars! */ - if (sp->hits == (char) -1 || sp->hits >= sp->length) { - continue; /* dead ship */ - } else { - shots++; - } - } - return(shots); -} - diff --git a/lib/libncurses/TESTS/copy.c b/lib/libncurses/TESTS/copy.c deleted file mode 100644 index 013f9dbe42376..0000000000000 --- a/lib/libncurses/TESTS/copy.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <ncurses.h> - -main() -{ -WINDOW *win1, *win2; -int h, i; - - initscr(); - cbreak(); - noecho(); - win1 = newwin(20, 50, 0, 20); - for (h = 0; h < 20; h++) - for (i = 0; i < 50; i++) - mvwaddch(win1, h, i, 'X'); - wrefresh(win1); - getch(); - - win2 = newwin(20, 50, 3, 30); - for (h = 0; h < 20; h++) - for (i = 0; i < 50; i++) - mvwaddch(win2, h, i, 'Y'); - wnoutrefresh(win1); - wnoutrefresh(win2); - doupdate(); - getch(); - - /* now, remove window 2 and restore the contents of window 1 */ - i = copywin(win1, win2, 5, 10, 0, 0, 14, 39, 0); - wnoutrefresh(win1); - wnoutrefresh(win2); - printw("copywin returns %d\n", i); - wnoutrefresh(stdscr); - doupdate(); - - getch(); - - endwin(); -} - diff --git a/lib/libncurses/TESTS/corner.c b/lib/libncurses/TESTS/corner.c deleted file mode 100644 index 2ab38a982af8d..0000000000000 --- a/lib/libncurses/TESTS/corner.c +++ /dev/null @@ -1,16 +0,0 @@ -#include <ncurses.h> - -int main() -{ -int i, j; - - initscr(); - - for (i = 0; i < LINES; i++) { - j = mvaddch(i, COLS - 1, 'A' + i); - } - refresh(); - endwin(); - exit(0); -} - diff --git a/lib/libncurses/TESTS/ensor.c b/lib/libncurses/TESTS/ensor.c deleted file mode 100644 index 4eca9cb463c4a..0000000000000 --- a/lib/libncurses/TESTS/ensor.c +++ /dev/null @@ -1,52 +0,0 @@ -#include <ncurses.h> - -main() -{ - int i; - WINDOW *win; - - initscr(); - noecho(); - nonl(); - cbreak(); - - scrollok(stdscr, TRUE); - - for (i=0; i<25; i++) - printw("This is in the background, this should be left alone!\n"); - - refresh(); - win=newwin(10,50,6,20); - scrollok(win,TRUE); - wmove(win,0,0); - whline(win,0,49); - wmove(win,9,0); - whline(win,0,49); - wrefresh(win); - wattrset(win,A_STANDOUT); - mvwprintw(win, 0, 14, " Scrolling Demo! "); - mvwprintw(win, 9, 14, " Scrolling Demo! "); - wattroff(win,A_STANDOUT); - wsetscrreg(win, 1,8); - - mvwprintw(win, 0, 5, " DOWN "); - wmove(win,1,0); - wrefresh(win); - - getch(); - for (i=0; i<25; i++){ wprintw(win, "This is window line test (%d).\n", i); - if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD); - wrefresh(win); } - - mvwprintw(win, 0, 5, " UP "); - wrefresh(win); - getch(); - for (i=0; i<25; i++) { wmove(win,1,0); winsertln(win); - if (i%2) wattrset(win,A_BOLD); else wattroff(win,A_BOLD); - wprintw(win, "Scrolling backwards! (%d)\n", i); wrefresh(win); } - - mvwprintw(win, 0, 5, " DONE "); wrefresh(win); - - endwin(); -} - diff --git a/lib/libncurses/TESTS/firework.c b/lib/libncurses/TESTS/firework.c deleted file mode 100644 index b4975849b593a..0000000000000 --- a/lib/libncurses/TESTS/firework.c +++ /dev/null @@ -1,113 +0,0 @@ -#include <stdio.h> -#include <signal.h> -#include <ncurses.h> -#include <ctype.h> -#include <sys/types.h> -#include <time.h> - -void explode(); - -int main() -{ -int start,end,row,diff,flag,direction,seed; - - initscr(); - if (has_colors()) - start_color(); - seed = time((time_t *)0); - srand(seed); - cbreak(); - for (;;) { - do { - start = rand() % (COLS -3); - end = rand() % (COLS - 3); - start = (start < 2) ? 2 : start; - end = (end < 2) ? 2 : end; - direction = (start > end) ? -1 : 1; - diff = abs(start-end); - } while (diff<2 || diff>=LINES-2); - attrset(A_NORMAL); - for (row=0;row<diff;row++) { - mvprintw(LINES - row,start + (row * direction), - (direction < 0) ? "\\" : "/"); - if (flag++) { - refresh(); - erase(); - flag = 0; - } - } - if (flag++) { - refresh(); - flag = 0; - } - seed = time((time_t *)0); - srand(seed); - explode(LINES-row,start+(diff*direction)); - erase(); - refresh(); - } - endwin(); - exit(0); -} - -void explode(int row, int col) -{ - erase(); - mvprintw(row,col,"-"); - refresh(); - - init_pair(1,get_colour(),COLOR_BLACK); - attrset(COLOR_PAIR(1)); - mvprintw(row-1,col-1," - "); - mvprintw(row,col-1,"-+-"); - mvprintw(row+1,col-1," - "); - refresh(); - - init_pair(1,get_colour(),COLOR_BLACK); - attrset(COLOR_PAIR(1)); - mvprintw(row-2,col-2," --- "); - mvprintw(row-1,col-2,"-+++-"); - mvprintw(row, col-2,"-+#+-"); - mvprintw(row+1,col-2,"-+++-"); - mvprintw(row+2,col-2," --- "); - refresh(); - - init_pair(1,get_colour(),COLOR_BLACK); - attrset(COLOR_PAIR(1)); - mvprintw(row-2,col-2," +++ "); - mvprintw(row-1,col-2,"++#++"); - mvprintw(row, col-2,"+# #+"); - mvprintw(row+1,col-2,"++#++"); - mvprintw(row+2,col-2," +++ "); - refresh(); - - init_pair(1,get_colour(),COLOR_BLACK); - attrset(COLOR_PAIR(1)); - mvprintw(row-2,col-2," # "); - mvprintw(row-1,col-2,"## ##"); - mvprintw(row, col-2,"# #"); - mvprintw(row+1,col-2,"## ##"); - mvprintw(row+2,col-2," # "); - refresh(); - - init_pair(1,get_colour(),COLOR_BLACK); - attrset(COLOR_PAIR(1)); - mvprintw(row-2,col-2," # # "); - mvprintw(row-1,col-2,"# #"); - mvprintw(row, col-2," "); - mvprintw(row+1,col-2,"# #"); - mvprintw(row+2,col-2," # # "); - refresh(); - return; -} - -int get_colour() -{ - int attr; - attr = (rand() % 16)+1; - if (attr == 1 || attr == 9) - attr = COLOR_RED; - if (attr > 8) - attr |= A_BOLD; - return(attr); -} diff --git a/lib/libncurses/TESTS/getch.c b/lib/libncurses/TESTS/getch.c deleted file mode 100644 index 90a0ee42178cc..0000000000000 --- a/lib/libncurses/TESTS/getch.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <ncurses.h> - -main() - { - int c,i; - initscr(); - cbreak(); - noecho(); -#if 1 - wtimeout(stdscr,1000); -#endif - scrollok(stdscr,TRUE); - for (c='A';c<='Z';c++) - for (i=0;i<25;i++) - { - move(i,i); - addch(c); - refresh(); - } - move (0,0); - while ((c=wgetch(stdscr))!='A') - { - if (c == EOF) printw(">>wait for keypress<<"); - else printw(">>%c<<\n",c); - refresh(); - } - endwin(); - } - diff --git a/lib/libncurses/TESTS/hanoi.c b/lib/libncurses/TESTS/hanoi.c deleted file mode 100644 index 8a482d5655c94..0000000000000 --- a/lib/libncurses/TESTS/hanoi.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Name: Towers of Hanoi. - * - * Desc: - * This is a playable copy of towers of hanoi. - * Its sole purpose is to demonstrate my Amiga Curses package. - * This program should compile on any system that has Curses. - * 'hanoi' will give a manual game with 7 playing pieces. - * 'hanoi n' will give a manual game with n playing pieces. - * 'hanoi n a' will give an auto solved game with n playing pieces. - * - * Author: Simon J Raybould (sie@fulcrum.bt.co.uk). - * - * Date: 05.Nov.90 - * - */ - -#include <ncurses.h> - -#define NPEGS 3 /* This is not configurable !! */ -#define MINTILES 3 -#define MAXTILES 9 -#define DEFAULTTILES 7 -#define TOPLINE 6 -#define BASELINE 16 -#define STATUSLINE (LINES-3) -#define LEFTPEG 19 -#define MIDPEG 39 -#define RIGHTPEG 59 - -#define LENTOIND(x) (((x)-1)/2) -#define OTHER(a,b) (3-((a)+(b))) - -struct Peg { - int Length[MAXTILES]; - int Count; -}; - -struct Peg Pegs[NPEGS]; -int PegPos[] = { LEFTPEG, MIDPEG, RIGHTPEG }; -int TileColour[] = { - COLOR_GREEN, /* Length 3 */ - COLOR_MAGENTA, /* Length 5 */ - COLOR_RED, /* Length 7 */ - COLOR_BLUE, /* Length 9 */ - COLOR_CYAN, /* Length 11 */ - COLOR_YELLOW, /* Length 13 */ - COLOR_GREEN, /* Length 15 */ - COLOR_MAGENTA, /* Length 17 */ - COLOR_RED, /* Length 19 */ -}; -int NMoves = 0; - -static unsigned char AutoFlag; - -void InitTiles(), DisplayTiles(), MakeMove(), AutoMove(), Usage(); - -int -main(int argc, char **argv) -{ -int NTiles, FromCol, ToCol; - - switch(argc) { - case 1: - NTiles = DEFAULTTILES; - break; - case 2: - NTiles = atoi(argv[1]); - if (NTiles > MAXTILES || NTiles < MINTILES) { - fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); - exit(1); - } - break; - case 3: - if (strcmp(argv[2], "a")) { - Usage(); - exit(1); - } - NTiles = atoi(argv[1]); - if (NTiles > MAXTILES || NTiles < MINTILES) { - fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); - exit(1); - } - AutoFlag = TRUE; - break; - default: - Usage(); - exit(1); - } - initscr(); - if (!has_colors()) { - puts("terminal doesn't support color."); - exit(1); - } - start_color(); - { - int i; - for (i = 0; i < 9; i++) - init_pair(i+1, COLOR_BLACK, TileColour[i]); - } - cbreak(); - if (LINES < 24) { - fprintf(stderr, "Min screen length 24 lines\n"); - endwin(); - exit(1); - } - if(AutoFlag) - leaveok(stdscr, TRUE); /* Attempt to remove cursor */ - InitTiles(NTiles); - DisplayTiles(); - if(AutoFlag) { - do { - noecho(); - AutoMove(0, 2, NTiles); - } while(!Solved(NTiles)); - sleep(2); - } else { - for(;;) { - if(GetMove(&FromCol, &ToCol)) - break; - if (AutoFlag) { - AutoMove(0, 2, NTiles); - break; - } - if(InvalidMove(FromCol, ToCol)) { - mvaddstr(STATUSLINE, 0, "Invalid Move !!"); - refresh(); - beep(); - continue; - } - MakeMove(FromCol, ToCol); - if(Solved(NTiles)) { - mvprintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves); - refresh(); - sleep(5); - break; - } - } - } - endwin(); -} - -int -InvalidMove(int From, int To) -{ - if(From == To) - return TRUE; - if(!Pegs[From].Count) - return TRUE; - if(Pegs[To].Count && - Pegs[From].Length[Pegs[From].Count-1] > - Pegs[To].Length[Pegs[To].Count-1]) - return TRUE; - return FALSE; -} - -void -InitTiles(int NTiles) -{ -int Size, SlotNo; - - for(Size=NTiles*2+1, SlotNo=0; Size>=3; Size-=2) - Pegs[0].Length[SlotNo++] = Size; - - Pegs[0].Count = NTiles; - Pegs[1].Count = 0; - Pegs[2].Count = 0; -} - -#define gc() {noecho();getch();echo();} - -void -DisplayTiles() -{ - int Line, Peg, SlotNo; - char TileBuf[BUFSIZ]; - - erase(); - mvaddstr(1, 24, "T O W E R S O F H A N O I"); - mvaddstr(3, 34, "SJR 1990"); - mvprintw(19, 5, "Moves : %d", NMoves); - standout(); - mvaddstr(BASELINE, 8, " "); - - for(Line=TOPLINE; Line<BASELINE; Line++) { - mvaddch(Line, LEFTPEG, ' '); - mvaddch(Line, MIDPEG, ' '); - mvaddch(Line, RIGHTPEG, ' '); - } - mvaddch(BASELINE, LEFTPEG, '1'); - mvaddch(BASELINE, MIDPEG, '2'); - mvaddch(BASELINE, RIGHTPEG, '3'); - standend(); - - /* Draw tiles */ - for(Peg=0; Peg<NPEGS; Peg++) { - for(SlotNo=0; SlotNo<Pegs[Peg].Count; SlotNo++) { - memset(TileBuf, ' ', Pegs[Peg].Length[SlotNo]); - TileBuf[Pegs[Peg].Length[SlotNo]] = '\0'; - attrset(COLOR_PAIR(LENTOIND(Pegs[Peg].Length[SlotNo]))); - mvaddstr(BASELINE-(SlotNo+1), - PegPos[Peg]-Pegs[Peg].Length[SlotNo]/2, TileBuf); - } - } - attrset(A_NORMAL); - refresh(); -} - -int -GetMove(int *From, int *To) -{ - mvaddstr(STATUSLINE, 0, "Next move ('q' to quit) from "); - clrtoeol(); - refresh(); - if((*From = getch()) == 'q') - return TRUE; - else if (*From == 'a') { - AutoFlag = TRUE; - return FALSE; - } - *From -= ('0'+1); - addstr(" to "); - clrtoeol(); - refresh(); - if((*To = getch()) == 'q') - return TRUE; - *To -= ('0'+1); - move(STATUSLINE, 0); - clrtoeol(); - refresh(); - return FALSE; -} - -void -MakeMove(int From, int To) -{ - - Pegs[From].Count--; - Pegs[To].Length[Pegs[To].Count] = Pegs[From].Length[Pegs[From].Count]; - Pegs[To].Count++; - NMoves++; - DisplayTiles(); -} - -void -AutoMove(int From, int To, int Num) -{ - - if(Num == 1) { - MakeMove(From, To); - return; - } - AutoMove(From, OTHER(From, To), Num-1); - MakeMove(From, To); - AutoMove(OTHER(From, To), To, Num-1); -} - -int -Solved(int NumTiles) -{ -int i; - - for(i = 1; i < NPEGS; i++) - if (Pegs[i].Count == NumTiles) - return TRUE; - return FALSE; -} - -void -Usage() -{ - fprintf(stderr, "Usage: hanoi [<No Of Tiles>] [a]\n"); - fprintf(stderr, "The 'a' option causes the tower to be solved automatically\n"); -} - diff --git a/lib/libncurses/TESTS/knight.c b/lib/libncurses/TESTS/knight.c deleted file mode 100644 index 73f7b42f9d933..0000000000000 --- a/lib/libncurses/TESTS/knight.c +++ /dev/null @@ -1,320 +0,0 @@ -/* Knights Tour - a brain game */ - -#include <ncurses.h> -#include <signal.h> -#include <ctype.h> -#include <stdlib.h> - -#ifdef __FreeBSD__ -#define srand48 srandom -#define lrand48 random -#endif - -short board [64]; /* the squares */ -char row, column; /* input characters */ -int rw,col; /* numeric equivalent of row and column */ -int curow,curcol; /* current row and column integers */ -int rdif, cdif; /* difference between input and current */ -int j; /* index into board */ - -char script[]={"'_)//,/(-)/__/__(_<_(__),|/|/_///_/_<//_/_)__o__o'______///_(--_(_)___,(_/,_/__(_\0"}; - -int ypos[] ={1,0,1,2,3,0,1,2,2,3,3,2,2,3,2,2,3,3,3,3,3,2,3,3,2,4,5,5, - 4,3,3,2,1,2,3,3,3,2,1,3,3,2,3,3,3,2,1,1,0,1,4,4,4,4,4,4,5,6,7,7, - 7,6,6,6,7,7,7,6,6,6,6,7,7,7,6,7,7,6,6,7,7}; - -int xpos[]={0,1,2,1,0,5,4,3,2,4,6,7,8,8,9,10,10,11,12,13,14,15,15,16, - 16,16,15,14,15,17,18,19,20,20,20,21,22,23,24,23,25,26,27,26,28, - 13,23,25,27,27,2,3,4,5,6,7,4,3,2,1,0,1,2,5,4,5,6,6,7,8,9,8,9,10, - 11,11,12,13,14,14,15}; - -static char *instructions[] = -{ -" Knight's Tour is a board game for one player. It is played on", -"an eight by eight board and is based on the allowable moves that a knight", -"can make in the game of chess. For those who are unfamiliar with the", -"game, a knight may move either on a row or a column but not diagonally.", -"He may move one square in any direction and two squares in a perpendicular", -"direction >or< two squares in any direction and one square in a", -"perpendicular direction. He may not, of course, move off the board.", -"", -" At the beginning of a game you will be asked to either choose a", -"starting square or allow the computer to select a random location.", -"Squares are designated by a letter-number combination where the row is", -"specified by a letter A-H and the numbers 1-8 define a column. Invalid", -"entries are ignored and illegal moves produce a beep at the terminal.", -"", -" The objective is to visit every square on the board. When you claim", -"a square a marker is placed on it to show where you've been. You may", -"not revisit a square that you've landed on before.", -"", -" After each move the program checks to see if you have any legal", -"moves left. If not, the game ends and your squares are counted. If", -"you've made all the squares you win the game. Otherwise, you are told", -"the number of squares you did make.", -"END" -}; - -void init(void); -int play(void); -void drawboard(void); -void dosquares(void); -void getfirst(void); -void getrc(void); -void putstars(void); -int evalmove(void); -int chkmoves(void); -int endgame(void); -int chksqr(int, int); -void instruct(void); -void title(int, int); - -int -main () -{ - init (); - for (;;) - if (!play ()) { - endwin (); - exit (0); - } -} - -void -init () -{ - - srand48 (getpid()); - initscr (); - cbreak (); /* immediate char return */ - noecho (); /* no immediate echo */ - title (1,23); - mvaddstr (23, 25, "Would you like instructions? "); - refresh(); - if ((toupper(getch())) == 'Y') - instruct(); - clear (); -} - -int -play () -{ - drawboard (); /* clear screen and drawboard */ - for (j = 0; j < 64; j++) board[j]=0; - getfirst (); /* get the starting square */ - for (;;) { - getrc(); - if (evalmove()) { - putstars (); - if (!chkmoves()) - return (endgame ()); - } - else beep(); - } -} - -void -drawboard () -{ - erase (); - dosquares (); - refresh (); - mvaddstr (0, 7, "1 2 3 4 5 6 7 8"); - for (j = 0; j < 8; j++) mvaddch (2*j+2, 3, j + 'A'); - refresh (); - mvaddstr (20, 5, "ROW:"); - mvaddstr (20, 27, "COLUMN:"); - mvaddstr (14, 49, "CURRENT ROW"); - mvaddstr (16, 49, "CURRENT COL"); - mvaddstr (22, 5, "A - H or Q to quit"); - mvaddstr (22, 27, "1 - 8 or ESC to cancel row"); - refresh (); - title (1,40); -} - -void -dosquares () -{ - mvaddstr (1, 6, "-------------------------------"); - for (j = 1; j < 9; j++){ - mvaddstr (2*j, 5, "| | | | | | | | |"); - mvaddstr (2*j+1, 6, "-------------------------------"); - } -} - -void -getfirst () /* get first square */ -{ - mvaddstr (23, 25, "(S)elect or (R)andom "); refresh (); - do { - row = toupper(getch()); - } while ((row != 'S') && (row != 'R')); - if (row == 'R') { - rw = lrand48() % 8; - col = lrand48() % 8; - j = 8* rw + col; - row = rw + 'A'; - column = col + '1'; - } - else { - mvaddstr (23, 25, "Enter starting row and column"); - refresh (); - getrc(); /* get row and column */ - } - putstars (); - move (23, 0); - clrtobot(); -} - -void -getrc () /* get row and column */ -{ - noecho (); - do { - mvaddstr (20, 35, " "); - refresh (); - do { - mvaddch (20, 11, ' '); - move (20, 11); - refresh (); - row=toupper(getch()); - if (row == 'Q') { - endwin (); - exit (1); - } - } while ((row < 'A') || (row > 'H')); - addch (row); - move (20, 35); - refresh (); - do { - column=getch(); - if (column == '\033') break; - } while ((column < '1') || (column > '8')); - if (column != '\033') addch (column); - } while (column == '\033'); - refresh(); - rw = row - 'A'; - col= column - '1'; - j = 8 * rw + col; -} - -void -putstars () /* place the stars, update board & currents */ -{ - mvaddch (2*curow+2, 38, ' '); - mvaddch (2*rw+2, 38, '<'); - mvaddch (18, curcol*4+7, ' '); - mvaddch (18, col*4+7, '^'); - curow = rw; - curcol= col; - mvaddstr (2 * rw + 2, 4*col+6, "***"); - mvaddch (14, 61, row); - mvaddch (16, 61, column); - refresh (); - board[j] = 1; -} - -int -evalmove() /* convert row and column to integers */ - /* and evaluate move */ -{ - rdif = rw - curow; - cdif = col - curcol; - rdif = abs(rw - curow); - cdif = abs(col - curcol); - refresh (); - if ((rdif == 1) && (cdif == 2)) if (board [j] == 0) return (1); - if ((rdif == 2) && (cdif == 1)) if (board [j] == 0) return (1); - return (0); -} - -int -chkmoves () /* check to see if valid moves are available */ -{ - if (chksqr(2,1)) return (1); - if (chksqr(2,-1)) return (1); - if (chksqr(-2,1)) return (1); - if (chksqr(-2,-1)) return (1); - if (chksqr(1,2)) return (1); - if (chksqr(1,-2)) return (1); - if (chksqr(-1,2)) return (1); - if (chksqr(-1,-2)) return (1); - return (0); -} - -int -endgame () /* check for filled board or not */ -{ - rw = 0; - for (j = 0; j < 64; j++) if (board[j] != 0) rw+=1; - if (rw == 64) mvaddstr (20, 20, "Congratulations !! You got 'em all"); - else mvprintw (20, 20, "You have ended up with %2d squares",rw); - mvaddstr (21, 25, "Play again ? (y/n) "); - refresh (); - if ((row=tolower(getch())) == 'y') return (1); - else return (0); -} - -#ifndef abs -abs(num) -int num; -{ - if (num < 0) return (-num); - else return (num); -} -#endif - -int -chksqr (int n1, int n2) -{ -int r1, c1; - - r1 = rw + n1; - c1 = col + n2; - if ((r1<0) || (r1>7)) return (0); - if ((c1<0) || (c1>7)) return (0); - if (board[r1*8+c1] == 0) return (1); - else return (0); -} - -void -instruct() -{ -int i; - - clear (); - for (i=0;;i++) { - if ((strcmp(instructions[i],"END"))) mvaddstr (i, 0, instructions[i]); - else { - mvaddstr (23, 25, "Ready to play ? (y/n) "); - refresh(); - if (toupper(getch()) == 'Y') { - clear (); - return; - } else { - clear (); - refresh (); - endwin (); - exit (0); - } - } - } -} - -void -title (y,x) -int y,x; -{ -char c; - - j = 0; - do { - c = script[j]; - if (c == 0) break ; - mvaddch (ypos[j]+y, xpos[j]+x, c); - j++; - } while (c != 0); - refresh (); -} - - diff --git a/lib/libncurses/TESTS/ncurses.c b/lib/libncurses/TESTS/ncurses.c deleted file mode 100644 index 91512360a9da8..0000000000000 --- a/lib/libncurses/TESTS/ncurses.c +++ /dev/null @@ -1,1121 +0,0 @@ -/**************************************************************************** - -NAME - ncurses.c --- ncurses library exerciser - -SYNOPSIS - ncurses - -DESCRIPTION - An interactive test module for the ncurses library. - -AUTHOR - This software is Copyright (C) 1993 by Eric S. Raymond, all rights reserved. -It is issued with ncurses under the same terms and conditions as the ncurses -library source. - -***************************************************************************/ -/*LINTLIBRARY */ -#include <stdio.h> -#include <ctype.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <assert.h> -#include <ncurses.h> - -#define P(s) printw("%s\n", s) -#ifndef CTRL -#define CTRL(x) ((x) & 0x1f) -#endif - -/**************************************************************************** - * - * Character input test - * - ****************************************************************************/ - -static void getch_test(void) -/* test the keypad feature */ -{ -char buf[BUFSIZ]; -unsigned int c; -int incount = 0, firsttime = 0; -bool blocking = TRUE; - - refresh(); - - (void) printw("Delay in 10ths of a second (<CR> for blocking input)? "); - echo(); - getstr(buf); - noecho(); - - if (isdigit(buf[0])) - { - timeout(atoi(buf) * 100); - blocking = FALSE; - } - - c = '?'; - for (;;) - { - if (firsttime++) - { - printw("Key pressed: %04o ", c); - if (c >= KEY_MIN) - { - (void) addstr(keyname(c)); - addch('\n'); - } - else if (c > 0x80) - { - if (isprint(c & ~0x80)) - (void) printw("M-%c", c); - else - (void) printw("M-%s", unctrl(c)); - addstr(" (high-half character)\n"); - } - else - { - if (isprint(c)) - (void) printw("%c (ASCII printable character)\n", c); - else - (void) printw("%s (ASCII control character)\n", unctrl(c)); - } - } - if (c == 'x' || c == 'q') - break; - if (c == '?') - addstr("Type any key to see its keypad value, `q' to quit, `?' for help.\n"); - - while ((c = getch()) == ERR) - if (!blocking) - (void) printw("%05d: input timed out\n", incount++); - } - - timeout(-1); - erase(); - endwin(); -} - -static void attr_test(void) -/* test text attributes */ -{ - refresh(); - - mvaddstr(0, 20, "Character attribute test display"); - - mvaddstr(2,8,"This is STANDOUT mode: "); - attron(A_STANDOUT); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_STANDOUT); - - mvaddstr(4,8,"This is REVERSE mode: "); - attron(A_REVERSE); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_REVERSE); - - mvaddstr(6,8,"This is BOLD mode: "); - attron(A_BOLD); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_BOLD); - - mvaddstr(8,8,"This is UNDERLINE mode: "); - attron(A_UNDERLINE); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_UNDERLINE); - - mvaddstr(10,8,"This is DIM mode: "); - attron(A_DIM); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_DIM); - - mvaddstr(12,8,"This is BLINK mode: "); - attron(A_BLINK); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_BLINK); - - mvaddstr(14,8,"This is BOLD UNDERLINE BLINK mode: "); - attron(A_BOLD|A_BLINK|A_UNDERLINE); - addstr("abcde fghij klmno pqrst uvwxy x"); - attroff(A_BOLD|A_BLINK|A_UNDERLINE); - - attrset(A_NORMAL); - mvaddstr(16,8,"This is NORMAL mode: "); - addstr("abcde fghij klmno pqrst uvwxy x"); - - refresh(); - - move(LINES - 1, 0); - addstr("Press any key to continue... "); - (void) getch(); - - erase(); - endwin(); -} - -/**************************************************************************** - * - * Color support tests - * - ****************************************************************************/ - -static char *colors[] = -{ - "black", - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "white" -}; - -static void color_test(void) -/* generate a color test pattern */ -{ - int i; - - refresh(); - (void) printw("There are %d color pairs\n", COLOR_PAIRS); - - (void) mvprintw(1, 0, - "%dx%d matrix of foreground/background colors, bright *off*\n", - COLORS, COLORS); - for (i = 0; i < COLORS; i++) - mvaddstr(2, (i+1) * 8, colors[i]); - for (i = 0; i < COLORS; i++) - mvaddstr(3 + i, 0, colors[i]); - for (i = 1; i < COLOR_PAIRS; i++) - { - init_pair(i, i % COLORS, i / COLORS); - attron(COLOR_PAIR(i)); - mvaddstr(3 + (i / COLORS), (i % COLORS + 1) * 8, "Hello"); - attrset(A_NORMAL); - } - - (void) mvprintw(COLORS + 4, 0, - "%dx%d matrix of foreground/background colors, bright *on*\n", - COLORS, COLORS); - for (i = 0; i < COLORS; i++) - mvaddstr(5 + COLORS, (i+1) * 8, colors[i]); - for (i = 0; i < COLORS; i++) - mvaddstr(6 + COLORS + i, 0, colors[i]); - for (i = 1; i < COLOR_PAIRS; i++) - { - init_pair(i, i % COLORS, i / COLORS); - attron(COLOR_PAIR(i) | A_BOLD); - mvaddstr(6 + COLORS + (i / COLORS), (i % COLORS + 1) * 8, "Hello"); - attrset(A_NORMAL); - } - - move(LINES - 1, 0); - addstr("Press any key to continue... "); - (void) getch(); - - erase(); - endwin(); -} - -static void color_edit(void) -/* display the color test pattern, without trying to edit colors */ -{ - int i, c, value = 0, current = 0, field = 0, usebase = 0; - - refresh(); - - for (i = 0; i < COLORS; i++) - init_pair(i, COLOR_WHITE, i); - - do { - short red, green, blue; - - attron(A_BOLD); - mvaddstr(0, 20, "Color RGB Value Editing"); - attroff(A_BOLD); - - for (i = 0; i < COLORS; i++) - { - mvprintw(2 + i, 0, "%c %-8s:", - (i == current ? '>' : ' '), - (i < sizeof(colors)/sizeof(colors[0]) ? colors[i] : "")); - attrset(COLOR_PAIR(i)); - addstr(" "); - attrset(A_NORMAL); - - /* - * Note: this refresh should *not* be necessary! It works around - * a bug in attribute handling that apparently causes the A_NORMAL - * attribute sets to interfere with the actual emission of the - * color setting somehow. This needs to be fixed. - */ - refresh(); - - color_content(i, &red, &green, &blue); - addstr(" R = "); - if (current == i && field == 0) attron(A_STANDOUT); - printw("%04d", red); - if (current == i && field == 0) attrset(A_NORMAL); - addstr(", G = "); - if (current == i && field == 1) attron(A_STANDOUT); - printw("%04d", green); - if (current == i && field == 1) attrset(A_NORMAL); - addstr(", B = "); - if (current == i && field == 2) attron(A_STANDOUT); - printw("%04d", blue); - if (current == i && field == 2) attrset(A_NORMAL); - attrset(A_NORMAL); - addstr(")"); - } - - mvaddstr(COLORS + 3, 0, - "Use up/down to select a color, left/right to change fields."); - mvaddstr(COLORS + 4, 0, - "Modify field by typing nnn=, nnn-, or nnn+. ? for help."); - - move(2 + current, 0); - - switch (c = getch()) - { - case KEY_UP: - current = (current == 0 ? (COLORS - 1) : current - 1); - value = 0; - break; - - case KEY_DOWN: - current = (current == (COLORS - 1) ? 0 : current + 1); - value = 0; - break; - - case KEY_RIGHT: - field = (field == 2 ? 0 : field + 1); - value = 0; - break; - - case KEY_LEFT: - field = (field == 0 ? 2 : field - 1); - value = 0; - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - do { - value = value * 10 + (c - '0'); - c = getch(); - } while - (isdigit(c)); - if (c != '+' && c != '-' && c != '=') - beep(); - else - ungetch(c); - break; - - case '+': - usebase = 1; - goto changeit; - - case '-': - value = -value; - usebase = 1; - goto changeit; - - case '=': - usebase = 0; - changeit: - color_content(current, &red, &green, &blue); - if (field == 0) - red = red * usebase + value; - else if (field == 1) - green = green * usebase + value; - else if (field == 2) - blue = blue * usebase + value; - init_color(current, red, green, blue); - break; - - case '?': - erase(); - P(" RGB Value Editing Help"); - P(""); - P("You are in the RGB value editor. Use the arrow keys to select one of"); - P("the fields in one of the RGB triples of the current colors; the one"); - P("currently selected will be reverse-video highlighted."); - P(""); - P("To change a field, enter the digits of the new value; they won't be"); - P("echoed. Finish by typing `='; the change will take effect instantly."); - P("To increment or decrement a value, use the same procedure, but finish"); - P("with a `+' or `-'."); - P(""); - P("To quit, do `x' or 'q'"); - - move(LINES - 1, 0); - addstr("Press any key to continue... "); - (void) getch(); - erase(); - break; - - case 'x': - case 'q': - break; - - default: - beep(); - break; - } - } while - (c != 'x' && c != 'q'); - - erase(); - endwin(); -} - -/**************************************************************************** - * - * Soft-key label test - * - ****************************************************************************/ - -static void slk_test(void) -/* exercise the soft keys */ -{ - int c, fmt = 1; - char buf[9]; - - c = CTRL('l'); - do { - switch(c) - { - case CTRL('l'): - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Soft Key Exerciser"); - attroff(A_BOLD); - - move(2, 0); - P("Available commands are:"); - P(""); - P("^L -- refresh screen"); - P("a -- activate or restore soft keys"); - P("d -- disable soft keys"); - P("c -- set centered format for labels"); - P("l -- set left-justified format for labels"); - P("r -- set right-justified format for labels"); - P("[12345678] -- set label; labels are numbered 1 through 8"); - P("e -- erase stdscr (should not erase labels)"); - P("s -- test scrolling of shortened screen"); - P("x, q -- return to main menu"); - P(""); - P("Note: if activating the soft keys causes your terminal to"); - P("scroll up one line, your terminal auto-scrolls when anything"); - P("is written to the last screen position. The ncurses code"); - P("does not yet handle this gracefully."); - refresh(); - /* fall through */ - - case 'a': - slk_restore(); - break; - - case 'e': - wclear(stdscr); - break; - - case 's': - move(20, 0); - while ((c = getch()) != 'Q') - addch(c); - break; - - case 'd': - slk_clear(); - break; - - case 'l': - fmt = 0; - break; - - case 'c': - fmt = 1; - break; - - case 'r': - fmt = 2; - break; - - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': - (void) mvaddstr(20, 0, "Please enter the label value: "); - wgetnstr(stdscr, buf, 8); - slk_set((c - '0'), buf, fmt); - slk_refresh(); - break; - - case 'x': - case 'q': - goto done; - - default: - beep(); - } - } while - ((c = getch()) != EOF); - - done: - erase(); - endwin(); -} - -/**************************************************************************** - * - * Alternate character-set stuff - * - ****************************************************************************/ - -static void acs_display() -/* display the ACS character set */ -{ - int i, j; - - erase(); - attron(A_BOLD); - mvaddstr(0, 20, "Display of the ACS Character Set"); - attroff(A_BOLD); - refresh(); - -#define ACSY 2 - mvaddstr(ACSY + 0, 0, "ACS_ULCORNER: "); addch(ACS_ULCORNER); - mvaddstr(ACSY + 1, 0, "ACS_LLCORNER: "); addch(ACS_LLCORNER); - mvaddstr(ACSY + 2, 0, "ACS_URCORNER: "); addch(ACS_URCORNER); - mvaddstr(ACSY + 3, 0, "ACS_LRCORNER: "); addch(ACS_LRCORNER); - mvaddstr(ACSY + 4, 0, "ACS_RTEE: "); addch(ACS_RTEE); - mvaddstr(ACSY + 5, 0, "ACS_LTEE: "); addch(ACS_LTEE); - mvaddstr(ACSY + 6, 0, "ACS_BTEE: "); addch(ACS_BTEE); - mvaddstr(ACSY + 7, 0, "ACS_TTEE: "); addch(ACS_TTEE); - mvaddstr(ACSY + 8, 0, "ACS_HLINE: "); addch(ACS_HLINE); - mvaddstr(ACSY + 9, 0, "ACS_VLINE: "); addch(ACS_VLINE); - mvaddstr(ACSY + 10,0, "ACS_PLUS: "); addch(ACS_PLUS); - mvaddstr(ACSY + 11,0, "ACS_S1: "); addch(ACS_S1); - mvaddstr(ACSY + 12,0, "ACS_S9: "); addch(ACS_S9); - - mvaddstr(ACSY + 0, 40, "ACS_DIAMOND: "); addch(ACS_DIAMOND); - mvaddstr(ACSY + 1, 40, "ACS_CKBOARD: "); addch(ACS_CKBOARD); - mvaddstr(ACSY + 2, 40, "ACS_DEGREE: "); addch(ACS_DEGREE); - mvaddstr(ACSY + 3, 40, "ACS_PLMINUS: "); addch(ACS_PLMINUS); - mvaddstr(ACSY + 4, 40, "ACS_BULLET: "); addch(ACS_BULLET); - mvaddstr(ACSY + 5, 40, "ACS_LARROW: "); addch(ACS_LARROW); - mvaddstr(ACSY + 6, 40, "ACS_RARROW: "); addch(ACS_RARROW); - mvaddstr(ACSY + 7, 40, "ACS_DARROW: "); addch(ACS_DARROW); - mvaddstr(ACSY + 8, 40, "ACS_UARROW: "); addch(ACS_UARROW); - mvaddstr(ACSY + 9, 40, "ACS_BOARD: "); addch(ACS_BOARD); - mvaddstr(ACSY + 10,40, "ACS_LANTERN: "); addch(ACS_LANTERN); - mvaddstr(ACSY + 11,40, "ACS_BLOCK: "); addch(ACS_BLOCK); - -#define HYBASE (ACSY + 13) - mvprintw(HYBASE + 1, 0, "High-half characters via echochar:\n"); - for (i = 0; i < 4; i++) - { - move(HYBASE + i + 3, 24); - for (j = 0; j < 32; j++) - echochar(128 + 32 * i + j); - } - - move(LINES - 1, 0); - addstr("Press any key to continue... "); - (void) getch(); - - erase(); - endwin(); -} - -/**************************************************************************** - * - * Windows and scrolling tester. - * - ****************************************************************************/ - -typedef struct -{ - int y, x; -} -pair; - -static void report(void) -/* report on the cursor's current position, then restore it */ -{ - int y, x; - - getyx(stdscr, y, x); - move(LINES - 1, COLS - 17); - printw("Y = %2d X = %2d", y, x); - move(y, x); -} - -static pair *selectcell(uli, ulj, lri, lrj) -/* arrows keys move cursor, return location at current on non-arrow key */ -int uli, ulj, lri, lrj; /* co-ordinates of corners */ -{ - static pair res; /* result cell */ - int si = lri - uli + 1; /* depth of the select area */ - int sj = lrj - ulj + 1; /* width of the select area */ - int i = 0, j = 0; /* offsets into the select area */ - - for (;;) - { - move(LINES - 1, COLS - 17); - printw("Y = %2d X = %2d", uli + i, ulj + j); - move(uli + i, ulj + j); - - switch(getch()) - { - case KEY_UP: i += si - 1; break; - case KEY_DOWN: i++; break; - case KEY_LEFT: j += sj - 1; break; - case KEY_RIGHT: j++; break; - case '\004': return((pair *)NULL); - default: res.y = uli + i; res.x = ulj + j; return(&res); - } - i %= si; - j %= sj; - } -} - -static WINDOW *getwindow(void) -/* Ask user for a window definition */ -{ - WINDOW *rwindow, *bwindow; - pair ul, lr, *tmp; - - move(0, 0); clrtoeol(); - addstr("Use arrows to move cursor, anything else to mark corner 1"); - refresh(); - if ((tmp = selectcell(1, 0, LINES-1, COLS-1)) == (pair *)NULL) - return((WINDOW *)NULL); - memcpy(&ul, tmp, sizeof(pair)); - addch(ACS_ULCORNER); - move(0, 0); clrtoeol(); - addstr("Use arrows to move cursor, anything else to mark corner 2"); - refresh(); - if ((tmp = selectcell(ul.y, ul.x, LINES-1, COLS-1)) == (pair *)NULL) - return((WINDOW *)NULL); - memcpy(&lr, tmp, sizeof(pair)); - - rwindow = newwin(lr.y - ul.y + 1, lr.x - ul.x + 1, ul.y, ul.x); - - bwindow = newwin(lr.y - ul.y + 3, lr.x - ul.x + 3, ul.y - 1, ul.x - 1); - wborder(bwindow, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, - 0, 0, 0, 0); - wrefresh(bwindow); - delwin(bwindow); - - scrollok(rwindow, TRUE); -/* immedok(rwindow); */ - wrefresh(rwindow); - - return(rwindow); -} - -static void acs_and_scroll() -/* Demonstrate windows */ -{ - int c; - struct frame - { - struct frame *next, *last; - WINDOW *wind; - } - *oldw = (struct frame *)NULL, *current = (struct frame *)NULL, *neww; - - refresh(); - mvaddstr(LINES - 2, 0, - "F1 = make new window, F2 = next window, F3 = previous window, Ctrl-D = exit"); - mvaddstr(LINES - 1, 0, - "All other characters are echoed, windows should scroll."); - - c = KEY_F(1); - do { - report(); - if (current) - wrefresh(current->wind); - - switch(c) - { - case KEY_F(1): - neww = (struct frame *) malloc(sizeof(struct frame)); - if ((neww->wind = getwindow()) == (WINDOW *)NULL) - goto breakout; - if (oldw == NULL) /* First element, */ - { - neww->next = neww; /* so point it at itself */ - neww->last = neww; - current = neww; - } - else - { - neww->last = oldw; oldw->next = neww; - neww->next = current; current->last = neww; - } - oldw = neww; - keypad(neww->wind, TRUE); - break; - - case KEY_F(2): - current = current->next; - break; - - case KEY_F(3): - current = current->last; - break; - - case KEY_F(4): /* undocumented --- use this to test area clears */ - selectcell(0, 0, LINES - 1, COLS - 1); - clrtobot(); - refresh(); - break; - - case '\r': - c = '\n'; - /* FALLTHROUGH */ - - default: - waddch(current->wind, c); - break; - } - report(); - wrefresh(current->wind); - } while - ((c = wgetch(current->wind)) != '\004'); - - breakout: - erase(); - endwin(); -} - -#define GRIDSIZE 5 - -static void panner(WINDOW *pad, int iy, int ix, int (*pgetc)(void)) -{ - static int porty, portx, basex = 0, basey = 0; - int pxmax, pymax, c; - WINDOW *vscroll = (WINDOW *)NULL, *hscroll = (WINDOW *)NULL; - - porty = iy; portx = ix; - - getmaxyx(pad, pymax, pxmax); - - if (pymax > porty) - vscroll = newwin(porty - (pxmax > ix), 1, 0, portx - (pymax > iy)); - if (pxmax > portx) - hscroll = newwin(1, portx - (pymax > iy), porty - (pxmax > ix), 0); - - c = KEY_REFRESH; - do { - switch(c) - { - case KEY_REFRESH: - /* do nothing */ - break; - - case KEY_IC: - if (portx >= pxmax || portx >= ix) - beep(); - else - { - mvwin(vscroll, 0, ++portx - 1); - delwin(hscroll); - hscroll = newwin(1, portx - (pymax > porty), - porty - (pxmax > portx), 0); - } - break; - - case KEY_IL: - if (porty >= pymax || porty >= iy) - beep(); - else - { - mvwin(hscroll, ++porty - 1, 0); - delwin(vscroll); - vscroll = newwin(porty - (pxmax > portx), 1, - 0, portx - (pymax > porty)); - } - break; - - case KEY_DC: - if (portx <= 0) - beep(); - else - { - mvwin(vscroll, 0, --portx - 1); - delwin(hscroll); - hscroll = newwin(1, portx - (pymax > porty), - porty - (pxmax > portx), 0); - } - break; - - case KEY_DL: - if (porty <= 0) - beep(); - else - { - mvwin(hscroll, --porty - 1, 0); - delwin(vscroll); - vscroll = newwin(porty - (pxmax > portx), 1, - 0, portx - (pymax > porty)); - } - break; - - case KEY_LEFT: - if (basex > 0) - basex--; - else - beep(); - break; - - case KEY_RIGHT: - if (basex + portx < pxmax) - basex++; - else - beep(); - break; - - case KEY_UP: - if (basey > 0) - basey--; - else - beep(); - break; - - case KEY_DOWN: - if (basey + porty < pymax) - basey++; - else - beep(); - break; - } - - prefresh(pad, - basey, basex, - 0, 0, - porty - (hscroll != (WINDOW *)NULL) - 1, - portx - (vscroll != (WINDOW *)NULL) - 1); - if (vscroll) - { - int lowend, i, highend; - - lowend = basey * ((float)porty / (float)pymax); - highend = (basey + porty) * ((float)porty / (float)pymax); - - touchwin(vscroll); - for (i = 0; i < lowend; i++) - mvwaddch(vscroll, i, 0, ACS_VLINE); - wattron(vscroll, A_REVERSE); - for (i = lowend; i <= highend; i++) - mvwaddch(vscroll, i, 0, ' '); - wattroff(vscroll, A_REVERSE); - for (i = highend + 1; i < porty; i++) - mvwaddch(vscroll, i, 0, ACS_VLINE); - wrefresh(vscroll); - } - if (hscroll) - { - int lowend, j, highend; - - lowend = basex * ((float)portx / (float)pxmax); - highend = (basex + portx) * ((float)portx / (float)pxmax); - - touchwin(hscroll); - for (j = 0; j < lowend; j++) - mvwaddch(hscroll, 0, j, ACS_HLINE); - wattron(hscroll, A_REVERSE); - for (j = lowend; j <= highend; j++) - mvwaddch(hscroll, 0, j, ' '); - wattroff(hscroll, A_REVERSE); - for (j = highend + 1; j < portx; j++) - mvwaddch(hscroll, 0, j, ACS_HLINE); - wrefresh(hscroll); - } - mvaddch(porty - 1, portx - 1, ACS_LRCORNER); - - } while - ((c = pgetc()) != KEY_EXIT); -} - -int padgetch(void) -{ - int c; - - switch(c = getch()) - { - case 'u': return(KEY_UP); - case 'd': return(KEY_DOWN); - case 'r': return(KEY_RIGHT); - case 'l': return(KEY_LEFT); - case '+': return(KEY_IL); - case '-': return(KEY_DL); - case '>': return(KEY_IC); - case '<': return(KEY_DC); - default: return(c); - } -} - -static void demo_pad(void) -/* Demonstrate pads. */ -{ - int i, j, gridcount = 0; - WINDOW *panpad = newpad(200, 200); - - for (i = 0; i < 200; i++) - { - for (j = 0; j < 200; j++) - if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) - { - if (i == 0 || j == 0) - waddch(panpad, '+'); - else - waddch(panpad, 'A' + (gridcount++ % 26)); - } - else if (i % GRIDSIZE == 0) - waddch(panpad, '-'); - else if (j % GRIDSIZE == 0) - waddch(panpad, '|'); - else - waddch(panpad, ' '); - } - mvprintw(LINES - 3, 0, "Use arrow keys to pan over the test pattern"); - mvprintw(LINES - 2, 0, "Use +,- to grow/shrink the panner vertically."); - mvprintw(LINES - 1, 0, "Use <,> to grow/shrink the panner horizontally."); - panner(panpad, LINES - 4, COLS, padgetch); - - endwin(); - erase(); -} - -/**************************************************************************** - * - * Tests from John Burnell's PDCurses tester - * - ****************************************************************************/ - -static void Continue (WINDOW *win) -{ - wmove(win, 10, 1); - mvwaddstr(win, 10, 1, " Press any key to continue"); - wrefresh(win); - wgetch(win); -} - -static void input_test(WINDOW *win) -/* Input test, adapted from John Burnell's PDCurses tester */ -{ - int w, h, bx, by, sw, sh, i; - WINDOW *subWin; - wclear (win); -#ifdef FOO - char buffer [80]; - int num; -#endif /* FOO */ - - w = win->_maxx; - h = win->_maxy; - bx = win->_begx; - by = win->_begy; - sw = w / 3; - sh = h / 3; - if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL) - return; - -#ifdef A_COLOR - if (has_colors()) - { - init_pair(2,COLOR_CYAN,COLOR_BLUE); - wattrset(subWin, COLOR_PAIR(2) | A_BOLD); - } - else - wattrset(subWin, A_BOLD); -#else - wattrset(subWin, A_BOLD); -#endif - box(subWin, ACS_VLINE, ACS_HLINE); -#ifdef FOO - mvwaddstr(subWin, 2, 1, "This is a subwindow"); -#endif /* FOO */ - wrefresh(win); - - nocbreak(); - mvwaddstr(win, 1, 1, "Type random keys for 5 seconds."); - mvwaddstr(win, 2, 1, - "These should be discarded (not echoed) after the subwindow goes away."); - wrefresh(win); - - for (i = 0; i < 5; i++) - { - mvwprintw (subWin, 1, 1, "Time = %d", i); - wrefresh(subWin); - sleep(1); - flushinp(); - } - - delwin (subWin); - werase(win); - flash(); - wrefresh(win); - sleep(1); - - mvwaddstr(win, 2, 1, "Press a key"); - wmove(win, 9, 10); - wrefresh(win); - echo(); - wgetch(win); - flushinp(); - mvwaddstr(win, 12, 0, - "If you see any key other than what you typed, flushinp() is broken."); - Continue(win); - - wmove(win, 9, 10); - wdelch(win); - wrefresh(win); - wmove(win, 12, 0); - clrtoeol(); - waddstr(win, - "What you typed should now have been deleted; if not, wdelch() failed."); - Continue(win); - -#ifdef FOO - /* - * This test won't be portable until vsscanf() is - */ - mvwaddstr(win, 6, 2, "Enter a number then a string separated by space"); - echo(); - mvwscanw(win, 7, 6, "%d %s", &num,buffer); - mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num); -#endif /* FOO */ - - Continue(win); -} - -/**************************************************************************** - * - * Main sequence - * - ****************************************************************************/ - -bool do_single_test(const char c) -/* perform a single specified test */ -{ - switch (c) - { - case 'a': - getch_test(); - return(TRUE); - - case 'b': - attr_test(); - return(TRUE); - - case 'c': - if (!has_colors()) - (void) printf("This %s terminal does not support color.\n", - getenv("TERM")); - else - color_test(); - return(TRUE); - - case 'd': - if (!has_colors()) - (void) printf("This %s terminal does not support color.\n", - getenv("TERM")); - else if (!can_change_color()) - (void) printf("This %s terminal has hardwired color values.\n", - getenv("TERM")); - else - color_edit(); - return(TRUE); - - case 'e': - slk_test(); - return(TRUE); - - case 'f': - acs_display(); - return(TRUE); - - case 'g': - acs_and_scroll(); - return(TRUE); - - case 'p': - demo_pad(); - return(TRUE); - - case 'i': - input_test(stdscr); - return(TRUE); - - case '?': - (void) puts("This is the ncurses capability tester."); - (void) puts("You may select a test from the main menu by typing the"); - (void) puts("key letter of the choice (the letter to left of the =)"); - (void) puts("at the > prompt. The commands `x' or `q' will exit."); - return(TRUE); - } - - return(FALSE); -} - -int main(const int argc, const char *argv[]) -{ - char buf[BUFSIZ]; - - /* enable debugging */ - trace(TRACE_ORDINARY); - - /* tell it we're going to play with soft keys */ - slk_init(1); - - /* we must initialize the curses data structure only once */ - initscr(); - - /* tests, in general, will want these modes */ - start_color(); - cbreak(); - noecho(); - scrollok(stdscr, TRUE); - keypad(stdscr, TRUE); - - /* - * Return to terminal mode, so we're guaranteed of being able to - * select terminal commands even if the capabilities are wrong. - */ - endwin(); - - (void) puts("Welcome to ncurses. Press ? for help."); - - do { - (void) puts("This is the ncurses main menu"); - (void) puts("a = character input test"); - (void) puts("b = character attribute test"); - (void) puts("c = color test pattern"); - (void) puts("d = edit RGB color values"); - (void) puts("e = exercise soft keys"); - (void) puts("f = display ACS characters"); - (void) puts("g = display windows and scrolling"); - (void) puts("p = exercise pad features"); - (void) puts("i = subwindow input test"); - (void) puts("? = get help"); - - (void) fputs("> ", stdout); - (void) fflush(stdout); /* necessary under SVr4 curses */ - (void) fgets(buf, BUFSIZ, stdin); - - if (do_single_test(buf[0])) { - clear(); - refresh(); - endwin(); - continue; - } - } while - (buf[0] != 'q' && buf[0] != 'x'); - - exit(0); -} - -/* ncurses.c ends here */ diff --git a/lib/libncurses/TESTS/newdemo.c b/lib/libncurses/TESTS/newdemo.c deleted file mode 100644 index 6c98c762327a6..0000000000000 --- a/lib/libncurses/TESTS/newdemo.c +++ /dev/null @@ -1,350 +0,0 @@ -/* $FreeBSD$ - * - * newdemo.c - A demo program using PDCurses. The program illustrate - * the use of colours for text output. - */ - -#include <stdio.h> -#include <signal.h> -#include <time.h> -#include <ncurses.h> - -#define delay_output(x) - -/* - * The Australian map - */ -char *AusMap[16] = -{ - " A A ", - " N.T. AAAAA AAAA ", - " AAAAAAAAAAA AAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.", - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ", - " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.", - "W.A. AAAAAAAAA AAAAAA Vic.", - " AAA S.A. AA", - " A Tas.", - "" -}; - -/* - * Funny messages - */ -#define NMESSAGES 6 - -char *messages[] = -{ - "Hello from the Land Down Under", - "The Land of crocs. and a big Red Rock", - "Where the sunflower runs along the highways", - "the dusty red roads lead one to loneliness", - "Blue sky in the morning and", - "freezing nights and twinkling stars", - "" -}; - -/* - * Main driver - */ -main() -{ -WINDOW *win; -int w, x, y, i, j, c, len; -time_t t; -char buffer[80], *message; -int width, height; -chtype save[80]; -void trap(); - - initscr(); - start_color(); - cbreak(); - signal(SIGINT, trap); - width = 48; - height = 14; /* Create a drawing window */ - win = newwin(height, width, (LINES-height)/2, (COLS-width)/2); - if(win == NULL) - { endwin(); - return 1; - } - - while(1) - { init_pair(1,COLOR_WHITE,COLOR_BLUE); - wattrset(win, COLOR_PAIR(1)); - werase(win); - - init_pair(2,COLOR_RED,COLOR_RED); - wattrset(win, COLOR_PAIR(2)); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - /* Do ramdom output of a character */ - wattrset(win, COLOR_PAIR(1)); - c = 'a'; - for(i=0; i < 5000; ++i) - { x = rand() % (width-2) + 1; - y = rand() % (height-2) + 1; - mvwaddch(win, y, x, c); - wrefresh(win); - nodelay(win,TRUE); - if (wgetch(win) != ERR) - break; - if(i == 2000) - { c = 'b'; - init_pair(3,COLOR_CYAN,COLOR_YELLOW); - wattron(win, COLOR_PAIR(3)); - } - } - - SubWinTest(win); - /* Erase and draw green window */ - init_pair(4,COLOR_YELLOW,COLOR_GREEN); - wattrset(win, COLOR_PAIR(4) | A_BOLD); - werase(win); - wrefresh(win); - /* Draw RED bounding box */ - wattrset(win, COLOR_PAIR(2)); - box(win, ' ', ' '); - wrefresh(win); - /* Display Australia map */ - wattrset(win, COLOR_PAIR(4) | A_BOLD); - i = 0; - while(*AusMap[i]) - { mvwaddstr(win, i+1, 8, AusMap[i]); - wrefresh(win); - delay_output(100); - ++i; - } - - init_pair(5,COLOR_BLUE,COLOR_WHITE); - wattrset(win, COLOR_PAIR(5) | A_BLINK); - mvwaddstr(win, height-2, 6, " PDCurses 2.1 for DOS, OS/2 and Unix"); - wrefresh(win); - - /* Draw running messages */ - init_pair(6,COLOR_YELLOW,COLOR_WHITE); - wattrset(win, COLOR_PAIR(6)); - message = messages[0]; - len = strlen(message); - j = 0; - i = 2; - w = width-2; - while(j < NMESSAGES) - { strncpy(buffer, message, w - i); - buffer[w-i] = 0; - mvwaddstr(win, height/2, i, buffer); - if(w - i < len) - { memset(buffer, ' ', i); - strcpy(buffer, message + (w - i)); - buffer[strlen(buffer)] = ' '; - buffer[i-2] = '\0'; - mvwaddstr(win, height/2, 2, buffer); - } - wrefresh(win); - nodelay(win,TRUE); - if (wgetch(win) != ERR) - { flushinp(); - break; - } - mvwaddch(win, height/2, i, ' '); - i = ++i % w; - if(i < 2) - { message = messages[++j%NMESSAGES]; - memset(buffer, ' ', w-2); - buffer[w-2] = 0; - mvwaddstr(win, height/2, 2, buffer); - i = 2; - } - delay_output(300); - } - - j = 0; - /* Draw running As across in RED */ - init_pair(7,COLOR_RED,COLOR_GREEN); - wattron(win, COLOR_PAIR(7)); - for(i=2; i < width - 4; ++i) - { c = mvwinch(win, 4, i); - save[j++] = c; - c = c & 0x7f; - mvwaddch(win, 4, i, c); - } - wrefresh(win); - - /* Put a message up wait for a key */ - i = height-2; - wattrset(win, COLOR_PAIR(5)); - mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit "); - wrefresh(win); - - if(WaitForUser() == 1) - break; - - j = 0; /* Restore the old line */ - for(i=2; i < width - 4; ++i) - mvwaddch(win, 4, i, save[j++]); - wrefresh(win); - - BouncingBalls(win); - /* Put a message up wait for a key */ - i = height-2; - wattrset(win, COLOR_PAIR(5)); - mvwaddstr(win, i, 5, " Type a key to continue or 'Q' to quit "); - wrefresh(win); - if(WaitForUser() == 1) - break; - } -exit: - endwin(); - return 0; -} - -/* - * Test sub windows - */ -SubWinTest(WINDOW *win) -{ -int w, h, sw, sh, bx, by; -WINDOW *swin1, *swin2, *swin3; - - w = win->_maxx; - h = win->_maxy; - bx = win->_begx; - by = win->_begy; - sw = w / 3; - sh = h / 3; - if((swin1 = subwin(win, sh, sw, by+3, bx+5)) == NULL) - return 1; - if((swin2 = subwin(win, sh, sw, by+4, bx+8)) == NULL) - return 1; - if((swin3 = subwin(win, sh, sw, by+5, bx+11)) == NULL) - return 1; - - init_pair(8,COLOR_RED,COLOR_BLUE); - wattrset(swin1, COLOR_PAIR(8)); - werase(swin1); - mvwaddstr(swin1, 0, 3, "Sub-window 1"); - wrefresh(swin1); - - init_pair(8,COLOR_CYAN,COLOR_MAGENTA); - wattrset(swin2, COLOR_PAIR(8)); - werase(swin2); - mvwaddstr(swin2, 0, 3, "Sub-window 2"); - wrefresh(swin2); - - init_pair(8,COLOR_YELLOW,COLOR_GREEN); - wattrset(swin3, COLOR_PAIR(8)); - werase(swin3); - mvwaddstr(swin3, 0, 3, "Sub-window 3"); - wrefresh(swin3); - - delwin(swin1); - delwin(swin2); - delwin(swin3); - WaitForUser(); - return 0; -} - -/* - * Bouncing balls - */ -BouncingBalls(WINDOW *win) -{ -chtype c1, c2, c3; -int w, h; -int x1, y1, xd1, yd1; -int x2, y2, xd2, yd2; -int x3, y3, xd3, yd3; - - w = win->_maxx; - h = win->_maxy; - x1 = 2 + rand() % (w - 4); - y1 = 2 + rand() % (h - 4); - x2 = 2 + rand() % (w - 4); - y2 = 2 + rand() % (h - 4); - x3 = 2 + rand() % (w - 4); - y3 = 2 + rand() % (h - 4); - xd1 = 1; yd1 = 1; - xd2 = 1; yd2 = 0; - xd3 = 0; yd3 = 1; - nodelay(win,TRUE); - while(wgetch(win) == ERR) - { x1 = xd1 > 0 ? ++x1 : --x1; - if(x1 <= 1 || x1 >= w - 2) - xd1 = xd1 ? 0 : 1; - y1 = yd1 > 0 ? ++y1 : --y1; - if(y1 <= 1 || y1 >= h - 2) - yd1 = yd1 ? 0 : 1; - - x2 = xd2 > 0 ? ++x2 : --x2; - if(x2 <= 1 || x2 >= w - 2) - xd2 = xd2 ? 0 : 1; - y2 = yd2 > 0 ? ++y2 : --y2; - if(y2 <= 1 || y2 >= h - 2) - yd2 = yd2 ? 0 : 1; - - x3 = xd3 > 0 ? ++x3 : --x3; - if(x3 <= 1 || x3 >= w - 2) - xd3 = xd3 ? 0 : 1; - y3 = yd3 > 0 ? ++y3 : --y3; - if(y3 <= 1 || y3 >= h - 2) - yd3 = yd3 ? 0 : 1; - - c1 = mvwinch(win, y1, x1); - c2 = mvwinch(win, y2, x2); - c3 = mvwinch(win, y3, x3); - - init_pair(8,COLOR_RED,COLOR_BLUE); - wattrset(win, COLOR_PAIR(8)); - mvwaddch(win, y1, x1, 'O'); - init_pair(8,COLOR_BLUE,COLOR_RED); - wattrset(win, COLOR_PAIR(8)); - mvwaddch(win, y2, x2, '*'); - init_pair(8,COLOR_YELLOW,COLOR_WHITE); - wattrset(win, COLOR_PAIR(8)); - mvwaddch(win, y3, x3, '@'); - wmove(win, 0, 0); - wrefresh(win); - mvwaddch(win, y1, x1, c1); - mvwaddch(win, y2, x2, c2); - mvwaddch(win, y3, x3, c3); - delay_output(150); - } - return 0; -} - -/* - * Wait for user - */ -int WaitForUser() -{ - time_t t; - chtype key; - - nodelay(stdscr,TRUE); - t = time((time_t *)0); - while(1) - { - if ((key = getch()) != ERR) - { - if (key == 'q' || key == 'Q') - return 1; - else - return 0; - } - if (time((time_t *)0) - t > 5) - return 0; - } -} - -/* - * Trap interrupt - */ -void trap() -{ - endwin(); - exit(0); -} - -/* End of DEMO.C */ diff --git a/lib/libncurses/TESTS/over.c b/lib/libncurses/TESTS/over.c deleted file mode 100644 index 5681916ee4d8c..0000000000000 --- a/lib/libncurses/TESTS/over.c +++ /dev/null @@ -1,120 +0,0 @@ -/********************************************************************* - * [program] overwrite() - Play with overwrite() function to * - * attempt pop-up windows. * - * ----------------------------------------------------------------- * - * [written] 1-Feb-1993 by Neal Ensor (ensor@cs.utk.edu) * - * ----------------------------------------------------------------- * - * [notes] Originally written on SVR4 UNIX, then recompiled on * - * Linux (Slackware 1.1.1, ncurses 1.8.1) * - * ----------------------------------------------------------------- * - * [problem] On ncurses, the overwrite() function doesn't seem to * - * overwrite. Maybe I'm missing something, but this * - * program in SVR4 displays three windows, waits for a * - * keypress, then removes the top window. With ncurses, * - * nothing changes on the display. * - *********************************************************************/ - -# include <ncurses.h> /* ncurses include lives here */ - -main() -{ - /**************************************************************** - * Declare three little window pointers... * - ****************************************************************/ - WINDOW *win, *win1, *win2; - - /**************************************************************** - * Set up the screen... * - ****************************************************************/ - initscr(); - /* traceon(); */ - noecho(); - nonl(); - cbreak(); - refresh(); - - /**************************************************************** - * Draw three overlapping windows. * - ****************************************************************/ - win=newwin(6,45, 6,6); - win1=newwin(10,20,5,5); - win2=newwin(10,30,7,7); - - /**************************************************************** - * Box them, and print a hidden message... * - ****************************************************************/ - box(win, 0, 0); - box(win1, 0, 0); - box(win2, 0, 0); - mvwprintw(win1, 6,6, "Hey!"); - mvwaddch(win, 1, 1, '0'); - mvwaddch(win1, 1, 1, '1'); - mvwaddch(win2, 1, 1, '2'); - wnoutrefresh(win); - wnoutrefresh(win1); - wnoutrefresh(win2); - doupdate(); - - /**************************************************************** - * Await a keypress to show what we've done so far. * - ****************************************************************/ - getch(); - - /**************************************************************** - * Now, overwrite win2 with contents of all lower windows IN * - * ORDER from the stdscr up... * - ****************************************************************/ - if (overwrite(stdscr, win2) == ERR) - fprintf(stderr, "overwrite(stdscr, win2) failed!\n"); - - touchwin(stdscr); wnoutrefresh(stdscr); - touchwin(win); wnoutrefresh(win); - touchwin(win1); wnoutrefresh(win1); - touchwin(win2); wnoutrefresh(win2); - doupdate(); - - getch(); - if (overwrite(win, win2) == ERR) - fprintf(stderr, "overwrite(win, win2) failed!\n"); - - touchwin(stdscr); wnoutrefresh(stdscr); - touchwin(win); wnoutrefresh(win); - touchwin(win1); wnoutrefresh(win1); - touchwin(win2); wnoutrefresh(win2); - doupdate(); - - getch(); - if (overwrite(win1, win2) == ERR) - fprintf(stderr, "overwrite(win1, win2) failed!\n"); - - /**************************************************************** - * Perform touches, and hidden refreshes on each window. * - * ------------------------------------------------------------ * - * NOTE: If you replace the wnoutrefresh() call with wrefresh()* - * you can see all windows being redrawn untouched. * - ****************************************************************/ - touchwin(stdscr); wnoutrefresh(stdscr); - touchwin(win); wnoutrefresh(win); - touchwin(win1); wnoutrefresh(win1); - touchwin(win2); wnoutrefresh(win2); - doupdate(); - - /**************************************************************** - * At this point, win2 should be "destroyed"; having all other * - * window contents overwritten onto it. The doupdate() should * - * effectively remove it from the screen, leaving the others * - * untouched. On SVR4, this happens, but not with ncurses. * - * I'd suspect something in overwrite() causes this, as nothing * - * appears to be overwritten after the calls, with no errors * - * being reported. This was compiled on my Linux from Slackware* - * 1.1.1, with ncurses1.8.1 recompiled on it, using the console * - * entry from the "new" terminfo from ncurses1.8.1. * - ****************************************************************/ - getch(); - - /**************************************************************** - * Clean up our act and exit. * - ****************************************************************/ - endwin(); -} - diff --git a/lib/libncurses/TESTS/rain.c b/lib/libncurses/TESTS/rain.c deleted file mode 100644 index 9779d0219998e..0000000000000 --- a/lib/libncurses/TESTS/rain.c +++ /dev/null @@ -1,96 +0,0 @@ -#include <ncurses.h> -#include <signal.h> -/* rain 11/3/1980 EPS/CITHEP */ - -#define cursor(col,row) move(row,col) - -float ranf(); -void onsig(); - -main(argc,argv) -int argc; -char *argv[]; -{ -int x, y, j; -static int xpos[5], ypos[5]; -float r; -float c; - - for (j=SIGHUP;j<=SIGTERM;j++) - if (signal(j,SIG_IGN)!=SIG_IGN) signal(j,onsig); - - initscr(); - nl(); - noecho(); - r = (float)(LINES - 4); - c = (float)(COLS - 4); - for (j=5;--j>=0;) { - xpos[j]=(int)(c* ranf())+2; - ypos[j]=(int)(r* ranf())+2; - } - for (j=0;;) { - x=(int)(c*ranf())+2; - y=(int)(r*ranf())+2; - - cursor(x,y); addch('.'); - - cursor(xpos[j],ypos[j]); addch('o'); - - if (j==0) j=4; else --j; - cursor(xpos[j],ypos[j]); addch('O'); - - if (j==0) j=4; else --j; - cursor(xpos[j],ypos[j]-1); - addch('-'); - cursor(xpos[j]-1,ypos[j]); - addstr("|.|"); - cursor(xpos[j],ypos[j]+1); - addch('-'); - - if (j==0) j=4; else --j; - cursor(xpos[j],ypos[j]-2); - addch('-'); - cursor(xpos[j]-1,ypos[j]-1); - addstr("/ \\"); - cursor(xpos[j]-2,ypos[j]); - addstr("| O |"); - cursor(xpos[j]-1,ypos[j]+1); - addstr("\\ /"); - cursor(xpos[j],ypos[j]+2); - addch('-'); - - if (j==0) j=4; else --j; - cursor(xpos[j],ypos[j]-2); - addch(' '); - cursor(xpos[j]-1,ypos[j]-1); - addstr(" "); - cursor(xpos[j]-2,ypos[j]); - addstr(" "); - cursor(xpos[j]-1,ypos[j]+1); - addstr(" "); - cursor(xpos[j],ypos[j]+2); - addch(' '); - xpos[j]=x; ypos[j]=y; - refresh(); - } -} - -void -onsig(n) -int n; -{ - endwin(); - exit(0); -} - -float -ranf() -{ - float rv; - long r = rand(); - - r &= 077777; - rv =((float)r/32767.); - return rv; -} - diff --git a/lib/libncurses/TESTS/scroll.c b/lib/libncurses/TESTS/scroll.c deleted file mode 100644 index 428a064b43b8e..0000000000000 --- a/lib/libncurses/TESTS/scroll.c +++ /dev/null @@ -1,30 +0,0 @@ -#include <ncurses.h> - -main() -{ -int i; - - initscr(); - noecho(); - scrollok(stdscr, TRUE); - setscrreg(0, 9); - mvaddstr(0,0,"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); - mvaddstr(1,0,"bbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); - mvaddstr(2,0,"ccccccccccccccccccccccccccccc"); - mvaddstr(3,0,"ddddddddddddddddddddddddddddd"); - mvaddstr(4,0,"eeeeeeeeeeeeeeeeeeeeeeeeeeeee"); - mvaddstr(5,0,"fffffffffffffffffffffffffffff"); - mvaddstr(6,0,"ggggggggggggggggggggggggggggg"); - mvaddstr(7,0,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhh"); - mvaddstr(8,0,"iiiiiiiiiiiiiiiiiiiiiiiiiiiii"); - mvaddstr(9,0,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjj"); - refresh(); - for (i = 0; i < 4; i++) { - getch(); - scrl(-1); - refresh(); - } - getch(); - endwin(); - -} diff --git a/lib/libncurses/TESTS/scroll2.c b/lib/libncurses/TESTS/scroll2.c deleted file mode 100644 index e7b2e30939931..0000000000000 --- a/lib/libncurses/TESTS/scroll2.c +++ /dev/null @@ -1,91 +0,0 @@ -#include <ncurses.h> -#define ROWS 20 -#define scroll_window wscrl - -main() -{ - int i; - WINDOW * w; - - - initscr(); - cbreak(); - noecho(); - w = newwin (ROWS, 35, 2, 25); - scrollok(w, TRUE); - wsetscrreg(w, 0, ROWS-1); - -#ifdef LELE - mvaddstr (0, 0, "With my function"); -#else - mvaddstr (0, 0, "With the original wscrl"); -#endif - refresh(); - - - for (i=0; i<ROWS-1; i++) - { - mvwprintw (w, i, 0, "Line number %d", i); - } - mvwaddstr (w, ROWS-1, 0, "Moving one line at a time"); - wrefresh(w); - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, 1); - wrefresh(w); - } - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, -1); - wrefresh(w); - } - getch(); - wclear (w); - - - for (i=0; i<ROWS-1; i++) - { - mvwprintw (w, i, 0, "Line number %d", i); - } - mvwaddstr (w, ROWS-1, 0, "Moving two line at a time"); -#ifndef LELE - mvaddstr (0, 30, "** THIS FAILS ON MY MACHINE WITH A BUS ERROR -**"); -#endif - - - wrefresh(w); - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, 2); - wrefresh(w); - } - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, -2); - wrefresh(w); - } - getch(); - wclear (w); - for (i=0; i<ROWS-1; i++) - { - mvwprintw (w, i, 0, "Line number %d", i); - } - mvwaddstr (w, ROWS-1, 0, "Moving three line at a time"); - wrefresh(w); - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, 3); - wrefresh(w); - } - for (i = 0; i < 4; i++) { - getch(); - scroll_window (w, -3); - wrefresh(w); - } - getch(); - - - endwin(); -} - diff --git a/lib/libncurses/TESTS/scroll3.c b/lib/libncurses/TESTS/scroll3.c deleted file mode 100644 index b2a10c3e213ad..0000000000000 --- a/lib/libncurses/TESTS/scroll3.c +++ /dev/null @@ -1,51 +0,0 @@ -#include <ncurses.h> - -main(int argc, char **argv) -{ - WINDOW *w, *x; - - initscr(); - w = newwin(0, 0, 0, 0); - if (argc > 2) - x = newwin(0, 0, 0, 0); - scrollok(w, TRUE); - if (argc > 2) - scrollok(x, TRUE); - idlok(w, TRUE); - if (argc > 2) - idlok(x, TRUE); - wmove(w, LINES - 1, 0); - waddstr(w, "test 1 in w"); - wrefresh(w); - sleep(1); - if (argc == 2 || argc == 4) - { - waddch(w, '\n'); - sleep(1); - waddch(w, '\n'); - sleep(1); - waddch(w, '\n'); - sleep(1); - beep(); - wrefresh(w); - } - sleep(1); - if (argc > 2) - { - wmove(x, LINES - 1, 0); - waddstr(x, "test 2 in x"); - sleep(1); - waddch(x, '\n'); - sleep(1); - waddch(x, '\n'); - sleep(1); - waddch(x, '\n'); - sleep(1); - beep(); - wrefresh(w); - sleep(1); - } - endwin(); - return 0; -} - diff --git a/lib/libncurses/TESTS/test.c b/lib/libncurses/TESTS/test.c deleted file mode 100644 index f77f3a1e751e2..0000000000000 --- a/lib/libncurses/TESTS/test.c +++ /dev/null @@ -1,27 +0,0 @@ - -#include <ncurses.h> - -main() -{ -int x, y; - - initscr(); - cbreak(); - nodelay(stdscr, TRUE); - - for (y = 0; y < 43; y++) - for (x =0; x < 132; x++) { - move(y,x); - printw("X"); - refresh(); - if (!getch()) { - beep(); - sleep(1); - } - } - - nocbreak(); - endwin(); -} - - diff --git a/lib/libncurses/TESTS/testcurs.c b/lib/libncurses/TESTS/testcurs.c deleted file mode 100644 index df2468a87e344..0000000000000 --- a/lib/libncurses/TESTS/testcurs.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - * - * This is a test program for the PDCurses screen package for IBM PC type - * machines. - * This program was written by John Burnell (johnb@kea.am.dsir.govt.nz) - * - */ - -#include <stdio.h> -#include <ncurses.h> - -#ifdef __STDC__ -void inputTest (WINDOW *); -void scrollTest (WINDOW *); -void introTest (WINDOW *); -int initTest (WINDOW **); -void outputTest (WINDOW *); -void padTest (WINDOW *); -void resizeTest (WINDOW *); -void display_menu(int,int); -#else -void inputTest (); -void scrollTest (); -void introTest (); -int initTest (); -void outputTest (); -void padTest (); -void resizeTest (); -void display_menu(); -#endif - -struct commands -{ - char *text; -#ifdef __STDC__ - void (*function)(WINDOW *); -#else - void (*function)(); -#endif -}; -typedef struct commands COMMAND; -#define MAX_OPTIONS 6 -COMMAND command[MAX_OPTIONS] = -{ - {"Intro Test",introTest}, - {"Pad Test",padTest}, - {"Resize Test",resizeTest}, - {"Scroll Test",scrollTest}, - {"Input Test",inputTest}, - {"Output Test",outputTest} -}; - -int width, height; - -main() -{ -WINDOW *win; -int key,old_option=(-1),new_option=0; -bool quit=FALSE; - -#ifdef PDCDEBUG - PDC_debug("testcurs started\n"); -#endif - if (!initTest (&win)) {return 1;} - -#ifdef A_COLOR - if (has_colors()) - { - init_pair(1,COLOR_WHITE,COLOR_BLUE); - wattrset(win, COLOR_PAIR(1)); - } - else - wattrset(win, A_REVERSE); -#else - wattrset(win, A_REVERSE); -#endif - - erase(); - display_menu(old_option,new_option); - while(1) - { - noecho(); - keypad(stdscr,TRUE); - raw(); - key = getch(); - switch(key) - { - case 10: - case 13: - case KEY_ENTER: - erase(); - refresh(); - (*command[new_option].function)(win); - erase(); - display_menu(old_option,new_option); - break; - case KEY_UP: - new_option = (new_option == 0) ? new_option : new_option-1; - display_menu(old_option,new_option); - break; - case KEY_DOWN: - new_option = (new_option == MAX_OPTIONS-1) ? new_option : new_option+1; - display_menu(old_option,new_option); - break; - case 'Q': - case 'q': - quit = TRUE; - break; - default: break; - } - if (quit == TRUE) - break; - } - - delwin (win); - - endwin(); - return 0; -} -#ifdef __STDC__ -void Continue (WINDOW *win) -#else -void Continue (win) -WINDOW *win; -#endif -{ - wmove(win, 10, 1); -/* wclrtoeol(win); -*/ mvwaddstr(win, 10, 1, " Press any key to continue"); - wrefresh(win); - raw(); - wgetch(win); -} -#ifdef __STDC_ -int initTest (WINDOW **win) -#else -int initTest (win) -WINDOW **win; -#endif -{ -#ifdef PDCDEBUG - PDC_debug("initTest called\n"); -#endif - initscr(); -#ifdef PDCDEBUG - PDC_debug("after initscr()\n"); -#endif -#ifdef A_COLOR - if (has_colors()) - start_color(); -#endif - width = 60; - height = 13; /* Create a drawing window */ - *win = newwin(height, width, (LINES-height)/2, (COLS-width)/2); - if(*win == NULL) - { endwin(); - return 1; - } -} -#ifdef __STDC__ -void introTest (WINDOW *win) -#else -void introTest (win) -WINDOW *win; -#endif -{ - beep (); - werase(win); - - box(win, ACS_VLINE, ACS_HLINE); - wrefresh(win); - cbreak (); - mvwaddstr(win, 1, 1, "You should have rectangle in the middle of the screen"); - mvwaddstr(win, 2, 1, "You should have heard a beep"); - Continue(win); - return; -} -#ifdef __STDC__ -void scrollTest (WINDOW *win) -#else -void scrollTest (win) -WINDOW *win; -#endif -{ - int i; - int OldX, OldY; - char *Message = "The window will now scroll slowly"; - - mvwprintw (win, height - 2, 1, Message); - wrefresh (win); - scrollok(win, TRUE); - for (i = 1; i <= height; i++) { - usleep (250); - scroll(win); - wrefresh (win); - }; - - getmaxyx (win, OldY, OldX); - mvwprintw (win, 6, 1, "The top of the window will scroll"); - wmove (win, 1, 1); - wsetscrreg (win, 0, 4); - box(win, ACS_VLINE, ACS_HLINE); - wrefresh (win); - for (i = 1; i <= 5; i++) { - usleep (500); - scroll(win); - wrefresh (win); - }; - wsetscrreg (win, 0, --OldY); - -} -#ifdef __STDC__ -void inputTest (WINDOW *win) -#else -void inputTest (win) -WINDOW *win; -#endif -{ - int w, h, bx, by, sw, sh, i, c,num; - char buffer [80]; - WINDOW *subWin; - wclear (win); - - w = win->_maxx; - h = win->_maxy; - bx = win->_begx; - by = win->_begy; - sw = w / 3; - sh = h / 3; - if((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL) - return; - -#ifdef A_COLOR - if (has_colors()) - { - init_pair(2,COLOR_CYAN,COLOR_BLUE); - wattrset(subWin, COLOR_PAIR(2) | A_BOLD); - } - else - wattrset(subWin, A_BOLD); -#else - wattrset(subWin, A_BOLD); -#endif - box(subWin, ACS_VLINE, ACS_HLINE); - wrefresh(win); - - nocbreak(); - mvwaddstr(win, 2, 1, "Press some keys for 5 seconds"); - mvwaddstr(win, 1, 1, "Pressing ^C should do nothing"); - wrefresh(win); - - for (i = 0; i < 5; i++) { - werase (subWin); - box(subWin, ACS_VLINE, ACS_HLINE); - mvwprintw (subWin, 1, 1, "Time = %d", i); - wrefresh(subWin); - usleep(1000); - flushinp(); - } - - delwin (subWin); - werase(win); - flash(); - wrefresh(win); - usleep(500); - - mvwaddstr(win, 2, 1, "Press a key, followed by ENTER"); - wmove(win, 9, 10); - wrefresh(win); - echo(); - noraw(); - wgetch(win); - flushinp(); - - wmove(win, 9, 10); - wdelch(win); - mvwaddstr(win, 4, 1, "The character should now have been deleted"); - Continue(win); - - wclear (win); - mvwaddstr(win, 2, 1, "Press a function key or an arrow key"); - wrefresh(win); - keypad(win, TRUE); - raw(); - c = wgetch(win); - - nodelay(win, TRUE); - wgetch(win); - nodelay(win, FALSE); - - refresh(); - wclear (win); - mvwaddstr(win, 3, 2, "The window should have moved"); - mvwaddstr(win, 4, 2, "This text should have appeared without you pressing a key"); - mvwprintw(win, 2, 2, "Keycode = %d", c); - mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space"); - echo(); - noraw(); - mvwscanw(win, 7, 6, "%d %s", &num,buffer); - mvwprintw(win, 8, 6, "String: %s Number: %d", buffer,num); - Continue(win); -} -#ifdef __STDC__ -void outputTest (WINDOW *win) -#else -void outputTest (win) -WINDOW *win; -#endif -{ - WINDOW *win1; - char Buffer [80]; - chtype ch; - - /* traceon(); */ - nl (); - wclear (win); - mvwaddstr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped"); - mvwin(win, 2, 1); - Continue(win); - - wclear(win); - mvwaddstr(win, 1, 1, "A new window will appear with this text in it"); - mvwaddstr(win, 8, 1, "Press any key to continue"); - wrefresh(win); - wgetch(win); - - win1 = newwin(10, 50, 15, 25); - if(win1 == NULL) - { endwin(); - return; - } -#ifdef A_COLOR - if (has_colors()) - { - init_pair(3,COLOR_BLUE,COLOR_WHITE); - wattrset(win1, COLOR_PAIR(3)); - } - else - wattrset(win1, A_NORMAL); -#else - wattrset(win1, A_NORMAL); -#endif - wclear (win1); - mvwaddstr(win1, 5, 1, "This text should appear; using overlay option"); - copywin(win, win1,0,0,0,0,10,50,TRUE); - -#ifdef UNIX - box(win1,ACS_VLINE,ACS_HLINE); -#else - box(win1,0xb3,0xc4); -#endif - wmove(win1, 8, 26); - wrefresh(win1); - wgetch(win1); - - wclear(win1); - wattron(win1, A_BLINK); - mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window"); - wattroff(win1, A_BLINK); - wrefresh(win1); - wgetch(win1); - delwin(win1); - - wclear(win); - wrefresh(win); - mvwaddstr(win, 6, 2, "This line shouldn't appear"); - mvwaddstr(win, 4, 2, "Only half of the next line is visible"); - mvwaddstr(win, 5, 2, "Only half of the next line is visible"); - wmove(win, 6, 1); - wclrtobot (win); - wmove(win, 5, 20); - wclrtoeol (win); - mvwaddstr(win, 8, 2, "This line also shouldn't appear"); - wmove(win, 8, 1); - wdeleteln(win); - Continue(win); - /* traceoff(); */ - - wmove (win, 5, 9); - ch = winch (win); - - wclear(win); - wmove (win, 6, 2); - waddstr (win, "The next char should be l: "); - winsch (win, ch); - Continue(win); - - wmove(win, 5, 1); - winsertln (win); - mvwaddstr(win, 5, 2, "The lines below should have moved down"); - Continue(win); - - wclear(win); - wmove(win, 2, 2); - wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); - mvwaddstr(win, 10, 1, "Enter a string: "); - wrefresh(win); - noraw(); - echo(); - wscanw (win, "%s", Buffer); - - wclear(win); - mvwaddstr(win, 10, 1, "Enter a string"); - wrefresh(win); - clear(); - move(0,0); - printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); - mvaddstr(10, 1, "Enter a string: "); - refresh(); - noraw(); - echo(); - scanw ("%s", Buffer); - - wclear(win); - curs_set(2); - mvwaddstr(win, 1, 1, "The cursor should appear as a block"); - Continue(win); - - wclear(win); - curs_set(0); - mvwaddstr(win, 1, 1, "The cursor should have disappeared"); - Continue(win); - - wclear(win); - curs_set(1); - mvwaddstr(win, 1, 1, "The cursor should be an underline"); - Continue(win); -} - -#ifdef __STDC__ -void resizeTest(WINDOW *dummy) -#else -void resizeTest(dummy) -WINDOW *dummy; -#endif -{ - WINDOW *win1; - char Buffer [80]; - chtype ch; - - savetty (); - - clear(); - refresh(); -#ifdef __PDCURSES__ - resize(50); -#endif - - - win1 = newwin(11, 50, 14, 25); - if(win1 == NULL) - { endwin(); - return; - } -#ifdef A_COLOR - if (has_colors()) - { - init_pair(3,COLOR_BLUE,COLOR_WHITE); - wattrset(win1, COLOR_PAIR(3)); - } -#endif - wclear (win1); - - mvwaddstr(win1, 1, 1, "The screen may now have 50 lines"); - Continue(win1); - - resetty (); - - wclear (win1); - mvwaddstr(win1, 1, 1, "The screen should now be reset"); - Continue(win1); - - delwin(win1); - - clear(); - refresh(); - -} -#ifdef __STDC__ -void padTest(WINDOW *dummy) -#else -void padTest(dummy) -WINDOW *dummy; -#endif -{ -WINDOW *pad; - - pad = newpad(50,100); - mvwaddstr(pad, 5, 2, "This is a new pad"); - mvwaddstr(pad, 8, 0, "The end of this line should be truncated here:abcd"); - mvwaddstr(pad,11, 1, "This line should not appear."); - wmove(pad, 10, 1); - wclrtoeol(pad); - mvwaddstr(pad, 10, 1, " Press any key to continue"); - prefresh(pad,0,0,0,0,10,45); - keypad(pad, TRUE); - raw(); - wgetch(pad); - - mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad"); - mvwaddstr(pad, 40, 1, " Press any key to continue"); - prefresh(pad,30,0,0,0,10,45); - keypad(pad, TRUE); - raw(); - wgetch(pad); - - delwin(pad); -} - -#ifdef __STDC__ -void display_menu(int old_option,int new_option) -#else -void display_menu(old_option,new_option) -int old_option,new_option; -#endif -{ - register int i; - - attrset(A_NORMAL); - mvaddstr(3,20,"PDCurses Test Program"); - - for (i=0;i<MAX_OPTIONS;i++) - mvaddstr(5+i,25,command[i].text); - if (old_option != (-1)) - mvaddstr(5+old_option,25,command[old_option].text); - attrset(A_REVERSE); - mvaddstr(5+new_option,25,command[new_option].text); - attrset(A_NORMAL); - mvaddstr(13,3,"Use Up and Down Arrows to select - Enter to run - Q to quit"); - refresh(); -} - diff --git a/lib/libncurses/TESTS/worm.c b/lib/libncurses/TESTS/worm.c deleted file mode 100644 index abbe2413487e7..0000000000000 --- a/lib/libncurses/TESTS/worm.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - - @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@ - @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@ - @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@ - @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ - @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ - @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@ - @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@ - - Eric P. Scott - Caltech High Energy Physics - October, 1980 - -*/ - -#include <ncurses.h> -#include <signal.h> - -#define cursor(col,row) move(row,col) - -int Wrap; -short *ref[128]; -static char flavor[]={ - 'O', '*', '#', '$', '%', '0' -}; -static short xinc[]={ - 1, 1, 1, 0, -1, -1, -1, 0 -}, yinc[]={ - -1, 0, 1, 1, 1, 0, -1, -1 -}; -static struct worm { - int orientation, head; - short *xpos, *ypos; -} worm[40]; -static char *field; -static int length=16, number=3, trail=' '; -static struct options { - int nopts; - int opts[3]; -} normal[8]={ - { 3, { 7, 0, 1 } }, - { 3, { 0, 1, 2 } }, - { 3, { 1, 2, 3 } }, - { 3, { 2, 3, 4 } }, - { 3, { 3, 4, 5 } }, - { 3, { 4, 5, 6 } }, - { 3, { 5, 6, 7 } }, - { 3, { 6, 7, 0 } } -}, upper[8]={ - { 1, { 1, 0, 0 } }, - { 2, { 1, 2, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 4, 5, 0 } }, - { 1, { 5, 0, 0 } }, - { 2, { 1, 5, 0 } } -}, left[8]={ - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 2, 3, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 3, 7, 0 } }, - { 1, { 7, 0, 0 } }, - { 2, { 7, 0, 0 } } -}, right[8]={ - { 1, { 7, 0, 0 } }, - { 2, { 3, 7, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 3, 4, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 2, { 6, 7, 0 } } -}, lower[8]={ - { 0, { 0, 0, 0 } }, - { 2, { 0, 1, 0 } }, - { 1, { 1, 0, 0 } }, - { 2, { 1, 5, 0 } }, - { 1, { 5, 0, 0 } }, - { 2, { 5, 6, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}, upleft[8]={ - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 3, 0, 0 } }, - { 2, { 1, 3, 0 } }, - { 1, { 1, 0, 0 } } -}, upright[8]={ - { 2, { 3, 5, 0 } }, - { 1, { 3, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 5, 0, 0 } } -}, lowleft[8]={ - { 3, { 7, 0, 1 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 1, { 1, 0, 0 } }, - { 2, { 1, 7, 0 } }, - { 1, { 7, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}, lowright[8]={ - { 0, { 0, 0, 0 } }, - { 1, { 7, 0, 0 } }, - { 2, { 5, 7, 0 } }, - { 1, { 5, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } }, - { 0, { 0, 0, 0 } } -}; - -void onsig(); -float ranf(); - -main(argc,argv) -int argc; -char *argv[]; -{ -int x, y; -int n; -struct worm *w; -struct options *op; -int h; -short *ip; -int last, bottom; - - for (x=1;x<argc;x++) { - register char *p; - p=argv[x]; - if (*p=='-') p++; - switch (*p) { - case 'f': - field="WORM"; - break; - case 'l': - if (++x==argc) goto usage; - if ((length=atoi(argv[x]))<2||length>1024) { - fprintf(stderr,"%s: Invalid length\n",*argv); - exit(1); - } - break; - case 'n': - if (++x==argc) goto usage; - if ((number=atoi(argv[x]))<1||number>40) { - fprintf(stderr,"%s: Invalid number of worms\n",*argv); - exit(1); - } - break; - case 't': - trail='.'; - break; - default: - usage: - fprintf(stderr, "usage: %s [-field] [-length #] [-number #] [-trail]\n",*argv); - exit(1); - break; - } - } - - signal(SIGINT, onsig); - initscr(); - bottom = LINES-1; - last = COLS-1; - - ip=(short *)malloc(LINES*COLS*sizeof (short)); - - for (n=0;n<LINES;) { - ref[n++]=ip; ip+=COLS; - } - for (ip=ref[0],n=LINES*COLS;--n>=0;) *ip++=0; - ref[bottom][last]=1; - for (n=number, w= &worm[0];--n>=0;w++) { - w->orientation=w->head=0; - if (!(ip=(short *)malloc(length*sizeof (short)))) { - fprintf(stderr,"%s: out of memory\n",*argv); - exit(1); - } - w->xpos=ip; - for (x=length;--x>=0;) *ip++ = -1; - if (!(ip=(short *)malloc(length*sizeof (short)))) { - fprintf(stderr,"%s: out of memory\n",*argv); - exit(1); - } - w->ypos=ip; - for (y=length;--y>=0;) *ip++ = -1; - } - if (field) { - register char *p; - p=field; - for (y=bottom;--y>=0;) { - for (x=COLS;--x>=0;) { - addch(*p++); - if (!*p) p=field; - } - addch('\n'); - } - } - refresh(); - - for (;;) { - for (n=0,w= &worm[0];n<number;n++,w++) { - if ((x=w->xpos[h=w->head])<0) { - cursor(x=w->xpos[h]=0,y=w->ypos[h]=bottom); - addch(flavor[n%6]); - ref[y][x]++; - } - else y=w->ypos[h]; - if (++h==length) h=0; - if (w->xpos[w->head=h]>=0) { - register int x1, y1; - x1=w->xpos[h]; y1=w->ypos[h]; - if (--ref[y1][x1]==0) { - cursor(x1,y1); addch(trail); - } - } - op= &(x==0 ? (y==0 ? upleft : (y==bottom ? lowleft : left)) : - (x==last ? (y==0 ? upright : (y==bottom ? lowright : right)) : - (y==0 ? upper : (y==bottom ? lower : normal))))[w->orientation]; - switch (op->nopts) { - case 0: - refresh(); - endwin(); - exit(0); - case 1: - w->orientation=op->opts[0]; - break; - default: - w->orientation=op->opts[(int)(ranf()*(float)op->nopts)]; - } - cursor(x+=xinc[w->orientation], y+=yinc[w->orientation]); - if (!Wrap||x!=last||y!=bottom) addch(flavor[n%6]); - ref[w->ypos[h]=y][w->xpos[h]=x]++; - } - refresh(); - } -} - -void -onsig() -{ - endwin(); - exit(0); -} - -float -ranf() -{ -float rv; -long r = rand(); - - r &= 077777; - rv =((float)r/32767.); - return rv; -} diff --git a/lib/libncurses/TESTS/xmas.c b/lib/libncurses/TESTS/xmas.c deleted file mode 100644 index 57cc0ea6bb421..0000000000000 --- a/lib/libncurses/TESTS/xmas.c +++ /dev/null @@ -1,1192 +0,0 @@ -/******************************************************************************/ -/* asciixmas */ -/* December 1989 Larry Bartz Indianapolis, IN */ -/* */ -/* */ -/* I'm dreaming of an ascii character-based monochrome Christmas, */ -/* Just like the one's I used to know! */ -/* Via a full duplex communications channel, */ -/* At 9600 bits per second, */ -/* Even though it's kinda slow. */ -/* */ -/* I'm dreaming of an ascii character-based monochrome Christmas, */ -/* With ev'ry C program I write! */ -/* May your screen be merry and bright! */ -/* And may all your Christmases be amber or green, */ -/* (for reduced eyestrain and improved visibility)! */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* IMPLEMENTATION */ -/* */ -/* Feel free to modify the defined string FROMWHO to reflect you, your */ -/* organization, your site, whatever. */ -/* */ -/* This really looks a lot better if you can turn off your cursor before */ -/* execution. I wanted to do that here but very few termcap entries or */ -/* terminfo definitions have the appropriate string defined. If you know */ -/* the string(s) for the terminal(s) you use or which your site supports, */ -/* you could call asciixmas from within a shell in which you issue the */ -/* string to the terminal. The cursor is distracting but it doesn't really */ -/* ruin the show. */ -/* */ -/* At our site, we invoke this for our users just after login and the */ -/* determination of terminal type. */ -/* */ -/* */ -/* PORTABILITY */ -/* */ -/* I wrote this using only the very simplest curses functions so that it */ -/* might be the most portable. I was personally able to test on five */ -/* different cpu/UNIX combinations. */ -/* */ -/* */ -/* COMPILE */ -/* */ -/* usually this: */ -/* */ -/* cc -O asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* Zilog S8000 models 11, 21, 31, etc with ZEUS variant of SYSTEM III */ -/* maybe other SYSTEM III also: */ -/* */ -/* cc asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* as above with optional "peephole optimizer" installed: */ -/* */ -/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* */ -/* Zilog S8000 models 32, 130 with WE32100 chip and SYS V, REL2 */ -/* maybe 3B2 also? */ -/* */ -/* cc -f -O -K sd asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* Pyramid, Sequent, any other "dual universe" types compile and execute */ -/* under either universe. The compile line for the ucb universe (as you */ -/* might expect) is the same as for SYS III UNIX: */ -/* */ -/* cc -O asciixmas.c -lcurses -ltermlib -o asciixmas -s */ -/* */ -/* The above compile will also hold true for other BSD systems. (I hope) */ -/* */ -/* */ -/* */ -/* */ -/* For the Scrooges out there among you who don't want this thing to loop */ -/* forever (or until the user hits a key), insert this into your compile */ -/* line just after "cc" : */ -/* */ -/* -DNOLOOP */ -/* */ -/* like so: */ -/* */ -/* cc -DNOLOOP -O asciixmas.c -lcurses -o asciixmas -s */ -/* */ -/* */ -/* */ -/******************************************************************************/ - -#include <ncurses.h> -#include <signal.h> - -#define FROMWHO "Mark Hessling - (M.Hessling@gu.edu.au)" - -int y_pos, x_pos; - -WINDOW - *treescrn, *treescrn2,*treescrn3, *treescrn4,*treescrn5, *treescrn6, - *treescrn7, *treescrn8, - *dotdeer0, - *stardeer0, - *lildeer0, *lildeer1, *lildeer2, *lildeer3, - *middeer0, *middeer1, *middeer2, *middeer3, - *bigdeer0, *bigdeer1, *bigdeer2, *bigdeer3, *bigdeer4, - *lookdeer0, *lookdeer1, *lookdeer2, *lookdeer3, *lookdeer4, - *w_holiday, - *w_del_msg; - -void main() -{ - void done(); - int loopy; - - initscr(); - noecho(); - nonl(); - refresh(); - signal(SIGINT,done); - signal(SIGTERM,done); -#if !defined DOS && !defined OS2 - signal(SIGHUP,done); - signal(SIGQUIT,done); -#endif - - - - treescrn = newwin(16,27,3,53); - treescrn2 = newwin(16,27,3,53); - treescrn3 = newwin(16,27,3,53); - treescrn4 = newwin(16,27,3,53); - treescrn5 = newwin(16,27,3,53); - treescrn6 = newwin(16,27,3,53); - treescrn7 = newwin(16,27,3,53); - treescrn8 = newwin(16,27,3,53); - - dotdeer0 = newwin(3,71,0,8); - - stardeer0 = newwin(4,56,0,8); - - lildeer0 = newwin(7,53,0,8); - lildeer1 = newwin(2,4,0,0); - lildeer2 = newwin(2,4,0,0); - lildeer3 = newwin(2,4,0,0); - - middeer0 = newwin(15,42,0,8); - middeer1 = newwin(3,7,0,0); - middeer2 = newwin(3,7,0,0); - middeer3 = newwin(3,7,0,0); - - bigdeer0 = newwin(10,23,0,0); - bigdeer1 = newwin(10,23,0,0); - bigdeer2 = newwin(10,23,0,0); - bigdeer3 = newwin(10,23,0,0); - bigdeer4 = newwin(10,23,0,0); - - lookdeer0 = newwin(10,25,0,0); - lookdeer1 = newwin(10,25,0,0); - lookdeer2 = newwin(10,25,0,0); - lookdeer3 = newwin(10,25,0,0); - lookdeer4 = newwin(10,25,0,0); - - w_holiday = newwin(1,26,3,27); - - w_del_msg = newwin(1,12,23,60); - - mvwaddstr(w_del_msg,0,0,"Hit any key to quit"); - - mvwaddstr(w_holiday,0,0,"H A P P Y H O L I D A Y S"); - - /* set up the windows for our various reindeer */ - - /* lildeer1 */ - mvwaddch(lildeer1,0,0,(chtype)'V'); - mvwaddch(lildeer1,1,0,(chtype)'@'); - mvwaddch(lildeer1,1,1,(chtype)'<'); - mvwaddch(lildeer1,1,2,(chtype)'>'); - mvwaddch(lildeer1,1,3,(chtype)'~'); - - /* lildeer2 */ - mvwaddch(lildeer2,0,0,(chtype)'V'); - mvwaddch(lildeer2,1,0,(chtype)'@'); - mvwaddch(lildeer2,1,1,(chtype)'|'); - mvwaddch(lildeer2,1,2,(chtype)'|'); - mvwaddch(lildeer2,1,3,(chtype)'~'); - - /* lildeer3 */ - mvwaddch(lildeer3,0,0,(chtype)'V'); - mvwaddch(lildeer3,1,0,(chtype)'@'); - mvwaddch(lildeer3,1,1,(chtype)'>'); - mvwaddch(lildeer3,1,2,(chtype)'<'); - mvwaddch(lildeer2,1,3,(chtype)'~'); - - - /* middeer1 */ - mvwaddch(middeer1,0,2,(chtype)'y'); - mvwaddch(middeer1,0,3,(chtype)'y'); - mvwaddch(middeer1,1,2,(chtype)'0'); - mvwaddch(middeer1,1,3,(chtype)'('); - mvwaddch(middeer1,1,4,(chtype)'='); - mvwaddch(middeer1,1,5,(chtype)')'); - mvwaddch(middeer1,1,6,(chtype)'~'); - mvwaddch(middeer1,2,3,(chtype)'\\'); - mvwaddch(middeer1,2,4,(chtype)'/'); - - /* middeer2 */ - mvwaddch(middeer2,0,2,(chtype)'y'); - mvwaddch(middeer2,0,3,(chtype)'y'); - mvwaddch(middeer2,1,2,(chtype)'0'); - mvwaddch(middeer2,1,3,(chtype)'('); - mvwaddch(middeer2,1,4,(chtype)'='); - mvwaddch(middeer2,1,5,(chtype)')'); - mvwaddch(middeer2,1,6,(chtype)'~'); - mvwaddch(middeer2,2,3,(chtype)'|'); - mvwaddch(middeer2,2,5,(chtype)'|'); - - /* middeer3 */ - mvwaddch(middeer3,0,2,(chtype)'y'); - mvwaddch(middeer3,0,3,(chtype)'y'); - mvwaddch(middeer3,1,2,(chtype)'0'); - mvwaddch(middeer3,1,3,(chtype)'('); - mvwaddch(middeer3,1,4,(chtype)'='); - mvwaddch(middeer3,1,5,(chtype)')'); - mvwaddch(middeer3,1,6,(chtype)'~'); - mvwaddch(middeer3,2,2,(chtype)'/'); - mvwaddch(middeer3,2,6,(chtype)'\\'); - - - /* bigdeer1 */ - mvwaddch(bigdeer1,0,17,(chtype)'\\'); - mvwaddch(bigdeer1,0,18,(chtype)'/'); - mvwaddch(bigdeer1,0,20,(chtype)'\\'); - mvwaddch(bigdeer1,0,21,(chtype)'/'); - mvwaddch(bigdeer1,1,18,(chtype)'\\'); - mvwaddch(bigdeer1,1,20,(chtype)'/'); - mvwaddch(bigdeer1,2,19,(chtype)'|'); - mvwaddch(bigdeer1,2,20,(chtype)'_'); - mvwaddch(bigdeer1,3,18,(chtype)'/'); - mvwaddch(bigdeer1,3,19,(chtype)'^'); - mvwaddch(bigdeer1,3,20,(chtype)'0'); - mvwaddch(bigdeer1,3,21,(chtype)'\\'); - mvwaddch(bigdeer1,4,17,(chtype)'/'); - mvwaddch(bigdeer1,4,18,(chtype)'/'); - mvwaddch(bigdeer1,4,19,(chtype)'\\'); - mvwaddch(bigdeer1,4,22,(chtype)'\\'); - mvwaddstr(bigdeer1,5,7,"^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer1,6,7,"( \\_____( /"); - mvwaddstr(bigdeer1,7,8,"( ) /"); - mvwaddstr(bigdeer1,8,9,"\\\\ /"); - mvwaddstr(bigdeer1,9,11,"\\>/>"); - - /* bigdeer2 */ - mvwaddch(bigdeer2,0,17,(chtype)'\\'); - mvwaddch(bigdeer2,0,18,(chtype)'/'); - mvwaddch(bigdeer2,0,20,(chtype)'\\'); - mvwaddch(bigdeer2,0,21,(chtype)'/'); - mvwaddch(bigdeer2,1,18,(chtype)'\\'); - mvwaddch(bigdeer2,1,20,(chtype)'/'); - mvwaddch(bigdeer2,2,19,(chtype)'|'); - mvwaddch(bigdeer2,2,20,(chtype)'_'); - mvwaddch(bigdeer2,3,18,(chtype)'/'); - mvwaddch(bigdeer2,3,19,(chtype)'^'); - mvwaddch(bigdeer2,3,20,(chtype)'0'); - mvwaddch(bigdeer2,3,21,(chtype)'\\'); - mvwaddch(bigdeer2,4,17,(chtype)'/'); - mvwaddch(bigdeer2,4,18,(chtype)'/'); - mvwaddch(bigdeer2,4,19,(chtype)'\\'); - mvwaddch(bigdeer2,4,22,(chtype)'\\'); - mvwaddstr(bigdeer2,5,7,"^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer2,6,7,"(( )____( /"); - mvwaddstr(bigdeer2,7,7,"( / |"); - mvwaddstr(bigdeer2,8,8,"\\/ |"); - mvwaddstr(bigdeer2,9,9,"|> |>"); - - /* bigdeer3 */ - mvwaddch(bigdeer3,0,17,(chtype)'\\'); - mvwaddch(bigdeer3,0,18,(chtype)'/'); - mvwaddch(bigdeer3,0,20,(chtype)'\\'); - mvwaddch(bigdeer3,0,21,(chtype)'/'); - mvwaddch(bigdeer3,1,18,(chtype)'\\'); - mvwaddch(bigdeer3,1,20,(chtype)'/'); - mvwaddch(bigdeer3,2,19,(chtype)'|'); - mvwaddch(bigdeer3,2,20,(chtype)'_'); - mvwaddch(bigdeer3,3,18,(chtype)'/'); - mvwaddch(bigdeer3,3,19,(chtype)'^'); - mvwaddch(bigdeer3,3,20,(chtype)'0'); - mvwaddch(bigdeer3,3,21,(chtype)'\\'); - mvwaddch(bigdeer3,4,17,(chtype)'/'); - mvwaddch(bigdeer3,4,18,(chtype)'/'); - mvwaddch(bigdeer3,4,19,(chtype)'\\'); - mvwaddch(bigdeer3,4,22,(chtype)'\\'); - mvwaddstr(bigdeer3,5,7,"^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer3,6,6,"( ()_____( /"); - mvwaddstr(bigdeer3,7,6,"/ / /"); - mvwaddstr(bigdeer3,8,5,"|/ \\"); - mvwaddstr(bigdeer3,9,5,"/> \\>"); - - /* bigdeer4 */ - mvwaddch(bigdeer4,0,17,(chtype)'\\'); - mvwaddch(bigdeer4,0,18,(chtype)'/'); - mvwaddch(bigdeer4,0,20,(chtype)'\\'); - mvwaddch(bigdeer4,0,21,(chtype)'/'); - mvwaddch(bigdeer4,1,18,(chtype)'\\'); - mvwaddch(bigdeer4,1,20,(chtype)'/'); - mvwaddch(bigdeer4,2,19,(chtype)'|'); - mvwaddch(bigdeer4,2,20,(chtype)'_'); - mvwaddch(bigdeer4,3,18,(chtype)'/'); - mvwaddch(bigdeer4,3,19,(chtype)'^'); - mvwaddch(bigdeer4,3,20,(chtype)'0'); - mvwaddch(bigdeer4,3,21,(chtype)'\\'); - mvwaddch(bigdeer4,4,17,(chtype)'/'); - mvwaddch(bigdeer4,4,18,(chtype)'/'); - mvwaddch(bigdeer4,4,19,(chtype)'\\'); - mvwaddch(bigdeer4,4,22,(chtype)'\\'); - mvwaddstr(bigdeer4,5,7,"^~~~~~~~~// ~~U"); - mvwaddstr(bigdeer4,6,6,"( )______( /"); - mvwaddstr(bigdeer4,7,5,"(/ \\"); - mvwaddstr(bigdeer4,8,0,"v___= ----^"); - - - /* lookdeer1 */ - mvwaddstr(lookdeer1,0,16,"\\/ \\/"); - mvwaddstr(lookdeer1,1,17,"\\Y/ \\Y/"); - mvwaddstr(lookdeer1,2,19,"\\=/"); - mvwaddstr(lookdeer1,3,17,"^\\o o/^"); - mvwaddstr(lookdeer1,4,17,"//( )"); - mvwaddstr(lookdeer1,5,7,"^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer1,6,7,"( \\_____( /"); - mvwaddstr(lookdeer1,7,8,"( ) /"); - mvwaddstr(lookdeer1,8,9,"\\\\ /"); - mvwaddstr(lookdeer1,9,11,"\\>/>"); - - /* lookdeer2 */ - mvwaddstr(lookdeer2,0,16,"\\/ \\/"); - mvwaddstr(lookdeer2,1,17,"\\Y/ \\Y/"); - mvwaddstr(lookdeer2,2,19,"\\=/"); - mvwaddstr(lookdeer2,3,17,"^\\o o/^"); - mvwaddstr(lookdeer2,4,17,"//( )"); - mvwaddstr(lookdeer2,5,7,"^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer2,6,7,"(( )____( /"); - mvwaddstr(lookdeer2,7,7,"( / |"); - mvwaddstr(lookdeer2,8,8,"\\/ |"); - mvwaddstr(lookdeer2,9,9,"|> |>"); - - /* lookdeer3 */ - mvwaddstr(lookdeer3,0,16,"\\/ \\/"); - mvwaddstr(lookdeer3,1,17,"\\Y/ \\Y/"); - mvwaddstr(lookdeer3,2,19,"\\=/"); - mvwaddstr(lookdeer3,3,17,"^\\o o/^"); - mvwaddstr(lookdeer3,4,17,"//( )"); - mvwaddstr(lookdeer3,5,7,"^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer3,6,6,"( ()_____( /"); - mvwaddstr(lookdeer3,7,6,"/ / /"); - mvwaddstr(lookdeer3,8,5,"|/ \\"); - mvwaddstr(lookdeer3,9,5,"/> \\>"); - - /* lookdeer4 */ - mvwaddstr(lookdeer4,0,16,"\\/ \\/"); - mvwaddstr(lookdeer4,1,17,"\\Y/ \\Y/"); - mvwaddstr(lookdeer4,2,19,"\\=/"); - mvwaddstr(lookdeer4,3,17,"^\\o o/^"); - mvwaddstr(lookdeer4,4,17,"//( )"); - mvwaddstr(lookdeer4,5,7,"^~~~~~~~~// \\O/"); - mvwaddstr(lookdeer4,6,6,"( )______( /"); - mvwaddstr(lookdeer4,7,5,"(/ \\"); - mvwaddstr(lookdeer4,8,0,"v___= ----^"); - - - - /***********************************************/ - cbreak(); - nodelay(stdscr,TRUE); - do - { - clear(); - werase(treescrn); - touchwin(treescrn); - werase(treescrn2); - touchwin(treescrn2); - werase(treescrn8); - touchwin(treescrn8); - refresh(); - usleep(1000); - boxit(); - refresh(); - usleep(1000); - seas(); - refresh(); - usleep(1000); - greet(); - refresh(); - usleep(1000); - fromwho(); - refresh(); - usleep(1000); - tree(); - usleep(1000); - balls(); - usleep(1000); - star(); - usleep(1000); - strng1(); - strng2(); - strng3(); - strng4(); - strng5(); - - - /* set up the windows for our blinking trees */ - /* **************************************** */ - /* treescrn3 */ - - overlay(treescrn, treescrn3); - - /*balls*/ - mvwaddch(treescrn3, 4, 18, ' '); - mvwaddch(treescrn3, 7, 6, ' '); - mvwaddch(treescrn3, 8, 19, ' '); - mvwaddch(treescrn3, 11, 22, ' '); - - /*star*/ - mvwaddch(treescrn3, 0, 12, '*'); - - /*strng1*/ - mvwaddch(treescrn3, 3, 11, ' '); - - /*strng2*/ - mvwaddch(treescrn3, 5, 13, ' '); - mvwaddch(treescrn3, 6, 10, ' '); - - /*strng3*/ - mvwaddch(treescrn3, 7, 16, ' '); - mvwaddch(treescrn3, 7, 14, ' '); - - /*strng4*/ - mvwaddch(treescrn3, 10, 13, ' '); - mvwaddch(treescrn3, 10, 10, ' '); - mvwaddch(treescrn3, 11, 8, ' '); - - /*strng5*/ - mvwaddch(treescrn3, 11, 18, ' '); - mvwaddch(treescrn3, 12, 13, ' '); - - - /* treescrn4 */ - - overlay(treescrn, treescrn4); - - /*balls*/ - mvwaddch(treescrn4, 3, 9, ' '); - mvwaddch(treescrn4, 4, 16, ' '); - mvwaddch(treescrn4, 7, 6, ' '); - mvwaddch(treescrn4, 8, 19, ' '); - mvwaddch(treescrn4, 11, 2, ' '); - mvwaddch(treescrn4, 12, 23, ' '); - - /*star*/ - wstandout(treescrn4); - mvwaddch(treescrn4, 0, 12, '*'); - wstandend(treescrn4); - - /*strng1*/ - mvwaddch(treescrn4, 3, 13, ' '); - - /*strng2*/ - - /*strng3*/ - mvwaddch(treescrn4, 7, 15, ' '); - mvwaddch(treescrn4, 8, 11, ' '); - - /*strng4*/ - mvwaddch(treescrn4, 9, 16, ' '); - mvwaddch(treescrn4, 10, 12, ' '); - mvwaddch(treescrn4, 11, 8, ' '); - - /*strng5*/ - mvwaddch(treescrn4, 11, 18, ' '); - mvwaddch(treescrn4, 12, 14, ' '); - - - /* treescrn5 */ - - overlay(treescrn, treescrn5); - - /*balls*/ - mvwaddch(treescrn5, 3, 15, ' '); - mvwaddch(treescrn5, 10, 20, ' '); - mvwaddch(treescrn5, 12, 1, ' '); - - /*star*/ - mvwaddch(treescrn5, 0, 12, '*'); - - /*strng1*/ - mvwaddch(treescrn5, 3, 11, ' '); - - /*strng2*/ - mvwaddch(treescrn5, 5, 12, ' '); - - /*strng3*/ - mvwaddch(treescrn5, 7, 14, ' '); - mvwaddch(treescrn5, 8, 10, ' '); - - /*strng4*/ - mvwaddch(treescrn5, 9, 15, ' '); - mvwaddch(treescrn5, 10, 11, ' '); - mvwaddch(treescrn5, 11, 7, ' '); - - /*strng5*/ - mvwaddch(treescrn5, 11, 17, ' '); - mvwaddch(treescrn5, 12, 13, ' '); - - /* treescrn6 */ - - overlay(treescrn, treescrn6); - - /*balls*/ - mvwaddch(treescrn6, 6, 7, ' '); - mvwaddch(treescrn6, 7, 18, ' '); - mvwaddch(treescrn6, 10, 4, ' '); - mvwaddch(treescrn6, 11, 23, ' '); - - /*star*/ - wstandout(treescrn6); - mvwaddch(treescrn6, 0, 12, '*'); - wstandend(treescrn6); - - /*strng1*/ - - /*strng2*/ - mvwaddch(treescrn6, 5, 11, ' '); - - /*strng3*/ - mvwaddch(treescrn6, 7, 13, ' '); - mvwaddch(treescrn6, 8, 9, ' '); - - /*strng4*/ - mvwaddch(treescrn6, 9, 14, ' '); - mvwaddch(treescrn6, 10, 10, ' '); - mvwaddch(treescrn6, 11, 6, ' '); - - /*strng5*/ - mvwaddch(treescrn6, 11, 16, ' '); - mvwaddch(treescrn6, 12, 12, ' '); - - /* treescrn7 */ - - overlay(treescrn, treescrn7); - - /*balls*/ - mvwaddch(treescrn7, 3, 15, ' '); - mvwaddch(treescrn7, 6, 7, ' '); - mvwaddch(treescrn7, 7, 18, ' '); - mvwaddch(treescrn7, 10, 4, ' '); - mvwaddch(treescrn7, 11, 22, ' '); - - /*star*/ - mvwaddch(treescrn7, 0, 12, '*'); - - /*strng1*/ - mvwaddch(treescrn7, 3, 12, ' '); - - /*strng2*/ - mvwaddch(treescrn7, 5, 13, ' '); - mvwaddch(treescrn7, 6, 9, ' '); - - /*strng3*/ - mvwaddch(treescrn7, 7, 15, ' '); - mvwaddch(treescrn7, 8, 11, ' '); - - /*strng4*/ - mvwaddch(treescrn7, 9, 16, ' '); - mvwaddch(treescrn7, 10, 12, ' '); - mvwaddch(treescrn7, 11, 8, ' '); - - /*strng5*/ - mvwaddch(treescrn7, 11, 18, ' '); - mvwaddch(treescrn7, 12, 14, ' '); - - - usleep(1000); - reindeer(); - - touchwin(w_holiday); - wrefresh(w_holiday); - wrefresh(w_del_msg); - - usleep(1000); - for(loopy = 0;loopy < 100;loopy++) - { - blinkit(); - } - -#ifdef NOLOOP - done(); -#endif - - } - while(getch() == (ERR)); -/* while(!typeahead(stdin));*/ - done(); -} - -boxit() -{ - int x = 0; - - while(x < 20) - { - mvaddch(x, 7, '|'); - ++x; - } - - x = 8; - - while(x < 80) - { - mvaddch(19, x, '_'); - ++x; - } - - x = 0; - - while(x < 80) - { - mvaddch(22, x, '_'); - ++x; - } - - return( 0 ); -} - -seas() -{ - mvaddch(4, 1, 'S'); - mvaddch(6, 1, 'E'); - mvaddch(8, 1, 'A'); - mvaddch(10, 1, 'S'); - mvaddch(12, 1, 'O'); - mvaddch(14, 1, 'N'); - mvaddch(16, 1, '`'); - mvaddch(18, 1, 'S'); - - return( 0 ); -} - - -greet() -{ - mvaddch(3, 5, 'G'); - mvaddch(5, 5, 'R'); - mvaddch(7, 5, 'E'); - mvaddch(9, 5, 'E'); - mvaddch(11, 5, 'T'); - mvaddch(13, 5, 'I'); - mvaddch(15, 5, 'N'); - mvaddch(17, 5, 'G'); - mvaddch(19, 5, 'S'); - - return( 0 ); -} - - -fromwho() -{ - mvaddstr(21, 13, FROMWHO); - return( 0 ); -} - - -del_msg() -{ - mvwaddstr(w_del_msg, 0, 0, "Hit any key to quit"); - wrefresh(w_del_msg); - - refresh(); - - return( 0 ); -} - - -tree() -{ - mvwaddch(treescrn, 1, 11, (chtype)'/'); - mvwaddch(treescrn, 2, 11, (chtype)'/'); - mvwaddch(treescrn, 3, 10, (chtype)'/'); - mvwaddch(treescrn, 4, 9, (chtype)'/'); - mvwaddch(treescrn, 5, 9, (chtype)'/'); - mvwaddch(treescrn, 6, 8, (chtype)'/'); - mvwaddch(treescrn, 7, 7, (chtype)'/'); - mvwaddch(treescrn, 8, 6, (chtype)'/'); - mvwaddch(treescrn, 9, 6, (chtype)'/'); - mvwaddch(treescrn, 10, 5, (chtype)'/'); - mvwaddch(treescrn, 11, 3, (chtype)'/'); - mvwaddch(treescrn, 12, 2, (chtype)'/'); - - mvwaddch(treescrn, 1, 13, (chtype)'\\'); - mvwaddch(treescrn, 2, 13, (chtype)'\\'); - mvwaddch(treescrn, 3, 14, (chtype)'\\'); - mvwaddch(treescrn, 4, 15, (chtype)'\\'); - mvwaddch(treescrn, 5, 15, (chtype)'\\'); - mvwaddch(treescrn, 6, 16, (chtype)'\\'); - mvwaddch(treescrn, 7, 17, (chtype)'\\'); - mvwaddch(treescrn, 8, 18, (chtype)'\\'); - mvwaddch(treescrn, 9, 18, (chtype)'\\'); - mvwaddch(treescrn, 10, 19, (chtype)'\\'); - mvwaddch(treescrn, 11, 21, (chtype)'\\'); - mvwaddch(treescrn, 12, 22, (chtype)'\\'); - - mvwaddch(treescrn, 4, 10, (chtype)'_'); - mvwaddch(treescrn, 4, 14, (chtype)'_'); - mvwaddch(treescrn, 8, 7, (chtype)'_'); - mvwaddch(treescrn, 8, 17, (chtype)'_'); - - mvwaddstr(treescrn, 13, 0, "//////////// \\\\\\\\\\\\\\\\\\\\\\\\"); - - mvwaddstr(treescrn, 14, 11, "| |"); - mvwaddstr(treescrn, 15, 11, "|_|"); - - wrefresh(treescrn); - wrefresh(w_del_msg); - - return( 0 ); -} - - -balls() -{ - - overlay(treescrn, treescrn2); - - mvwaddch(treescrn2, 3, 9, (chtype)'@'); - mvwaddch(treescrn2, 3, 15, (chtype)'@'); - mvwaddch(treescrn2, 4, 8, (chtype)'@'); - mvwaddch(treescrn2, 4, 16, (chtype)'@'); - mvwaddch(treescrn2, 5, 7, (chtype)'@'); - mvwaddch(treescrn2, 5, 17, (chtype)'@'); - mvwaddch(treescrn2, 7, 6, (chtype)'@'); - mvwaddch(treescrn2, 7, 18, (chtype)'@'); - mvwaddch(treescrn2, 8, 5, (chtype)'@'); - mvwaddch(treescrn2, 8, 19, (chtype)'@'); - mvwaddch(treescrn2, 10, 4, (chtype)'@'); - mvwaddch(treescrn2, 10, 20, (chtype)'@'); - mvwaddch(treescrn2, 11, 2, (chtype)'@'); - mvwaddch(treescrn2, 11, 22, (chtype)'@'); - mvwaddch(treescrn2, 12, 1, (chtype)'@'); - mvwaddch(treescrn2, 12, 23, (chtype)'@'); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -star() -{ - wstandout(treescrn2); - mvwaddch(treescrn2, 0, 12, (chtype)'*'); - wstandend(treescrn2); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -strng1() -{ - mvwaddch(treescrn2, 3, 13, (chtype)'\''); - mvwaddch(treescrn2, 3, 12, (chtype)':'); - mvwaddch(treescrn2, 3, 11, (chtype)'.'); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -strng2() -{ - mvwaddch(treescrn2, 5, 14, (chtype)'\''); - mvwaddch(treescrn2, 5, 13, (chtype)':'); - mvwaddch(treescrn2, 5, 12, (chtype)'.'); - mvwaddch(treescrn2, 5, 11, (chtype)','); - mvwaddch(treescrn2, 6, 10, (chtype)'\''); - mvwaddch(treescrn2, 6, 9, (chtype)':'); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -strng3() -{ - mvwaddch(treescrn2, 7, 16, (chtype)'\''); - mvwaddch(treescrn2, 7, 15, (chtype)':'); - mvwaddch(treescrn2, 7, 14, (chtype)'.'); - mvwaddch(treescrn2, 7, 13, (chtype)','); - mvwaddch(treescrn2, 8, 12, (chtype)'\''); - mvwaddch(treescrn2, 8, 11, (chtype)':'); - mvwaddch(treescrn2, 8, 10, (chtype)'.'); - mvwaddch(treescrn2, 8, 9, (chtype)','); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -strng4() -{ - mvwaddch(treescrn2, 9, 17, (chtype)'\''); - mvwaddch(treescrn2, 9, 16, (chtype)':'); - mvwaddch(treescrn2, 9, 15, (chtype)'.'); - mvwaddch(treescrn2, 9, 14, (chtype)','); - mvwaddch(treescrn2, 10, 13, (chtype)'\''); - mvwaddch(treescrn2, 10, 12, (chtype)':'); - mvwaddch(treescrn2, 10, 11, (chtype)'.'); - mvwaddch(treescrn2, 10, 10, (chtype)','); - mvwaddch(treescrn2, 11, 9, (chtype)'\''); - mvwaddch(treescrn2, 11, 8, (chtype)':'); - mvwaddch(treescrn2, 11, 7, (chtype)'.'); - mvwaddch(treescrn2, 11, 6, (chtype)','); - mvwaddch(treescrn2, 12, 5, (chtype)'\''); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - -strng5() -{ - mvwaddch(treescrn2, 11, 19, (chtype)'\''); - mvwaddch(treescrn2, 11, 18, (chtype)':'); - mvwaddch(treescrn2, 11, 17, (chtype)'.'); - mvwaddch(treescrn2, 11, 16, (chtype)','); - mvwaddch(treescrn2, 12, 15, (chtype)'\''); - mvwaddch(treescrn2, 12, 14, (chtype)':'); - mvwaddch(treescrn2, 12, 13, (chtype)'.'); - mvwaddch(treescrn2, 12, 12, (chtype)','); - - /* save a fully lit tree */ - overlay(treescrn2, treescrn); - - wrefresh(treescrn2); - wrefresh(w_del_msg); - return( 0 ); -} - - - -blinkit() -{ - static int cycle; - - if(cycle > 4) - { - cycle = 0; - } - - - touchwin(treescrn8); - - switch(cycle) - { - - case 0: - overlay(treescrn3, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - break; - case 1: - overlay(treescrn4, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - break; - case 2: - overlay(treescrn5, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - break; - case 3: - overlay(treescrn6, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - break; - case 4: - overlay(treescrn7, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - break; - } - - touchwin(treescrn8); - - - - /*ALL ON***************************************************/ - - - overlay(treescrn, treescrn8); - wrefresh(treescrn8); - wrefresh(w_del_msg); - - - ++cycle; - return( 0 ); -} - - -reindeer() -{ - int looper; - - y_pos = 0; - - - for(x_pos = 70; x_pos > 62; x_pos--) - { - if(x_pos < 62) - { - y_pos = 1; - } - for(looper = 0; looper < 4; looper++) - { - mvwaddch(dotdeer0, y_pos, x_pos, (chtype)'.'); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - werase(dotdeer0); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - } - } - - y_pos = 2; - - for(; x_pos > 50; x_pos--) - { - - for(looper = 0; looper < 4; looper++) - { - - if(x_pos < 56) - { - y_pos = 3; - - mvwaddch(stardeer0, y_pos, x_pos, (chtype)'*'); - wrefresh(stardeer0); - wrefresh(w_del_msg); - werase(stardeer0); - wrefresh(stardeer0); - wrefresh(w_del_msg); - } - else - { - mvwaddch(dotdeer0, y_pos, x_pos, (chtype)'*'); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - werase(dotdeer0); - wrefresh(dotdeer0); - wrefresh(w_del_msg); - } - } - } - - x_pos = 58; - - for(y_pos = 2; y_pos < 5; y_pos++) - { - - touchwin(lildeer0); - wrefresh(lildeer0); - wrefresh(w_del_msg); - - for(looper = 0; looper < 4; looper++) - { - mvwin(lildeer3, y_pos, x_pos); - wrefresh(lildeer3); - wrefresh(w_del_msg); - - mvwin(lildeer2, y_pos, x_pos); - wrefresh(lildeer2); - wrefresh(w_del_msg); - - mvwin(lildeer1, y_pos, x_pos); - wrefresh(lildeer1); - wrefresh(w_del_msg); - - mvwin(lildeer2, y_pos, x_pos); - wrefresh(lildeer2); - wrefresh(w_del_msg); - - mvwin(lildeer3, y_pos, x_pos); - wrefresh(lildeer3); - wrefresh(w_del_msg); - - touchwin(lildeer0); - wrefresh(lildeer0); - wrefresh(w_del_msg); - - x_pos -= 2; - } - } - - - x_pos = 35; - - for(y_pos = 5; y_pos < 10; y_pos++) - { - - touchwin(middeer0); - wrefresh(middeer0); - wrefresh(w_del_msg); - - for(looper = 0; looper < 2; looper++) - { - mvwin(middeer3, y_pos, x_pos); - wrefresh(middeer3); - wrefresh(w_del_msg); - - mvwin(middeer2, y_pos, x_pos); - wrefresh(middeer2); - wrefresh(w_del_msg); - - mvwin(middeer1, y_pos, x_pos); - wrefresh(middeer1); - wrefresh(w_del_msg); - - mvwin(middeer2, y_pos, x_pos); - wrefresh(middeer2); - wrefresh(w_del_msg); - - mvwin(middeer3, y_pos, x_pos); - wrefresh(middeer3); - wrefresh(w_del_msg); - - touchwin(middeer0); - wrefresh(middeer0); - wrefresh(w_del_msg); - - x_pos -= 3; - } - } - - usleep(2000); - - y_pos = 1; - - for(x_pos = 8; x_pos < 16; x_pos++) - { - - mvwin(bigdeer4, y_pos, x_pos); - wrefresh(bigdeer4); - wrefresh(w_del_msg); - - mvwin(bigdeer3, y_pos, x_pos); - wrefresh(bigdeer3); - wrefresh(w_del_msg); - - mvwin(bigdeer2, y_pos, x_pos); - wrefresh(bigdeer2); - wrefresh(w_del_msg); - - mvwin(bigdeer1, y_pos, x_pos); - wrefresh(bigdeer1); - wrefresh(w_del_msg); - - mvwin(bigdeer2, y_pos, x_pos); - wrefresh(bigdeer2); - wrefresh(w_del_msg); - - mvwin(bigdeer3, y_pos, x_pos); - wrefresh(bigdeer3); - wrefresh(w_del_msg); - - mvwin(bigdeer4, y_pos, x_pos); - wrefresh(bigdeer4); - wrefresh(w_del_msg); - - mvwin(bigdeer0, y_pos, x_pos); - wrefresh(bigdeer0); - wrefresh(w_del_msg); - } - - --x_pos; - - for(looper = 0; looper < 6; looper++) - { - mvwin(lookdeer4, y_pos, x_pos); - wrefresh(lookdeer4); - wrefresh(w_del_msg); - - mvwin(lookdeer3, y_pos, x_pos); - wrefresh(lookdeer3); - wrefresh(w_del_msg); - - mvwin(lookdeer2, y_pos, x_pos); - wrefresh(lookdeer2); - wrefresh(w_del_msg); - - mvwin(lookdeer1, y_pos, x_pos); - wrefresh(lookdeer1); - wrefresh(w_del_msg); - - mvwin(lookdeer2, y_pos, x_pos); - wrefresh(lookdeer2); - wrefresh(w_del_msg); - - mvwin(lookdeer3, y_pos, x_pos); - wrefresh(lookdeer3); - wrefresh(w_del_msg); - - mvwin(lookdeer4, y_pos, x_pos); - wrefresh(lookdeer4); - wrefresh(w_del_msg); - - } - - mvwin(lookdeer0, y_pos, x_pos); - wrefresh(lookdeer0); - wrefresh(w_del_msg); - - for(; y_pos < 10; y_pos++) - { - - for(looper = 0; looper < 2; looper++) - { - mvwin(bigdeer4, y_pos, x_pos); - wrefresh(bigdeer4); - wrefresh(w_del_msg); - - mvwin(bigdeer3, y_pos, x_pos); - wrefresh(bigdeer3); - wrefresh(w_del_msg); - - mvwin(bigdeer2, y_pos, x_pos); - wrefresh(bigdeer2); - wrefresh(w_del_msg); - - mvwin(bigdeer1, y_pos, x_pos); - wrefresh(bigdeer1); - wrefresh(w_del_msg); - - mvwin(bigdeer2, y_pos, x_pos); - wrefresh(bigdeer2); - wrefresh(w_del_msg); - - mvwin(bigdeer3, y_pos, x_pos); - wrefresh(bigdeer3); - wrefresh(w_del_msg); - - mvwin(bigdeer4, y_pos, x_pos); - wrefresh(bigdeer4); - wrefresh(w_del_msg); - } - mvwin(bigdeer0, y_pos, x_pos); - wrefresh(bigdeer0); - wrefresh(w_del_msg); - } - - --y_pos; - - mvwin(lookdeer3, y_pos, x_pos); - wrefresh(lookdeer3); - wrefresh(w_del_msg); - return( 0 ); -} - - - -void done() -{ - signal(SIGINT,done); - signal(SIGTERM,done); -#if !defined DOS && !defined OS2 - signal(SIGHUP,done); - signal(SIGQUIT,done); -#endif - clear(); - refresh(); - endwin(); - exit(0); -} |
