summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manager.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/manager.cpp b/manager.cpp
index 0bdd0a4..f2f9ab2 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -204,6 +204,16 @@ int Manager::io(){
redraw();
int key=tgetkey();
+ if(key<0){
+ cerr<<"Input read error: key="<<key<<endl;
+ key=tgetkey();
+ if(key<0){
+ cerr<<"Input double read error: key="<<key<<endl;
+ break;
+ } else {
+ receive({"error","Standard input is unreliable!"});
+ }
+ }
Either<bool,Command> ret=global_keyinput.input(key);
if(ret.isLeft()){
@@ -250,6 +260,11 @@ Maybe<string> Manager::promptString(const string &promptString){
redraw();
int key=tgetkey();
+ if(key<0){
+ cerr<<"Input read error in promptString: key="<<key<<endl;
+ fillrect(0,termsize.h-1,termsize.w,1,' ');
+ return {};
+ }
Either<bool,Command> ret=global_keyinput.input(key);
if(ret.isLeft()){
@@ -286,6 +301,11 @@ char Manager::promptChar(const string &promptString,const string &options,char d
while(true){
int key=tgetkey();
+ if(key<0){
+ cerr<<"Input read error in promptChar: key="<<key<<endl;
+ fillrect(0,termsize.h-1,termsize.w,1,' ');
+ return def;
+ }
if(key==KEY_ESC)return def;
if(key<=0||key>=127){
bel();