prompt: correctly handle backspace when empty

This commit is contained in:
Maxime Coste 2011-09-02 17:07:35 +00:00
parent 053b2e233e
commit 955744e5d0

View File

@ -165,11 +165,14 @@ std::string prompt(const std::string& text)
case '\r': case '\r':
return result; return result;
case 7: case 7:
move(max_y - 1, text.length() + result.length() - 1); if (not result.empty())
addch(' '); {
result.resize(result.length() - 1); move(max_y - 1, text.length() + result.length() - 1);
move(max_y - 1, text.length() + result.length()); addch(' ');
refresh; result.resize(result.length() - 1);
move(max_y - 1, text.length() + result.length());
refresh();
}
break; break;
case 27: case 27:
throw prompt_aborted(); throw prompt_aborted();