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

search for in the

ncurses_addch> <mysqli_warning_count
Last updated: Tue, 27 Nov 2007

view this page in

Funciones de Control de Pantalla con Terminal Ncurses

Introducción

ncurses (new curses) es un sistema de emulación del paquete curses del Sistema V 4.0 (y superiores). Usa formatos terminfo, soporta pads, colores, resaltados múltiples, caracteres de formulario y asignaciones de funciones de teclado. Debido a la naturaleza interactiva de esta biblioteca, ésta será de poca utilidad para la escritura de aplicaciones Web, pero puede ser útil cuando se escriben scripts orientados al uso de PHP desde la línea de comandos.

Warning

Esta extensión es EXPERIMENTAL. Esto significa que el comportamiento de esta extensión, los nombre de sus funciones y en definitiva TODO lo documentado sobre esta extensión, puede cambiar en una futura versión de PHP SIN AVISO. La advertencia queda hecha, y utilizar esta extensión queda bajo su propia responsabilidad.

Ncurses se encuentra disponible para las siguientes plataformas:

  • AIX

  • BeOS

  • Cygwin

  • Digital Unix (aka OSF1)

  • FreeBSD

  • GNU/Linux

  • HPUX

  • IRIX

  • OS/2

  • SCO OpenServer

  • Solaris

  • SunOS

Note: This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 6.0.0

Requisitos

Necesita las bibliotecas ncurses y sus archivos de cabecera. Descargue la última versión desde » ftp://ftp.gnu.org/pub/gnu/ncurses/ o algún otro mirror GNU.

Instalación

Para que estas funciones trabajen, debe compilar la versión CGI o CLI de PHP con --with-ncurses[=DIR].

Configuración en tiempo de ejecución

Esta extensión no tiene directivas de configuración en php.ini.

Tipos de recursos

Esta extensión define los recursos de ventana, panel y relleno.

Constantes predefinidas

Estas constantes están definidas por esta extensión y estarán disponibles solamente cuando la extensión ha sido o bien compilada dentro de PHP o grabada dinámicamente en tiempo de ejecución.

Códigos de error

En caso de fallos, las funciones ncurses devuelven NCURSES_ERR.

Colores

constantes de color de ncurses
constante significado
NCURSES_COLOR_BLACK sin color (negro)
NCURSES_COLOR_WHITE blanco
NCURSES_COLOR_RED rojo - soportado cuando la terminal se encuentra en modo de color
NCURSES_COLOR_GREEN verde - soportado cuando la terminal se encuentra en modo de color
NCURSES_COLOR_YELLOW amarillo - soportado cuando la terminal se encuentra en modo de color
NCURSES_COLOR_BLUE azul - soportado cuando la terminal se encuentra en modo de color
NCURSES_COLOR_CYAN cyan - soportado cuando la terminal se encuentra en modo de color
NCURSES_COLOR_MAGENTA magenta - soportado cuando la terminal se encuentra en modo de color

Teclas

constantes de teclas ncurses
constante significado
NCURSES_KEY_F0 - NCURSES_KEY_F64 teclas de función F1 - F64
NCURSES_KEY_DOWN flecha hacia abajo
NCURSES_KEY_UP flecha hacia arriba
NCURSES_KEY_LEFT flecha hacia la izquierda
NCURSES_KEY_RIGHT flecha hacia la derecha
NCURSES_KEY_HOME tecla home (flecha arriba+izquierda)
NCURSES_KEY_BACKSPACE backspace
NCURSES_KEY_DL eliminar línea
NCURSES_KEY_IL insertar línea
NCURSES_KEY_DC eliminar caracter
NCURSES_KEY_IC insertar caracter o entrar en modo de inserción
NCURSES_KEY_EIC salir de modo de inserción de caracteres
NCURSES_KEY_CLEAR limpiar la pantalla
NCURSES_KEY_EOS limpiar hasta el fin de la pantalla
NCURSES_KEY_EOL limpiar hasta el fin de la línea
NCURSES_KEY_SF desplazarse una línea hacia adelante
NCURSES_KEY_SR desplazarse una línea hacia atrás
NCURSES_KEY_NPAGE siguiente página
NCURSES_KEY_PPAGE página anterior
NCURSES_KEY_STAB definir tab
NCURSES_KEY_CTAB eliminar tab
NCURSES_KEY_CATAB eliminar todos los tabs
NCURSES_KEY_SRESET reset suave (parcial)
NCURSES_KEY_RESET reset o reset fuerte
NCURSES_KEY_PRINT imprimir
NCURSES_KEY_LL izquierda inferior
NCURSES_KEY_A1 izquierda superior del teclado numérico
NCURSES_KEY_A3 derecha superior del teclado numérico
NCURSES_KEY_B2 centro del teclado numérico
NCURSES_KEY_C1 izquierda inferior del teclado numérico
NCURSES_KEY_C3 derecha inferior del teclado numérico
NCURSES_KEY_BTAB tab hacia atrás
NCURSES_KEY_BEG comienzo
NCURSES_KEY_CANCEL cancelar
NCURSES_KEY_CLOSE cerrar
NCURSES_KEY_COMMAND cmd (comando)
NCURSES_KEY_COPY copiar
NCURSES_KEY_CREATE crear
NCURSES_KEY_END fin
NCURSES_KEY_EXIT salida
NCURSES_KEY_FIND encontrar
NCURSES_KEY_HELP ayuda
NCURSES_KEY_MARK marca
NCURSES_KEY_MESSAGE mensaje
NCURSES_KEY_MOVE mover
NCURSES_KEY_NEXT siguiente
NCURSES_KEY_OPEN abrir
NCURSES_KEY_OPTIONS opciones
NCURSES_KEY_PREVIOUS anterior
NCURSES_KEY_REDO rehacer
NCURSES_KEY_REFERENCE ref (referencia)
NCURSES_KEY_REFRESH refrescar
NCURSES_KEY_REPLACE reemplazar
NCURSES_KEY_RESTART reiniciar
NCURSES_KEY_RESUME reiniciar
NCURSES_KEY_SAVE guardar
NCURSES_KEY_SBEG comienzo usando shift
NCURSES_KEY_SCANCEL cancelar usando shift
NCURSES_KEY_SCOMMAND comando usando shift
NCURSES_KEY_SCOPY copiar usando shift
NCURSES_KEY_SCREATE crear usando shift
NCURSES_KEY_SDC eliminar caracter usando shift
NCURSES_KEY_SDL eliminar línea usando shift
NCURSES_KEY_SELECT seleccionar
NCURSES_KEY_SEND final usando shift
NCURSES_KEY_SEOL fin de línea usando shift
NCURSES_KEY_SEXIT salida usando shift
NCURSES_KEY_SFIND encontrar usando shift
NCURSES_KEY_SHELP ayuda usando shift
NCURSES_KEY_SHOME home usando shift
NCURSES_KEY_SIC entrada usando shift
NCURSES_KEY_SLEFT flecha hacia la izquierda usando shift
NCURSES_KEY_SMESSAGE mensaje usando shift
NCURSES_KEY_SMOVE mover usando shift
NCURSES_KEY_SNEXT siguiente usando shift
NCURSES_KEY_SOPTIONS opciones usando shift
NCURSES_KEY_SPREVIOUS anterior usando shift
NCURSES_KEY_SPRINT imprimir usando shift
NCURSES_KEY_SREDO rehacer usando shift
NCURSES_KEY_SREPLACE reemplazar usando shift
NCURSES_KEY_SRIGHT flecha hacia la derecha usando shift
NCURSES_KEY_SRSUME reiniciar usando shift
NCURSES_KEY_SSAVE guardar usando shift
NCURSES_KEY_SSUSPEND suspender usando shift
NCURSES_KEY_UNDO deshacer
NCURSES_KEY_MOUSE evento del mouse ha ocurrido
NCURSES_KEY_MAX valor máximo de tecla

Mouse

constantes de mouse
Constante significado
NCURSES_BUTTON1_RELEASED - NCURSES_BUTTON4_RELEASED botón (1-4) liberado
NCURSES_BUTTON1_PRESSED - NCURSES_BUTTON4_PRESSED botón (1-4) presionado
NCURSES_BUTTON1_CLICKED - NCURSES_BUTTON4_CLICKED botón (1-4) pulsado
NCURSES_BUTTON1_DOUBLE_CLICKED - NCURSES_BUTTON4_DOUBLE_CLICKED botón (1-4) pulsado dos veces
NCURSES_BUTTON1_TRIPLE_CLICKED - NCURSES_BUTTON4_TRIPLE_CLICKED botón (1-4) pulsado tres veces
NCURSES_BUTTON_CTRL ctrl presionado durante el clic
NCURSES_BUTTON_SHIFT shift presionado durante el clic
NCURSES_BUTTON_ALT alt presionado durante el clic
NCURSES_ALL_MOUSE_EVENTS reportar todos los eventos del mouse
NCURSES_REPORT_MOUSE_POSITION reportar la posición del mouse

