Basic command handler, bugfixes
This commit is contained in:
@ -68,11 +68,16 @@ class Shell implements WritableStreamInterface, EventEmitterInterface
|
||||
exit(0);
|
||||
|
||||
case "\n":
|
||||
$buffer = str_getcsv($this->buffer, " ");
|
||||
$buffer = str_getcsv(trim($this->buffer), " ");
|
||||
$this->buffer = '';
|
||||
$this->cursorPos = 0;
|
||||
$this->scrollOffset = 0;
|
||||
$this->emit('input', [ $buffer ]);
|
||||
$this->ostream->write("\n");
|
||||
if ($buffer[0] !== NULL) {
|
||||
$this->emit('input', [ $buffer, $this ]);
|
||||
} else {
|
||||
$this->redrawPrompt();
|
||||
}
|
||||
break;
|
||||
|
||||
case "\x7F": // backspace
|
||||
@ -156,7 +161,7 @@ class Shell implements WritableStreamInterface, EventEmitterInterface
|
||||
|
||||
public function redrawPrompt(): void
|
||||
{
|
||||
$prompt = $this->emit("prompt");
|
||||
$this->emit("prompt", [ $this ]);
|
||||
|
||||
$this->termWidth = intval(exec("tput cols"));
|
||||
$this->isPrompting = true;
|
||||
|
Reference in New Issue
Block a user