Fix scrolling in MessageBox, file overwrite confirmation

This commit is contained in:
2024-10-05 23:24:55 +02:00
parent 7a37ebe234
commit 29d070c305
2 changed files with 43 additions and 11 deletions
+32 -10
View File
@@ -20,7 +20,7 @@ class MessageBox
const U_EDGE_HORIZONTAL = "\u{2500}";
const U_EDGE_VERTICAL = "\u{2502}";
const U_EDGE_VERTICAL_SCROLL = "\u{2591}";
const U_EDGE_VERTICAL_SCROLL = "\u{2593}";
const U_EDGE_VERTICAL_THUMB = "\u{2593}";
const U_EDGE_VERTICAL_LEFT = "\u{2524}";
const U_EDGE_VERTICAL_RIGHT = "\u{251c}";
@@ -76,14 +76,36 @@ class MessageBox
$showing = false;
}
} else {
if ($ch == "k{UP}") {
$this->scroll--;
if ($this->scroll < 0) $this->scroll = 0;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
} elseif ($ch == "k{DOWN}") {
$this->scroll++;
if ($this->scroll > $maxScroll) $this->scroll = $maxScroll;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
switch ($ch) {
case "k{UP}":
$this->scroll--;
if ($this->scroll < 0) $this->scroll = 0;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
case "k{DOWN}":
$this->scroll++;
if ($this->scroll > $maxScroll) $this->scroll = $maxScroll;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
case "k{PGUP}":
$this->scroll -= $height - 2;
if ($this->scroll < 0) $this->scroll = 0;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
case "k{PGDN}":
$this->scroll += $height - 2;
if ($this->scroll >= $maxScroll) $this->scroll = $maxScroll;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
case "k{HOME}":
$this->scroll = 0;
if ($this->scroll >= count($wrapped)) $this->scroll = 0;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
case "k{END}":
$this->scroll = $maxScroll;
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
break;
}
}
}
@@ -154,7 +176,7 @@ class MessageBox
if ($n >= $thumbTop && $n <= $thumbBottom) {
$scrollbar = "\e[97;1m".self::U_EDGE_VERTICAL_THUMB."\e[40;37;22m";
} else {
$scrollbar = "\e[37;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
$scrollbar = "\e[30;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
}
$this->terminal
->writeAt($left, $top + 3 + $n, self::U_EDGE_VERTICAL.$item.$scrollbar);