PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ncurses_getmaxyx> <ncurses_flushinp
Last updated: Fri, 22 Aug 2008

view this page in

ncurses_getch

(PHP 4 >= 4.0.7, PHP 5, PECL ncurses:1.0.0)

ncurses_getchLit un caractère sur le clavier

Description

int ncurses_getch ( void )
Avertissement

Cette fonction est EXPERIMENTALE. Cela signifie que le comportement de cette fonction, son nom et, concrètement, TOUT ce qui est documenté ici peut changer dans un futur proche, SANS PREAVIS ! Soyez-en conscient, et utilisez cette fonction à vos risques et périls.

Avertissement

Cette fonction n'est pas documentée et seule la liste des arguments est disponible.



ncurses_getmaxyx> <ncurses_flushinp
Last updated: Fri, 22 Aug 2008
 
add a note add a note User Contributed Notes
ncurses_getch
Quis _ Omicidio _ NL
20-Dec-2007 07:06
In reply to petr at hroch dot info

You can use
ncurses_timeout(0);

ncurses_getch() will return -1 if no data is available
petr at hroch dot info
14-Nov-2006 11:11
While function ncurses_nodelay() is still not implemented and if you need a non-blocking getch,
following code might help.

$init = ncurses_init();
$full = ncurses_newwin (0,0,0,0);
ncurses_wborder($full,0,0,0,0,0,0,0,0);
ncurses_wrefresh($full);

$running = true;
$fp = fopen("php://stdin","r");     //open direct input stream for reading
stream_set_blocking($fp,0);        //set non-blocking mode

while ($running) {
  while (($buf = fgets($fp, 4096)) != false) {  //fgets is required if we want to handle escape sequenced keys
     $buffer .= $buf;
  }
  if ($buffer != "") {
     switch ($buffer) {      
       case " ": {            //exit on space key
         ncurses_end();
        exit;        
       }
       default: {
         ncurses_mvwaddstr($full,2,2,"$buffer");  //display input
       }
     }
    $buffer = ""; //empty buffer
   }

  // You can do something interesting here, while we're not waiting for an input
  ncurses_mvwaddstr($full,4,4,microtime(true));
  ncurses_wrefresh($full); 

  usleep(1); //reduce cpu usage
}
php at kormoc dot com
23-Nov-2005 12:45
After banging my head over this for awhile, I discovered, you must use ncurses_keypad($window, true); to enable the arrow keys and f keys to work correctly.
joeldegan AT yahoo.com
16-Dec-2002 09:29
When using getch to capture KEY_* events remember that the keypad is arranged like this:

+-----+------+-------+
| A1  |  up  |  A3   |
+-----+------+-------+
|left |  B2  | right |
+-----+------+-------+
| C1  | down |    C3  |
+-----+------+-------+

You use has_key to capture these and act upon them.

man curs_getch for more info.
pablorNOSPAM at nkstudios dot net
13-Sep-2002 10:40
A custom php ncurses_getstr function..

<?php

function ncurses_getstr($strlen){
    for (
$x=0;$x<$strlen;$x++){
       
$string .= chr(ncurses_getch());
    }
    return
$string;
}

ncurses_init();
ncurses_addstr(ncurses_getstr(6));
ncurses_refresh();
ncurses_getch();
ncurses_end();

?>

ncurses_getmaxyx> <ncurses_flushinp
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites