console : clear the history lines when using Ctrl+L
console : add a public method to update the window size. git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4238 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
13
console.php
13
console.php
@@ -70,6 +70,15 @@ private $usleep = 0;
|
|||||||
// Do not display anything, so we don't see the characters when the user is
|
// Do not display anything, so we don't see the characters when the user is
|
||||||
// deleting.
|
// deleting.
|
||||||
exec ("stty -echo -icanon min 1 time 0");
|
exec ("stty -echo -icanon min 1 time 0");
|
||||||
|
$this->updateTerminalSize ();
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
/** Update the terminal size
|
||||||
|
*/
|
||||||
|
public function updateTerminalSize ()
|
||||||
|
// {{{
|
||||||
|
{
|
||||||
$termSize = exec ("stty size", $null, $rc);
|
$termSize = exec ("stty size", $null, $rc);
|
||||||
if ($rc === 0)
|
if ($rc === 0)
|
||||||
{
|
{
|
||||||
@@ -82,7 +91,7 @@ private $usleep = 0;
|
|||||||
else
|
else
|
||||||
$this->termWidth = 80;
|
$this->termWidth = 80;
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
/** The destructor return the terminal to initial state
|
/** The destructor return the terminal to initial state
|
||||||
*/
|
*/
|
||||||
@@ -323,7 +332,7 @@ private $usleep = 0;
|
|||||||
// Refresh page (Ctrl+L)
|
// Refresh page (Ctrl+L)
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
echo "\033[2J\033[;H";
|
echo "\033[2J\033[;H\033c";
|
||||||
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
||||||
$this->rewriteLine ($prompt.$string);
|
$this->rewriteLine ($prompt.$string);
|
||||||
$this->moveCursor ($cursorPos);
|
$this->moveCursor ($cursorPos);
|
||||||
|
|||||||
Reference in New Issue
Block a user