note 40198 added to ref.ncurses
| From: | HabibValanejad at rn2 dot php dot net | Date: | Wed, 25 Feb 2004 02:46:30 +0000 |
| Subject: | note 40198 added to ref.ncurses | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65680@lists.php.net to get a copy of this message | ||
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 */
}
----
Manual Page -- http://www.php.net/manual/en/ref.ncurses.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40198
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40198&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40198&report=yes
Search -- http://master.php.net/manage/user-notes.php