diff --git a/console.php b/console.php index 3bc7d62..ab057bc 100644 --- a/console.php +++ b/console.php @@ -12,7 +12,13 @@ * Allow the user to use arrow keys and the shortcuts Ctrl+arrow, Ctrl+L, * Ctrl+U, Ctrl+W * To not allow the stop of the program by Ctrl+C, you can add - * exec ("stty intr ^J"); + * exec ("stty intr ^J"); + * To update the window size when the terminal is resized, use after console + * instanciation : + * declare(ticks = 1); + * pcntl_signal (SIGWINCH, function () use ($console) { + * $console->updateTerminalSize (); + * }); */ class console { @@ -135,6 +141,7 @@ private $usleep = 0; public function echo ($message) // {{{ { +$this->debug ("'$message'"); echo $message; $this->lineContent .= $message; } @@ -340,7 +347,7 @@ private $usleep = 0; { $this->clearLine (); $this->lineContent = ""; - $this->echo ($prompt."\n"); + echo "\r$prompt\n"; return ""; } // }}} @@ -617,8 +624,9 @@ private $usleep = 0; public function clearLine () // {{{ { - echo "\r".str_repeat (" ", mb_strlen ($this->lineContent))."\r"; + echo "\r\033[K"; $this->lineContent = ""; + $this->cursorPos = 0; } // }}}