} } } $this->checkCursorBounds(); ncurses_refresh(); } } function quitCommand($shell, $args) { exit; } function echoCommand($shell, $args) { $shell->addOutput($args); } function capsCommand($shell, $args) { $shell->addOutput(strtoupper($args)); } $shell = new Shell(' > '); $shell->registerCommand('quit', quitCommand); $shell->registerCommand('echo', echoCommand); $shell->registerCommand('caps', capsCommand); $shell->addOutput('Available command: echo, caps, quit'); $shell->addOutput('Move your cursor using arrows'); $shell->addOutput('Try it out by typing:'); $shell->addOutput('echo Hello world'); $shell->addOutput(''); while (true) { $shell->handleKey(); }