console : Add Ctr+D (logout) support

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4236 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-06-12 18:59:44 +00:00
parent 80abee3b12
commit 07e8b0f5c4

View File

@@ -116,7 +116,7 @@ class console
$char = $this->getKey ();
return $char;
}
// }}}
// }}}
/** Wait one key pressed by the user. If the key pressed is an ESC sequence,
* return this sequence
@@ -290,6 +290,15 @@ class console
$this->moveCursor ($cursorPos);
}
// }}}
elseif (ord ($char) === 4)
// {{{
{
// Logout (Ctrl+D)
$string = "exit";
$this->rewriteLine ($prompt.$string);
return $string;
}
// }}}
elseif (ord($char) === 21)
// Empty line from prompt to cursor (Ctrl+U)
// {{{
@@ -451,6 +460,12 @@ class console
}
// }}}
}
elseif (in_array (ord ($char), $this->nonWriteableChar))
// Non writeable char : skip it
// {{{
{
}
// }}}
else
// Normal char : Add it to the string
// {{{