Bugfixed history logic, example tweaks

This commit is contained in:
2024-03-02 02:17:32 +01:00
parent fdbcc7adae
commit 266c538f01
2 changed files with 14 additions and 7 deletions

View File

@ -6,16 +6,22 @@ require_once __DIR__."/../vendor/autoload.php";
$shell = new NoccyLabs\React\Shell\Shell();
// The prompt event is invoked before every full redraw. Call redrawPrompt()
// to trigger it manually. Set the prompt or the style here.
$shell->on('prompt', function ($shell) {
$shell->setPrompt(date("H:i:s> "));
});
// Input handler, parse the commands.
$shell->on('input', function (array $input) use ($shell) {
$shell->write("You entered: ".join(" ", $input)."\n");
});
// The shell is an OutputStream
// The shell is an OutputStream, and writing to it will handle hiding the prompt
// and redrawing it afterwards!
$shell->write("Hello World!\n\n");
// So output can be writen while you are typing!
Loop::addPeriodicTimer(5, function () use ($shell) {
$shell->write(date(DATE_ATOM)."\n");
});