Table of Contents



ncurses_addch> <mysqli_warning_count
Last updated: Tue, 27 Nov 2007
 
add a note add a note User Contributed Notes
Ncurses
fisher
02-Jan-2007 08:02
new version of PHP ncurses FAQ is here: http://alexeyrybak.com/php_ncurses_faq.html
g_a at freemail dot deletethispart dot hu
02-Feb-2006 04:03
To determine screen width and height without any external (OS specific) commands, I use:

<?php
ncurses_init
();
$fullscreen = ncurses_newwin ( 0, 0, 0, 0);
ncurses_getmaxyx($fullscreen,&$a,&$b);
ncurses_end();
echo
"Width:$b\nHeight:$a\n";
?>
krzysztof dot gorzelak at gmail dot com
05-Nov-2005 12:36
Here is a small example, how to use STDIN to read keys combinations in console.

$stdin = fopen('php://stdin', 'r');
stream_set_timeout($stdin, 1);
while (1) {
  $temp="";
    while (1) {
      if(stream_select($read = array($stdin), $write = NULL, $except = NULL, 0))
        $temp .= ord(fgetc($stdin));
      else break;
    }

    // F1 : $temp == 27914949126
    // ALT+F1 : $temp = 2727914949126
    // ....
   
    usleep("50000");
}
fisher
12-Jun-2005 11:23
russian speakers can find a practice php+ncurses faq with some useful samples here
http://fisher.phpclub.net/php_ncurses_faq.html
php at nospam dot feraudet dot com
15-Mar-2005 04:02
just an other ncurses tetris ...
In php with lib_ncurses of course ..

http://feraudet.com/phpntetris.php.txt

Cyril Feraudet
kermodebear at kermodebear dot org
17-Jun-2004 10:27
An implementation of a scrolling selection box:

<?php
function ncurses_menu_select( $options, $values, $max_height = 7, $max_width = 20, $y = 2, $x = 2 ) {
       
// Size inside of borders
       
$height = $max_height - 2;
       
$width  = $max_width  - 2;

       
// Number of options
       
$num_options = count( $options );

       
// Trim all values to fit
       
foreach( $options as $key => $value ) {
               
$options[ $key ] = substr( $value, 0, $width );
        }

       
// Create Window
       
$menu_window = ncurses_newwin( $max_height, $max_width, $y, $x );
       
ncurses_wborder( $menu_window, 0, 0, 0, 0, 0, 0, 0, 0 );

       
// Initialize Window
       
$current = 0; // Currently selected
       
$position = 1; // Position in list
       
$topitem = 0; // Top menu item
       
for ( $a = 0; $a < min( $height, $num_options ); $a++ ) {
                if (
$a == $current ) {
                       
ncurses_wattron( $menu_window, NCURSES_A_REVERSE );
                       
ncurses_mvwaddstr( $menu_window, 1 + $a, 1, $options[ $a ] );
                       
ncurses_wattroff( $menu_window, NCURSES_A_REVERSE );
                } else {
                       
ncurses_mvwaddstr( $menu_window, 1 + $a, 1, $options[ $a ] );
                }
        }
       
ncurses_mvwaddstr( $menu_window, 1, 0, '*' );
       
ncurses_wrefresh( $menu_window );
       
// Loop until a selection is made
       
while( ! in_array( $key = ncurses_getch( $menu_window ), array( 13, 10 ) ) ) {
                if (
$key == NCURSES_KEY_UP && $current > 0 ) {
                       
$move = -1;
                } else if (
$key == NCURSES_KEY_DOWN && $current < $num_options - 1 ) {
                       
$move = 1;
                } else {
                        continue;
                }

               
$current += $move;
               
$position += $move;
               
// If we scroll off the window, redraw items.
               
if ( $position < 1 || $position > $height ) {
                        if (
$position < 1 ) {
                               
$position = 1;
                        } else {
                               
$position = $height;
                        }
                       
$topitem += $move;
                        for (
$a = 1; $a <= $height; $a++ ) {
                               
ncurses_mvwaddstr( $menu_window, $a, 1, str_repeat( ' ', $width ) );
                                if (
$a == $position ) {
                                       
ncurses_wattron( $menu_window, NCURSES_A_REVERSE );
                                       
ncurses_mvwaddstr( $menu_window, $a, 1, $options[ $topitem + $a - 1 ] );
                                       
ncurses_wattroff( $menu_window, NCURSES_A_REVERSE );
                                } else {
                                       
ncurses_mvwaddstr( $menu_window, $a, 1, $options[ $topitem + $a - 1 ] );
                                }
                        }
                } else {
// Just update changed items
                       
ncurses_wattron( $menu_window, NCURSES_A_REVERSE );
                       
ncurses_mvwaddstr( $menu_window, $position, 1, $options[ $current ] );
                       
ncurses_wattroff( $menu_window, NCURSES_A_REVERSE );
                       
ncurses_mvwaddstr( $menu_window, $position - $move, 1, $options[ $current - $move ] );
                }
               
// Update 'scroll bar dot'
               
ncurses_wborder( $menu_window, 0, 0, 0, 0, 0, 0, 0, 0 );
               
$dot_position = round ( ( $current / $num_options ) * ( $height - 1 ) );
               
ncurses_mvwaddstr( $menu_window, 1 + $dot_position, 0, '*' );

               
ncurses_wrefresh( $menu_window );
        }
        return
$values[ $current ];
}

