note 42373 added to function.ncurses-clear

From: Date: Thu, 13 May 2004 19:49:33 +0000
Subject: note 42373 added to function.ncurses-clear
Groups: php.notes 
Request: Send a blank email to php-notes+get-69580@lists.php.net to get a copy of this message
When your script exits, after ncurses_clear() was called, it could leave your terminal in an inconsistent state. Therefore, you should call ncurses_savetty() in a constructor and nurses_resetty() in a destructor, to ensure, that your terminal is working fine after your script exits. Here is an example code snippet, on how to use this function, without falling into trouble ;-) <? // PHP5 Example class foo { /* Foo constructor */ function __construct() { /* Initialize ncurses first */ ncurses_init(); /* Save your tty !!! */ ncurses_savetty(); } function bar () { /* Clear the screen and wait a few seconds */ ncurses_clear(); sleep(5); } /* Foo destructor */ function __destruct() { /* Restore your terminal settings */ ncurses_resetty(); /* End ncurses and clean up */ ncurses_end(); } } $test_ncurses = new foo; $test_ncurses->bar(); ?> ---- Manual Page -- http://www.php.net/manual/en/function.ncurses-clear.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42373 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42373&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42373&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69580) next »