Implement folding (use '+' key), clean up code

This commit is contained in:
2024-10-03 01:44:10 +02:00
parent 989cc89e4b
commit 1cccfc0187
4 changed files with 90 additions and 26 deletions

View File

@ -35,7 +35,16 @@ class MessageBox
{
$wrapped = explode("\n", wordwrap($this->text, $width - 4, cut_long_words:true));
if ($height == 0) $height = count($wrapped) + 4;
[$w,$h] = $this->terminal->getSize();
if ($height == 0) {
$height = min($h - 5, count($wrapped) + 4);
}
if ($left == 0) {
$left = round(($w - $width) / 2);
}
if ($top == 0) {
$top = round(($h - $height) / 2);
}
$maxScroll = (count($wrapped) > $height) ? count($wrapped) - $height + 4 : 0;