/**
* Draw the menu to STDOUT
*/
protected function draw()
{
$this->terminal->clean();
$this->terminal->moveCursorToTop();
$frame = new Frame();
$frame->newLine(2);
if (is_string($this->title)) {
$frame->addRows($this->drawMenuItem(new LineBreakItem()));
$frame->addRows($this->drawMenuItem(new StaticItem($this->title)));
$frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator())));
}
array_map(function ($item, $index) use($frame) {
$frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem));
}, $this->items, array_keys($this->items));
$frame->addRows($this->drawMenuItem(new LineBreakItem()));
$frame->newLine(2);
foreach ($frame->getRows() as $row) {
echo $row;
}
$this->currentFrame = $frame;
}