@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | $previousItem = $this->getSelectedItem(); |
| 169 | 169 | $this->moveSelection($input); |
| 170 | 170 | $newItem = $this->getSelectedItem(); |
| 171 | - if ($previousItem !== $newItem) { |
|
| 172 | - $this->draw($previousItem, $newItem); |
|
| 173 | - } |
|
| 171 | + if ($previousItem !== $newItem) { |
|
| 172 | + $this->draw($previousItem, $newItem); |
|
| 173 | + } |
|
| 174 | 174 | break; |
| 175 | 175 | case 'enter': |
| 176 | 176 | $this->executeCurrentItem(); |
@@ -253,30 +253,30 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | $frame->addRows($this->drawMenuItem(new LineBreakItem())); |
| 255 | 255 | |
| 256 | - $frame->newLine(2); |
|
| 256 | + $frame->newLine(2); |
|
| 257 | 257 | |
| 258 | - if ($previousItem && $newItem) { |
|
| 258 | + if ($previousItem && $newItem) { |
|
| 259 | 259 | |
| 260 | - $rows = $frame->getRows(); |
|
| 260 | + $rows = $frame->getRows(); |
|
| 261 | 261 | |
| 262 | - $this->terminal->moveCursorToTop(); |
|
| 263 | - $this->terminal->moveCursorDown($previousItem->getStartRowNumber()); |
|
| 264 | - echo rtrim($rows[$previousItem->getStartRowNumber()], "\n\r"); |
|
| 262 | + $this->terminal->moveCursorToTop(); |
|
| 263 | + $this->terminal->moveCursorDown($previousItem->getStartRowNumber()); |
|
| 264 | + echo rtrim($rows[$previousItem->getStartRowNumber()], "\n\r"); |
|
| 265 | 265 | |
| 266 | - $this->terminal->moveCursorToTop(); |
|
| 267 | - $this->terminal->moveCursorDown($newItem->getStartRowNumber()); |
|
| 268 | - echo rtrim($rows[$newItem->getStartRowNumber()], "\n\r"); |
|
| 266 | + $this->terminal->moveCursorToTop(); |
|
| 267 | + $this->terminal->moveCursorDown($newItem->getStartRowNumber()); |
|
| 268 | + echo rtrim($rows[$newItem->getStartRowNumber()], "\n\r"); |
|
| 269 | 269 | |
| 270 | - } else { |
|
| 270 | + } else { |
|
| 271 | 271 | |
| 272 | - $this->terminal->clean(); |
|
| 273 | - $this->terminal->moveCursorToTop(); |
|
| 272 | + $this->terminal->clean(); |
|
| 273 | + $this->terminal->moveCursorToTop(); |
|
| 274 | 274 | |
| 275 | - foreach ($frame->getRows() as $row) { |
|
| 276 | - echo $row; |
|
| 277 | - } |
|
| 275 | + foreach ($frame->getRows() as $row) { |
|
| 276 | + echo $row; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | 281 | $this->currentFrame = $frame; |
| 282 | 282 | } |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | ); |
| 310 | 310 | }, $rows); |
| 311 | 311 | |
| 312 | - $item->setNumberOfRows( count( $rows ) ); |
|
| 312 | + $item->setNumberOfRows( count( $rows ) ); |
|
| 313 | 313 | |
| 314 | - return array( $rows, $item ); |
|
| 314 | + return array( $rows, $item ); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -23,9 +23,9 @@ |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function addRows(array $params = []) : void |
| 26 | - { |
|
| 27 | - list($rows, $item) = $params; |
|
| 28 | - $item->setStartRowNumber(count($this->rows)); |
|
| 26 | + { |
|
| 27 | + list($rows, $item) = $params; |
|
| 28 | + $item->setStartRowNumber(count($this->rows)); |
|
| 29 | 29 | foreach ($rows as $row) { |
| 30 | 30 | $this->rows[] = $row; |
| 31 | 31 | } |
@@ -16,52 +16,52 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | private $text; |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var int |
|
| 21 | - */ |
|
| 22 | - private $numberOfRows = 0; |
|
| 19 | + /** |
|
| 20 | + * @var int |
|
| 21 | + */ |
|
| 22 | + private $numberOfRows = 0; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var int |
|
| 26 | - */ |
|
| 27 | - private $startRowNumber = 0; |
|
| 24 | + /** |
|
| 25 | + * @var int |
|
| 26 | + */ |
|
| 27 | + private $startRowNumber = 0; |
|
| 28 | 28 | |
| 29 | 29 | public function __construct(string $text) |
| 30 | 30 | { |
| 31 | 31 | $this->text = $text; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Returns the number of terminal rows the item takes |
|
| 36 | - */ |
|
| 37 | - public function getNumberOfRows() { |
|
| 38 | - return $this->numberOfRows; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Sets the row number the item starts at in the frame |
|
| 43 | - */ |
|
| 44 | - public function setStartRowNumber(int $rowNumber) { |
|
| 45 | - $this->startRowNumber = $rowNumber; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Returns the row number the item starts at in the frame |
|
| 50 | - */ |
|
| 51 | - public function getStartRowNumber() { |
|
| 52 | - return $this->startRowNumber; |
|
| 53 | - } |
|
| 34 | + /** |
|
| 35 | + * Returns the number of terminal rows the item takes |
|
| 36 | + */ |
|
| 37 | + public function getNumberOfRows() { |
|
| 38 | + return $this->numberOfRows; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Sets the row number the item starts at in the frame |
|
| 43 | + */ |
|
| 44 | + public function setStartRowNumber(int $rowNumber) { |
|
| 45 | + $this->startRowNumber = $rowNumber; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Returns the row number the item starts at in the frame |
|
| 50 | + */ |
|
| 51 | + public function getStartRowNumber() { |
|
| 52 | + return $this->startRowNumber; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * The output text for the item |
| 57 | 57 | */ |
| 58 | 58 | public function getRows(MenuStyle $style, bool $selected = false) : array |
| 59 | 59 | { |
| 60 | - $rows = explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth())); |
|
| 60 | + $rows = explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth())); |
|
| 61 | 61 | |
| 62 | - $this->numberOfRows = count($rows); |
|
| 62 | + $this->numberOfRows = count($rows); |
|
| 63 | 63 | |
| 64 | - return $rows; |
|
| 64 | + return $rows; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -23,38 +23,38 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @var bool |
| 25 | 25 | */ |
| 26 | - private $disabled = false; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 31 | - private $numberOfRows = 0; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var int |
|
| 35 | - */ |
|
| 36 | - private $startRowNumber = 0; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Returns the number of terminal rows the item takes |
|
| 40 | - */ |
|
| 41 | - public function getNumberOfRows() { |
|
| 42 | - return $this->numberOfRows; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Sets the row number the item starts at in the frame |
|
| 47 | - */ |
|
| 48 | - public function setStartRowNumber(int $rowNumber) { |
|
| 49 | - $this->startRowNumber = $rowNumber; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Returns the row number the item starts at in the frame |
|
| 54 | - */ |
|
| 55 | - public function getStartRowNumber() { |
|
| 56 | - return $this->startRowNumber; |
|
| 57 | - } |
|
| 26 | + private $disabled = false; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | + private $numberOfRows = 0; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var int |
|
| 35 | + */ |
|
| 36 | + private $startRowNumber = 0; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Returns the number of terminal rows the item takes |
|
| 40 | + */ |
|
| 41 | + public function getNumberOfRows() { |
|
| 42 | + return $this->numberOfRows; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Sets the row number the item starts at in the frame |
|
| 47 | + */ |
|
| 48 | + public function setStartRowNumber(int $rowNumber) { |
|
| 49 | + $this->startRowNumber = $rowNumber; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Returns the row number the item starts at in the frame |
|
| 54 | + */ |
|
| 55 | + public function getStartRowNumber() { |
|
| 56 | + return $this->startRowNumber; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * The output text for the item |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | $length, |
| 75 | 75 | sprintf("\n%s", str_repeat(' ', mb_strlen($marker))) |
| 76 | 76 | ) |
| 77 | - ); |
|
| 77 | + ); |
|
| 78 | 78 | |
| 79 | - $this->numberOfRows = count($rows); |
|
| 79 | + $this->numberOfRows = count($rows); |
|
| 80 | 80 | |
| 81 | 81 | return array_map(function ($row, $key) use ($style, $length) { |
| 82 | 82 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
@@ -9,20 +9,20 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | interface MenuItemInterface |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Returns the number of terminal rows the item takes |
|
| 14 | - */ |
|
| 15 | - public function getNumberOfRows() : int; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * Sets the row number the item starts at in the frame |
|
| 19 | - */ |
|
| 20 | - public function setStartRowNumber(int $rowNumber) : void; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Returns the row number the item starts at in the frame |
|
| 24 | - */ |
|
| 25 | - public function getStartRowNumber() : int; |
|
| 12 | + /** |
|
| 13 | + * Returns the number of terminal rows the item takes |
|
| 14 | + */ |
|
| 15 | + public function getNumberOfRows() : int; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * Sets the row number the item starts at in the frame |
|
| 19 | + */ |
|
| 20 | + public function setStartRowNumber(int $rowNumber) : void; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Returns the row number the item starts at in the frame |
|
| 24 | + */ |
|
| 25 | + public function getStartRowNumber() : int; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * The output text for the item |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | private $lines; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var int |
|
| 25 | - */ |
|
| 26 | - private $numberOfRows = 0; |
|
| 23 | + /** |
|
| 24 | + * @var int |
|
| 25 | + */ |
|
| 26 | + private $numberOfRows = 0; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 31 | - private $startRowNumber = 0; |
|
| 28 | + /** |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | + private $startRowNumber = 0; |
|
| 32 | 32 | |
| 33 | 33 | public function __construct(string $breakChar = ' ', int $lines = 1) |
| 34 | 34 | { |
@@ -36,26 +36,26 @@ discard block |
||
| 36 | 36 | $this->lines = $lines; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Returns the number of terminal rows the item takes |
|
| 41 | - */ |
|
| 42 | - public function getNumberOfRows() { |
|
| 43 | - return $this->numberOfRows; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Sets the row number the item starts at in the frame |
|
| 48 | - */ |
|
| 49 | - public function setStartRowNumber(int $rowNumber) { |
|
| 50 | - $this->startRowNumber = $rowNumber; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Returns the row number the item starts at in the frame |
|
| 55 | - */ |
|
| 56 | - public function getStartRowNumber() { |
|
| 57 | - return $this->startRowNumber; |
|
| 58 | - } |
|
| 39 | + /** |
|
| 40 | + * Returns the number of terminal rows the item takes |
|
| 41 | + */ |
|
| 42 | + public function getNumberOfRows() { |
|
| 43 | + return $this->numberOfRows; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Sets the row number the item starts at in the frame |
|
| 48 | + */ |
|
| 49 | + public function setStartRowNumber(int $rowNumber) { |
|
| 50 | + $this->startRowNumber = $rowNumber; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Returns the row number the item starts at in the frame |
|
| 55 | + */ |
|
| 56 | + public function getStartRowNumber() { |
|
| 57 | + return $this->startRowNumber; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * The output text for the item |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | ), $this->lines)) |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | - $this->numberOfRows = count($rows); |
|
| 73 | + $this->numberOfRows = count($rows); |
|
| 74 | 74 | |
| 75 | - return $rows; |
|
| 75 | + return $rows; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | private $artLength; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var int |
|
| 37 | - */ |
|
| 38 | - private $numberOfRows = 0; |
|
| 35 | + /** |
|
| 36 | + * @var int |
|
| 37 | + */ |
|
| 38 | + private $numberOfRows = 0; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var int |
|
| 42 | - */ |
|
| 43 | - private $startRowNumber = 0; |
|
| 40 | + /** |
|
| 41 | + * @var int |
|
| 42 | + */ |
|
| 43 | + private $startRowNumber = 0; |
|
| 44 | 44 | |
| 45 | 45 | public function __construct(string $text, string $position = self::POSITION_CENTER) |
| 46 | 46 | { |
@@ -51,26 +51,26 @@ discard block |
||
| 51 | 51 | $this->artLength = max(array_map('mb_strlen', explode("\n", $text))); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Returns the number of terminal rows the item takes |
|
| 56 | - */ |
|
| 57 | - public function getNumberOfRows() { |
|
| 58 | - return $this->numberOfRows; |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * Returns the number of terminal rows the item takes |
|
| 56 | + */ |
|
| 57 | + public function getNumberOfRows() { |
|
| 58 | + return $this->numberOfRows; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Sets the row number the item starts at in the frame |
|
| 63 | - */ |
|
| 64 | - public function setStartRowNumber(int $rowNumber) { |
|
| 65 | - $this->startRowNumber = $rowNumber; |
|
| 66 | - } |
|
| 61 | + /** |
|
| 62 | + * Sets the row number the item starts at in the frame |
|
| 63 | + */ |
|
| 64 | + public function setStartRowNumber(int $rowNumber) { |
|
| 65 | + $this->startRowNumber = $rowNumber; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Returns the row number the item starts at in the frame |
|
| 70 | - */ |
|
| 71 | - public function getStartRowNumber() { |
|
| 72 | - return $this->startRowNumber; |
|
| 73 | - } |
|
| 68 | + /** |
|
| 69 | + * Returns the row number the item starts at in the frame |
|
| 70 | + */ |
|
| 71 | + public function getStartRowNumber() { |
|
| 72 | + return $this->startRowNumber; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * The output text for the item |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return $row; |
| 105 | - }, explode("\n", $this->text)); |
|
| 105 | + }, explode("\n", $this->text)); |
|
| 106 | 106 | |
| 107 | - $this->numberOfRows = count($rows); |
|
| 107 | + $this->numberOfRows = count($rows); |
|
| 108 | 108 | |
| 109 | - return $rows; |
|
| 109 | + return $rows; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |