a working example with mouse, 3 windows (need to be completed, but it works) ...
<?php
error_reporting(E_ALL);
function win($w, $h, $x, $y, $txt){
$win = ncurses_newwin($w, $h, $x, $y);
ncurses_wborder($win,0,0, 0,0, 0,0, 0,0);
ncurses_refresh();ncurses_mvwaddstr($win, 0, 1, " $txt ");
ncurses_mvwaddstr($win, 1, 1, "($w, $h, $x, $y)");
ncurses_wrefresh($win);
return $win;
}
$ncurse = ncurses_init();
$win0 = win(0, 0, 0, 0, 'win0');
$win1 = win(10, 30, 7, 25, 'win1');
$win2 = win(10, 30, 20, 25, 'win2');
$info = win(15, 20, 2, 2, 'info');
$newmask = NCURSES_BUTTON1_CLICKED + NCURSES_BUTTON1_RELEASED;
$mask = ncurses_mousemask($newmask, &$oldmask);
$events = array();
while(1){
ncurses_wmove($info, 1,1);
$ch = ncurses_getch();
ncurses_wclear($info);
ncurses_refresh();ncurses_wborder($info,0,0, 0,0, 0,0, 0,0);
ncurses_refresh();ncurses_mvwaddstr($win, 0, 1, " info ");
ncurses_refresh();switch($ch){
case NCURSES_KEY_MOUSE:
if(ncurses_getmouse($mevent)){
$events[] = $mevent;
ncurses_mvwaddstr($info, 2, 1, " mouse event ");
ncurses_mvwaddstr($info, 3, 1, " ({$mevent['x']}/{$mevent['y']}) ");
ncurses_mvwaddstr($info, 4, 1, " ({$mevent['mmask']}) ");
ncurses_wrefresh($info);
}
break;
case chr('q'):
break 2;
default:
if($ch > 0x40)
$txt = chr($ch) . " $ch ";
else
$txt = '.' . " $ch";
ncurses_mvwaddstr($info, 1, 1, " $txt ");
ncurses_wrefresh($info);
}
if(chr($ch) == 'q')
break;
}
ncurses_end();print_r($events);
?>