From 6aa0e0017d7d0cddc006da885946934b06949a91 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 14 Oct 2011 04:55:05 +0200 Subject: include libslang-1.4.9 and automatically build it and link erlang-slang against it few (erlang) people will still have libslang-1.4.9 installed or spend time to get it to link against the driver --- libslang/src/curses/rain.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 libslang/src/curses/rain.c (limited to 'libslang/src/curses/rain.c') diff --git a/libslang/src/curses/rain.c b/libslang/src/curses/rain.c new file mode 100644 index 0000000..792dab9 --- /dev/null +++ b/libslang/src/curses/rain.c @@ -0,0 +1,97 @@ +#include +#include +#include + +/* rain 11/3/1980 EPS/CITHEP */ + +#define cursor(col,row) move(row,col) + +float ranf(void); +void onsig(int sig); + +int +main(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(); + napms(50); + } +} + +void +onsig(int n) +{ + endwin(); + exit(n); +} + +float +ranf(void) +{ + float rv; + long r = rand(); + + r &= 077777; + rv =((float)r/32767.); + return rv; +} + -- cgit v1.2.3