?>
kermodebear at kermodebear dot org
17-Jun-2004 08:21
Not calling ncurses_end() can (will) cause issues with terminals. Although registering a shutdown function which includes ncurses_end() may help, sometimes things go awry and you're stuck with a terminal that is acting in strange ways.

This can be fixed! *NIX systems (FreeBSD, Linux, UNIX, et al.) usually support the 'reset' command which resets the terminal settings and allows you to get things back to normal.
kermodebear at kermodebear dot org
17-Jun-2004 08:17
Here is a function that takes an associative array, presents a menu in a new window, allows the user to make a choice using up and down arrows and the enter key, and returns the value of the menu item.

Limitations include:
No way of scrolling a long list, either horiontally or vertically;
No arguments for placement on screen, although this is easy to add;
No multiple selection;
Will produce all kinds of errors and warnings if the terminal is smaller than is necessary to create the window.

I'm very new at using the ncurses library; Comments and improvements would be greatly appreciated!

<?php
/**
 * Create a simple selection menu
 * @param array Associative array; The value will be shown on the menu, while the key will be returned when the associated value is selected.
 * @return mixed
 */
function ncurses_menu_select( $menu ) {
       
$keys = array_keys( $menu );
       
$values = array_values( $menu );

       
$height = $width = 0;
       
$height = count( $menu ) + 2;
        foreach(
$values as $value ) {
               
$width = max( $width, strlen( $value ) + 2 );
        }

       
$menu_window = ncurses_newwin( $height, $width, 5, 5 );
       
ncurses_wborder( $menu_window, 0,0, 0,0, 0,0, 0,0 );

       
$current = 0;
        for(
$a = 0; $a < count( $values ); $a++ ) {
                if (
$a == $current ) {
                       
ncurses_wattron( $menu_window, NCURSES_A_REVERSE );
                       
ncurses_mvwaddstr( $menu_window, 1 + $a, 1, $values[ $a ] );
                       
ncurses_wattroff( $menu_window, NCURSES_A_REVERSE );
                } else {
                       
ncurses_mvwaddstr( $menu_window, 1 + $a, 1, $values[ $a ] );
                }
        }
       
ncurses_wrefresh( $menu_window );

        while( !
in_array( $key = ncurses_getch( $menu_window ), array( 13, 10 ) ) ) {
                if (
$key == NCURSES_KEY_UP AND $current > 0 ) {
                       
$move = -1;
                } else if (
$key == NCURSES_KEY_DOWN and $current < count( $values ) - 1 ) {
                       
$move = 1;
                } else {
                       
$move = 0;
                }
               
ncurses_mvwaddstr( $menu_window, 1 + $current, 1, $values[ $current ] );
               
$current += $move;
               
ncurses_wattron( $menu_window, NCURSES_A_REVERSE );
               
ncurses_mvwaddstr( $menu_window, 1 + $current, 1, $values[ $current ] );
               
ncurses_wattroff( $menu_window, NCURSES_A_REVERSE );
               
ncurses_wrefresh( $menu_window );
        }
       
ncurses_delwin( $menu_window );
        return
$keys[ $current ];
}
?>

