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:
17
console.php
17
console.php
@@ -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
|
||||
// {{{
|
||||
|
||||
Reference in New Issue
Block a user