protected function draw() : void
    {
        $frame = new Frame;

        $frame->newLine(2);

        if ($this->style->getBorderTopWidth() > 0) {
            $frame->addRows($this->style->getBorderTopRows());
        }

        if ($this->style->getPaddingTopBottom() > 0) {
            $frame->addRows($this->style->getPaddingTopBottomRows());
        }

        if ($this->title) {
            $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));


        if ($this->style->getPaddingTopBottom() > 0) {
            $frame->addRows($this->style->getPaddingTopBottomRows());
        }

        if ($this->style->getBorderBottomWidth() > 0) {
            $frame->addRows($this->style->getBorderBottomRows());
        }

        $frame->newLine(2);

        $this->terminal->moveCursorToTop();
        foreach ($frame->getRows() as $row) {
            if ($row == "\n") {
                $this->terminal->clearLine();
            }
            $this->terminal->write($row);
        }
        $this->terminal->clearDown();

        $this->currentFrame = $frame;
    }
protected function draw() : void
    {
        $frame = new Frame;

        $frame->newLine(2);

        if ($this->style->getBorderTopWidth() > 0) {
            $frame->addRows($this->style->getBorderTopRows());
        }

        if ($this->style->getPaddingTopBottom() > 0) {
            $frame->addRows($this->style->getPaddingTopBottomRows());
        }

        if ($this->title) {
            $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));


        if ($this->style->getPaddingTopBottom() > 0) {
            $frame->addRows($this->style->getPaddingTopBottomRows());
        }

        if ($this->style->getBorderBottomWidth() > 0) {
            $frame->addRows($this->style->getBorderBottomRows());
        }

        $frame->newLine(2);

        $this->terminal->moveCursorToTop();
        foreach ($frame->getRows() as $row) {
            if ($row == "\n") {
                $this->terminal->clearLine();
            }
            $this->terminal->write($row);
        }
        $this->terminal->clearDown();

        $this->currentFrame = $frame;
    }
protected function draw ( ) : void { $ frame = new Frame ; $ frame -> newLine ( 2 ) ; if ( $ this -> style -> getBorderTopWidth ( ) > 0 ) { $ frame -> addRows ( $ this -> style -> getBorderTopRows ( ) ) ; } if ( $ this -> style -> getPaddingTopBottom ( ) > 0 ) { $ frame -> addRows ( $ this -> style -> getPaddingTopBottomRows ( ) ) ; } if ( $ this -> title ) { $ 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 ) ) ; if ( $ this -> style -> getPaddingTopBottom ( ) > 0 ) { $ frame -> addRows ( $ this -> style -> getPaddingTopBottomRows ( ) ) ; } if ( $ this -> style -> getBorderBottomWidth ( ) > 0 ) { $ frame -> addRows ( $ this -> style -> getBorderBottomRows ( ) ) ; } $ frame -> newLine ( 2 ) ; $ this -> terminal -> moveCursorToTop ( ) ; foreach ( $ frame -> getRows ( ) as $ row ) { if ( $ row == "\n" ) { $ this -> terminal -> clearLine ( ) ; } $ this -> terminal -> write ( $ row ) ; } $ this -> terminal -> clearDown ( ) ; $ this -> currentFrame = $ frame ; }
Draw the menu to STDOUT
Draw the menu to STDOUT