PHP Doku:: Switch of input buffering - function.ncurses-cbreak.html

Verlauf / Chronik / History: (1) anzeigen

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

Ein Service von Reinhard Neidl - Webprogrammierung.

Ncurses Funktionen

<<ncurses_can_change_color

ncurses_clear>>

ncurses_cbreak

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

ncurses_cbreakSwitch of input buffering

Beschreibung

bool ncurses_cbreak ( void )
Warnung

Diese Funktion ist EXPERIMENTELL. Das Verhalten, der Funktionsname und alles Andere, was hier dokumentiert ist, kann sich in zukünftigen PHP-Versionen ohne Ankündigung ändern. Seien Sie gewarnt und verwenden Sie diese Funktion auf eigenes Risiko.

Disables line buffering and character processing (interrupt and flow control characters are unaffected), making characters typed by the user immediately available to the program.

Rückgabewerte

Returns TRUE or NCURSES_ERR if any error occurred.

Siehe auch


2 BenutzerBeiträge:
- Beiträge aktualisieren...
php at kormoc dot com
28.11.2005 18:16
re satoru's post,
While it's not using cbreak, it sorta is an example. The only difference between raw and cbreak is how control keys are delt with.

Quoted from the ncurses_programming_howto:
Normally the terminal driver buffers the characters a user types until a new line or carriage return is encountered. But most programs require that the characters be available as soon as the user types them. The above two functions are used to disable line buffering. The difference between these two functions is in the way control characters like suspend (CTRL-Z), interrupt and quit (CTRL-C) are passed to the program. In the raw() mode these characters are directly passed to the program without generating a signal. In the cbreak() mode these control characters are interpreted as any other character by the terminal driver.
satoru
6.11.2005 8:14
<?php
 
/**************************************
  [WARNING!]
  Your terminal may be uncontrollable.

  [HOW TO EXIT]
  Push space key to terminate raw mode.

  [TESTING]
  Tested with FreeBSD5.3R + PHP5.0.5-CLI.
  The option '--with-ncurses' required.
  **************************************/

 
$tty = system("tty");
 
$handle = fopen($tty, "r");
  if (!
$handle)
    exit(
"cannot open $tty.\\n");

  print
"Push space key to terminate.\\n";

 
ncurses_init();
 
ncurses_raw();
  do {
   
$ch = fread($handle, 1);
   
printf('[%d] ', ord($ch));
  } while (
$ch != " " && ord($ch) != 3);
 
ncurses_noraw();
 
ncurses_end();
  print
"\\n";

 
fclose($handle);
?>



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",...)