console : manage correctely the bad provided values
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4264 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
17
console.php
17
console.php
@@ -292,7 +292,7 @@ class console
|
||||
$completeArr = call_user_func ($this->completionFunction, $string);
|
||||
$isAssoc = is_array ($completeArr) &&
|
||||
array_diff_key ($completeArr, array_keys (array_keys ($completeArr)));
|
||||
if (count ($completeArr) === 1)
|
||||
if (is_array ($completeArr) && count ($completeArr) === 1)
|
||||
{
|
||||
if (substr ($string, -1) !== " ")
|
||||
{
|
||||
@@ -314,7 +314,7 @@ class console
|
||||
else
|
||||
$string .= reset ($completeArr);
|
||||
}
|
||||
else
|
||||
elseif (is_array ($completeArr) && count ($completeArr))
|
||||
{
|
||||
// Multiple answers : display them
|
||||
// Manage if all the answers start by the same chars : add them to the
|
||||
@@ -358,9 +358,12 @@ class console
|
||||
echo "\n".implode ("\n", $completeArr)."\n";
|
||||
}
|
||||
}
|
||||
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
||||
$this->rewriteLine ($prompt.$string);
|
||||
$this->moveCursor ($cursorPos);
|
||||
if (is_array ($completeArr) && count ($completeArr))
|
||||
{
|
||||
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
||||
$this->rewriteLine ($prompt.$string);
|
||||
$this->moveCursor ($cursorPos);
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
elseif (ord ($char) === 3)
|
||||
@@ -377,7 +380,7 @@ class console
|
||||
// Logout (Ctrl+D)
|
||||
// {{{
|
||||
{
|
||||
$string = "exit";
|
||||
$string = "exit\n";
|
||||
$this->rewriteLine ($prompt.$string);
|
||||
return $string;
|
||||
}
|
||||
@@ -841,6 +844,8 @@ class console
|
||||
private function shortestIdenticalValues ($completeArr)
|
||||
// {{{
|
||||
{
|
||||
if (! is_array ($completeArr))
|
||||
return "";
|
||||
$minlen = 99999;
|
||||
foreach ($completeArr as $val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user