Misc fixes

This commit is contained in:
2024-10-07 00:30:09 +02:00
parent 46bf135446
commit 0e1354bd47
6 changed files with 33 additions and 32 deletions
+3 -3
View File
@@ -83,12 +83,12 @@ class Menu
* @param string|int|null $value
* @return mixed
*/
public function display(int $left, int $top, int $width, int $height = 0, string|int|null $value): mixed
public function display(int $left, int $top, int $width, int $height = 0, string|int|null $value = null): mixed
{
//$this->index = 0;
$keys = array_keys($this->items);
$this->index = array_search($value, $keys) ?? 0;
$this->index = array_search($value, $keys) ?: 0;
[$w,$h] = $this->terminal->getSize();
if ($height == 0) {
@@ -187,7 +187,7 @@ class Menu
$thumbTop = round(($visibleItems - 1) / count($this->items) * $scrollTop);
$thumbBottom = round(($visibleItems) / count($this->items) * $scrollBottom);
$tleft = round(($width / 2) - ((mb_strlen($this->title) + 2) / 2));
$tleft = (int)round(($width / 2) - ((mb_strlen($this->title) + 2) / 2));
// draw head
echo "\e[40;37m";