Example Use:

<?php
// Initialie ncurses
$ncurse = ncurses_init();
// A full screen window
$fullscreen = ncurses_newwin ( 0, 0, 0, 0);
// Add a pretty border
ncurses_border(0,0, 0,0, 0,0, 0,0);
// Draw everything so far
ncurses_refresh();

// Set up menu array
$menu_items = array(
       
'one'   => 'Menu Item #1',
       
'two'   => 'Menu Item #2',
       
'three' => 'Menu Item #3' );
// Display menu and return selection
$selection = ncurses_menu_select( $menu_items );

// Print selection
ncurses_mvaddstr( 1, 1, 'You selected ' . $menu_items[$selection] . ' with the value ' . $selection );

// Draw updates
ncurses_refresh( $fullscreen );
// End
ncurses_end();
?>
Habib Valanejad
25-Feb-2004 07:46
What if you want to draw a new window and after removing it, showing the pervious screen again? Unfortunately, there is no such a thing in php/ncurses as there is in original curses library (touchwin if I'm not mistaken - It has been a long time!).
However, you can do this by a simple trick! You can
dump the screen to a temp file and then restore it back
again!
Take a look at this function:

# Function: show_a_win()
# - Displays a small window and writes something in it.
# - waits for a key
# - shows the pervious screen again
function show_a_win()
{
   # Dump the current screen into a temp file:
   $tmpfile = tempnam("/tmp", "dump.");
   # Create a new window.
   $newwin = ncurses_newwin(4, 60, 10, 10);
   # Write something and then refresh it
   ncurses_mvwaddstr($newwin, 1, 1, "This is a test.");
   ncurses_wrefresh($newwin);
   # Wait for a key
   ncurses_wgetch($newwin);
   ncurses_delwin($newwin);  /* delete the window */
   /* Restore the screen the same way it was before entering
    * into the function:
    */
   ncurses_scr_restore($tmpfile);
   unlink($tmpfile);   /* Remove temp file */
}
Habib Valanejad
12-Dec-2003 12:30
Here is a function which would do the job for missing
ncurses_wclrtoeol() function:
/* wclrtoeol()
 * Erases  the  current line to the right of the cursor
*/
function wclrtoeol($win)
{
   # get current position
   ncurses_getyx($win, &$crow, &$ccol);
   # get maximum row and col for this window:
   ncurses_getmaxyx($win, &$max_row, &$max_col);
   for ($col = $ccol; $col < $max_col; $col ++){
      ncurses_wmove($win, $crow, $col);
      ncurses_waddch($win, 32);
   }
}
rainman at darkwired dot org
14-Aug-2003 05:49
A simple article I wrote about php-ncurses:
https://www.darkwired.org/pub/papers/articles/php-ncurses/
rainman at darkwired dot org
01-Aug-2003 02:55
This is not meant as spam to get people to use my client.

I have been working on a PHP4 IRC client with ncurses interface and I think it is a useful example of how ncurses with php could be used.
It is GPL licensed so you can just go and take a loot at it.

It can be found at http://torc.sourceforge.net or http://www.darkwired.org/projects/torc/

I hope this will help out some of you because php ncurses can be quite difficult I experienced :]

For any questions about the code you can ofcourse just mail me.
Habib Valanejad
26-Jun-2003 12:50
I had a small problem building php+ncurses support.
ncurses include files were installed in:
ncurses_installed_dir/include/ncurses
This caused problems when building php with ncurse support.
php was looking for include files in:
ncurses_installed_dir/include
However, include files were located in include/ncurses

I had to make symbolic links of files in ncurses directory so php could see them:
# cd ncurses_insalled_directory/include
# ln -s ncurses/* .
After that it worked.
alex at kazik dot de
19-Jun-2003 03:29
Here is a more complex example, I wrote:
http://alex.kazik.de/ncurses1.html
philip at cornado dot com
05-Jun-2003 09:01
A nice introductory PHP + Ncurses tutorial can be seen here:
* http://www.zend.com/zend/tut/tut-degan.php
Habib Valanejad
28-Mar-2003 05:13
For those of you who want to check if <ENTER> key is passed,
you have to check the key agains both NL and CR keys:

