Text
|
|
|
|
<?php /*
php 4.3.0rc0 compiled with the following
./configure --with-mysql --enable-pcntl --with-tsrm-pthreads --enable-sysvsem --enable-sysvshm --with-curl --enable-bcmath --enable-cli --enable-sigchild --enable-sockets --with-ncurses
*/ ini_set("ncurses.value",42); ini_set("ncurses.string","foobar");
$n=0;
$a = ncurses_init();//$a,$b,$c,$d,$e,$f,$g,$h $z = ncurses_newwin ( 15, 15, 10, 10);
if(ncurses_has_colors()){
ncurses_start_color();
ncurses_init_pair(1,NCURSES_COLOR_RED,NCURSES_COLOR_BLACK);
ncurses_init_pair(2,NCURSES_COLOR_BLUE,NCURSES_COLOR_BLACK);
ncurses_init_pair(3,NCURSES_COLOR_YELLOW,NCURSES_COLOR_BLACK);
ncurses_init_pair(4,NCURSES_COLOR_BLUE,NCURSES_COLOR_BLACK);
ncurses_init_pair(5,NCURSES_COLOR_MAGENTA,NCURSES_COLOR_BLACK);
ncurses_init_pair(6,NCURSES_COLOR_CYAN,NCURSES_COLOR_BLACK);
ncurses_init_pair(7,NCURSES_COLOR_WHITE,NCURSES_COLOR_BLACK);
} ncurses_border(0,0, 0,0, 0,0, 0,0);
while(1){
for ($x=1; $x<80; $x++) {
for ($y=1; $y<24; $y++) {
$n++;
ncurses_move($y,$x);
ncurses_addch($n+64);
ncurses_color_set($n%8);
ncurses_refresh();
if($n>26)$n=0;
}
} $z = ncurses_newwin ( 15, 15, 10, 10); /*
the following function ncurses_wborder() has nothing written about it on
php.net. I was reading through the ncurses examples and man pages when I just
decided to try the following.... then I started 'n'cursing...
*/ ncurses_wborder($z,0,0, 0,0, 0,0, 0,0); // undocumented function
ncurses_wrefresh($z); ncurses_getch(); // wait for use to press key }
// here is a function I wrote before realizing that php ncurses had this built-in
// as the following two functions
// ncurses_getmaxyx($z, $x, $y); // undocumented function gets maximum x and y
// ncurses_getyx($window_handle, $return_y, $return_x); // undocumented function, get current x/y
// function getmaxxy(){
$rez = `/usr/X11R6/bin/resize`;
$rez = explode("n",$rez);
while(list($key,$val)=each($rez)){
$a=explode("=",$val);
if(trim($a[0])=="COLUMNS"){ $COLUMNS = $a[1]; }
if(trim($a[0])=="LINES"){ $LINES = $a[1]; }
}//
$retval[0]=$COLUMNS;
$retval[1]=$LINES;
return $retval;
}
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|