Bugfixed history logic, example tweaks
This commit is contained in:
		@@ -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");
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user