PHP Doku:: Reads a character from keyboard (window) - function.ncurses-wgetch.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzEingabezeilenspezifische ErweiterungenNcurses Terminal Screen ControlNcurses Funktionenncurses_wgetch

Ein Service von Reinhard Neidl - Webprogrammierung.

Ncurses Funktionen

<<ncurses_werase

ncurses_whline>>

ncurses_wgetch

(PHP 4 >= 4.2.0, PHP 5 < 5.3.0, PECL ncurses >= 1.0.0)

ncurses_wgetchReads a character from keyboard (window)

Beschreibung

int ncurses_wgetch ( resource $window )
Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Parameter-Liste

window


3 BenutzerBeiträge:
- Beiträge aktualisieren...
johns at servangle dot net
7.01.2007 17:01
Something worth noting here; I noticed that with ncurses_wgetch function keys are broken into multiple codes while ncurses_getch returns only one attributed code.

For example, with ncurses_wgetch pressing an up arrow results in three codes 27 91 65 (an ascii escape sequence). The problem is subsequent calls to ncurses_wgetch are required to acquire all three codes. Unfortunately, pressing an “A” key for example would result in only a single code of 65. This makes it hard to trap for both function keys and regular keys.

However, with ncurses_getch an up arrow results in a single attributed code of 259 or the “NCURSES_KEY_UP” key constant. An “A” key is still 65.
john at bowlingball dot com
22.02.2006 17:19
By default ncurses_wgetch does not return keypad keys.  If you need to use function or arrow keys in a sub window, simply do this first.

ncurses_keypad($win, TRUE);
gf3 dot bm3 at gmail dot com
9.10.2004 1:41
Heres a function to get a string from a specific window and return it on ENTER.

// Dynamic String Input (converts INT ASCII to CHAR)
function ncurses_wgetstr($win){
    $strlen = 1;
    for ($sx=0;$sx<$strlen;$sx++){
        $strlen++;
        $ch = ncurses_wgetch($win);
        if ($ch == 13){
            return $str;
            break 2;
        }
        $str .= chr($ch);
    }
}

Example:

$ncurse = ncurses_init();
$fullscreen = ncurses_newwin (0,0,  0,0);
ncurses_border(0,0,  0,0,  0,0,  0,0);
ncurses_refresh();

while (1){
    $keyPressed = ncurses_wgetstr($fullscreen);
    ncurses_wrefresh($fullscreen);
}



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)