console : without suggestion, $start was incorrect (missing ending space)
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5571 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
12
console.php
12
console.php
@@ -297,6 +297,7 @@ class console
|
|||||||
// Manage autocompletion
|
// Manage autocompletion
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
|
$this->debug ("Autocompletion starting");
|
||||||
// Take the last part of the string without space or double quotes
|
// Take the last part of the string without space or double quotes
|
||||||
$pos = strrpos ($string, " ");
|
$pos = strrpos ($string, " ");
|
||||||
if ($pos === false)
|
if ($pos === false)
|
||||||
@@ -315,9 +316,11 @@ class console
|
|||||||
{
|
{
|
||||||
// Last char is not a space, end is the last word and start is the
|
// Last char is not a space, end is the last word and start is the
|
||||||
// begin to before last word
|
// begin to before last word
|
||||||
$start = mb_substr ($string, 0, $pos);
|
$start = mb_substr ($string, 0, $pos + 1);
|
||||||
$end = mb_substr ($string, $pos + 1);
|
$end = mb_substr ($string, $pos + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$this->debug ("Autocompletion : start='$start', end='$end'");
|
||||||
$completeArr = call_user_func ($this->completionFunction,
|
$completeArr = call_user_func ($this->completionFunction,
|
||||||
self::tokenize ($start));
|
self::tokenize ($start));
|
||||||
$isAssoc = is_array ($completeArr) &&
|
$isAssoc = is_array ($completeArr) &&
|
||||||
@@ -334,6 +337,7 @@ class console
|
|||||||
if (count ($completeArr) === 1)
|
if (count ($completeArr) === 1)
|
||||||
{
|
{
|
||||||
// One entry : add a space to put on the next
|
// One entry : add a space to put on the next
|
||||||
|
$this->debug ("Autocompletion : One entry : add ending space");
|
||||||
if ($start !== "")
|
if ($start !== "")
|
||||||
$start .= " ";
|
$start .= " ";
|
||||||
if ($isAssoc)
|
if ($isAssoc)
|
||||||
@@ -344,6 +348,7 @@ class console
|
|||||||
elseif (count ($completeArr))
|
elseif (count ($completeArr))
|
||||||
{
|
{
|
||||||
// Multiple entries : display them to allow the user to choose
|
// Multiple entries : display them to allow the user to choose
|
||||||
|
$this->debug ("Autocompletion : Multiple entries : display choices");
|
||||||
echo "\n";
|
echo "\n";
|
||||||
// In associative array, the key is the possible answer to
|
// In associative array, the key is the possible answer to
|
||||||
// autocompletion, and the value is the helper message
|
// autocompletion, and the value is the helper message
|
||||||
@@ -382,14 +387,17 @@ class console
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->debug ("Autocompletion : Zero entry : do not change");
|
||||||
$string = $start.$end;
|
$string = $start.$end;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (is_array ($completeArr) && count ($completeArr))
|
if (is_array ($completeArr) && count ($completeArr))
|
||||||
{
|
{
|
||||||
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
$cursorPos = mb_strlen ($prompt.$string) + 1;
|
||||||
$this->rewriteLine ($prompt.$string);
|
$this->rewriteLine ($prompt.$string);
|
||||||
$this->moveCursor ($cursorPos);
|
$this->moveCursor ($cursorPos);
|
||||||
}
|
}*/
|
||||||
|
$this->debug ("Autocompletion : end '$prompt.$string'");
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
elseif (ord ($char) === 3)
|
elseif (ord ($char) === 3)
|
||||||
|
|||||||
Reference in New Issue
Block a user