From cb93127fa2a553b8169cae72e1759a618ae32ba1 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 13 Jun 2018 11:13:33 +0000 Subject: [PATCH] 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 --- console.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/console.php b/console.php index 2a21c3a..d7f7b63 100644 --- a/console.php +++ b/console.php @@ -70,6 +70,15 @@ private $usleep = 0; // Do not display anything, so we don't see the characters when the user is // deleting. exec ("stty -echo -icanon min 1 time 0"); + $this->updateTerminalSize (); + } + // }}} + + /** Update the terminal size + */ + public function updateTerminalSize () + // {{{ + { $termSize = exec ("stty size", $null, $rc); if ($rc === 0) { @@ -82,7 +91,7 @@ private $usleep = 0; else $this->termWidth = 80; } - // }}} + // }}} /** The destructor return the terminal to initial state */ @@ -323,7 +332,7 @@ private $usleep = 0; // Refresh page (Ctrl+L) // {{{ { - echo "\033[2J\033[;H"; + echo "\033[2J\033[;H\033c"; $cursorPos = mb_strlen ($prompt.$string) + 1; $this->rewriteLine ($prompt.$string); $this->moveCursor ($cursorPos);