console : when moving to an old history, keep the position of the cursor if the user come back on the tmp stored entry

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4273 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-07-08 08:59:12 +00:00
parent e4ec389955
commit f76b7dd76b

View File

@@ -491,6 +491,7 @@ class console
if ($string !== "" && $historyTmp == "") if ($string !== "" && $historyTmp == "")
{ {
$historyTmp = $string; $historyTmp = $string;
$historyTmpPos = $cursorPos;
} }
if ($historyPos > 0) if ($historyPos > 0)
{ {
@@ -511,12 +512,14 @@ class console
{ {
$historyPos++; $historyPos++;
$string = $this->history[$historyPos]; $string = $this->history[$historyPos];
$cursorPos = mb_strlen ($prompt.$string) + 1;
} }
elseif ($historyTmp !== "") elseif ($historyTmp !== "")
{ {
$string = $historyTmp; $string = $historyTmp;
$cursorPos = $historyTmpPos;
$historyTmp = "";
} }
$cursorPos = mb_strlen ($prompt.$string) + 1;
$this->rewriteLine ($prompt.$string); $this->rewriteLine ($prompt.$string);
$this->moveCursor ($cursorPos); $this->moveCursor ($cursorPos);
} }