Add PgUp/Dn/Home/End to menu, bugfixes

This commit is contained in:
2024-10-05 17:54:49 +02:00
parent 0a82eb7a3c
commit f389e5985f
3 changed files with 131 additions and 73 deletions
+28
View File
@@ -27,10 +27,26 @@ class MessageBox
private int $scroll = 0;
/**
* constructor
*
* @param Terminal $terminal
* @param string $text
* @param string $title
*/
public function __construct(private Terminal $terminal, private string $text, private string $title = 'Message')
{
}
/**
* Display the message box
*
* @param int $left
* @param int $top
* @param int $width
* @param int $height
* @return void
*/
public function display(int $left, int $top, int $width, int $height = 0): void
{
$wrapped = explode("\n", wordwrap($this->text, $width - 4, cut_long_words:true));
@@ -76,6 +92,18 @@ class MessageBox
return;
}
/**
* Redraw the message box
*
* @param int $left
* @param int $top
* @param int $width
* @param int $height
* @param array $wrapped
* @param string $title
* @param int $maxScroll
* @return void
*/
private function redraw(int $left, int $top, int $width, int $height, array $wrapped, string $title, int $maxScroll) {
$visibleItems = $height - 4;