prompt: correctly handle backspace when empty
This commit is contained in:
parent
053b2e233e
commit
955744e5d0
13
src/main.cc
13
src/main.cc
|
@ -165,11 +165,14 @@ std::string prompt(const std::string& text)
|
|||
case '\r':
|
||||
return result;
|
||||
case 7:
|
||||
move(max_y - 1, text.length() + result.length() - 1);
|
||||
addch(' ');
|
||||
result.resize(result.length() - 1);
|
||||
move(max_y - 1, text.length() + result.length());
|
||||
refresh;
|
||||
if (not result.empty())
|
||||
{
|
||||
move(max_y - 1, text.length() + result.length() - 1);
|
||||
addch(' ');
|
||||
result.resize(result.length() - 1);
|
||||
move(max_y - 1, text.length() + result.length());
|
||||
refresh();
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
throw prompt_aborted();
|
||||
|
|
Loading…
Reference in New Issue
Block a user