src/Handlers/SelectHandler.php
public function handle(): array
    {
        $this->firstRun = true;
        $this->output->writeln(
            '<info>' . $this->question->getMessage() . '</info> [<comment>SPACE=select</>, <comment>ENTER=submit</>]'
        );
        $this->repaint();

        $sttyMode = shell_exec('stty -g');

        // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
        shell_exec('stty -icanon -echo');

        // Read a keypress
        while (!feof($this->stream)) {
            $char = fread($this->stream, 1);
            if (" " === $char) {
                $this->tryCellSelection();
            } elseif ("\033" === $char) {
                $this->tryCellNavigation($char);
            } elseif (10 === ord($char)) {
                //TODO handle valid state...
                $this->clear();
                $this->output->write('> ' . join(', ', $this->question->getSelections()));
                $this->output->write($char);
                break;
            }
            $this->repaint();
        }

        // Reset stty so it behaves normally again
        shell_exec(sprintf('stty %s', $sttyMode));

        $this->output->writeln(' ');

        return $this->question->getSelections();
    }
public function handle(): array
    {
        $this->firstRun = true;
        $this->output->writeln(
            '<info>' . $this->question->getMessage() . '</info> [<comment>SPACE=select</>, <comment>ENTER=submit</>]'
        );
        $this->repaint();

        $sttyMode = shell_exec('stty -g');

        // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
        shell_exec('stty -icanon -echo');

        // Read a keypress
        while (!feof($this->stream)) {
            $char = fread($this->stream, 1);
            if (" " === $char) {
                $this->tryCellSelection();
            } elseif ("\033" === $char) {
                $this->tryCellNavigation($char);
            } elseif (10 === ord($char)) {
                //TODO handle valid state...
                $this->clear();
                $this->output->write('> ' . join(', ', $this->question->getSelections()));
                $this->output->write($char);
                break;
            }
            $this->repaint();
        }

        // Reset stty so it behaves normally again
        shell_exec(sprintf('stty %s', $sttyMode));

        $this->output->writeln(' ');

        return $this->question->getSelections();
    }
public function handle ( ) : array { $ this -> firstRun = true ; $ this -> output -> writeln ( '<info>' . $ this -> question -> getMessage ( ) . '</info> [<comment>SPACE=select</>, <comment>ENTER=submit</>]' ) ; $ this -> repaint ( ) ; $ sttyMode = shell_exec ( 'stty -g' ) ; // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) shell_exec ( 'stty -icanon -echo' ) ; // Read a keypress while ( ! feof ( $ this -> stream ) ) { $ char = fread ( $ this -> stream , 1 ) ; if ( " " === $ char ) { $ this -> tryCellSelection ( ) ; } elseif ( "\033" === $ char ) { $ this -> tryCellNavigation ( $ char ) ; } elseif ( 10 === ord ( $ char ) ) { //TODO handle valid state... $ this -> clear ( ) ; $ this -> output -> write ( '> ' . join ( ', ' , $ this -> question -> getSelections ( ) ) ) ; $ this -> output -> write ( $ char ) ; break ; } $ this -> repaint ( ) ; } // Reset stty so it behaves normally again shell_exec ( sprintf ( 'stty %s' , $ sttyMode ) ) ; $ this -> output -> writeln ( ' ' ) ; return $ this -> question -> getSelections ( ) ; }
Navigates through option items.

@return array
Navigates through option items .