function get_str()
{
   for ($str = "";;){
      $key = ncurses_getch();
      switch ($key){
        case 10:   // newline
        case 13:   // Carrige Return
           return($str);
        default:
           $str .= chr($key);
            ncurses_refresh();
      } // switch
   } // for
} // get_str()

Hope that would help.
25-Mar-2003 05:18
In the example above, if you run resize from a C shell it will output the sizes in C shell syntax, run resize with -u to force Bourne syntax:
The $win parameter is just for future compatibility.

function ncurses_getmaxyx($win, &$y, &$x)
{
        exec("/usr/X11R6/bin/resize -u", $output);
        $cols = explode("=", $output[0]);
        $rows = explode("=", $output[1]);
        $x = intval($cols[1]);
        $y = intval($rows[1]);
}
joeldegan AT yahoo.com
15-Dec-2002 10:26
See the documentation for ncurses_border and ncurses_wrefresh for some more examples of doing windowing and dynamic sizing.. I also posted some information to the zend.com code-gallery for doing ncurses under php.
joeldegan AT yahoo.com
15-Dec-2002 01:10
I noticed a lack of a getxy() function so I wrote one.
You may need to change the path for your resize cmd.

<?
function getxy(){
   
$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;
}

print_r(getxy());
?>
joeldegan AT yahoo.com
15-Dec-2002 12:37
This is from the examples that come with the latest release.

From:
php-4.3.0RC3/ext/ncurses/example1.php

I found this useful...

<?php
$n
=0;
ncurses_init();
if(
ncurses_has_colors()){
ncurses_start_color();
       
ncurses_init_pair(1,NCURSES_COLOR_RED,NCURSES_COLOR_BLACK);
       
ncurses_init_pair(2,NCURSES_COLOR_GREEN,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);
}
while(
1){
for (
$x=0; $x<80; $x++) {
for (
$y=0; $y<24; $y++) {
 
$n++;
 
ncurses_move($y,$x);
 
ncurses_addch($n+64);
 
ncurses_color_set($n%8);
 
ncurses_refresh();
  if(
$n>26)$n=0;
}
}
ncurses_getch();
}
?>
joeldegan AT yahoo.com
14-Dec-2002 08:56
actually *that* example does not work...
here is one that I took and trimmed down from the ncurses examples.
I will do some more and post them here..

<?
ncurses_init
();
##############################################
ncurses_noecho();

   
$large = ncurses_newwin(20, 60, 2, 10);
   
$small = ncurses_newwin(10, 30, 7, 25);
   
   
ncurses_refresh();
   
ncurses_wrefresh($large);
   
ncurses_wrefresh($small);

   
ncurses_mvwaddstr($small, 5, 5, "   Test  String   ");
   
ncurses_wrefresh($small);
   
ncurses_getch();

##############################################
ncurses_end(); // Clean up, and quit
?>

This is from PHP 4.3.0RC0 compiled with the following flags..
./configure --prefix=/wwwroot/php --with-config-file-path=/wwwroot/php --with-mysql --enable-pcntl --with-tsrm-pthreads --enable-sysvsem --enable-sysvshm --with-curl --enable-bcmath --enable-sigchild --enable-sockets --with-ncurses
nweeks at utas dot edu dot au
08-Nov-2002 02:43
With your CGI version of PHP compiled with ncurses support, console apps are amazingly easy!

For example:
whack the following into a file, chmod +x it, and run it.

#!/usr/local/bin/php -q
<?php
ncurses_init
();
ncurses_border(25,25,18,18,24,24,23,23); // Do a lovely border
ncurses_move(1,1); // Start top left(inside border)
ncurses_addstr("Welcome to NCurses");
ncurses_addstr(" with PHP!");
ncurses_refresh(); // Send buffer to screen
ncurses_end(); // Clean up, and quit
?&gt;

You'll notice the second addstr simply tacks onto the first.
zak at php dot net
30-May-2002 02:34
There is a simple ncurses application in the PHP source tree. See http://cvs.php.net/co.php/php-src/ext/ncurses/example1.php?r=1.1

ncurses_addch> <mysqli_warning_count
Last updated: Tue, 27 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites