summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-09-02 17:07:35 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-09-02 17:07:35 +0000
commit955744e5d0b0e2541a2cba4e272edc4ddf60bc09 (patch)
treebd43e61f3ba7312e865fcfe2a377a5baa1a5deab /src
parent053b2e233e45dc21ac86a5418e663af08e1f426b (diff)
prompt: correctly handle backspace when empty
Diffstat (limited to 'src')
-rw-r--r--src/main.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.cc b/src/main.cc
index b4169139..32870b52 100644
--- a/src/main.cc
+++ b/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();