Code

configure.ac: add more optimization flags
[ncmpc.git] / src / screen_utils.c
index 1203a938c8c4ca657c1f31b2a78bb7b316e470ce..8889ac13277b8b8cb0b2edf53609847bc469ae80 100644 (file)
@@ -27,6 +27,7 @@
 #include "wreadln.h"
 
 #include <mpd/client.h>
+#include <ctype.h>
 
 void
 screen_bell(void)
@@ -66,6 +67,21 @@ screen_getch(const char *prompt)
        return key;
 }
 
+bool
+screen_get_yesno(const char *prompt, bool def)
+{
+       /* NOTE: if one day a translator decides to use a multi-byte character
+          for one of the yes/no keys, we'll have to parse it properly */
+
+       int key = tolower(screen_getch(prompt));
+       if (key == YES[0])
+               return true;
+       else if (key == NO[0])
+               return false;
+       else
+               return def;
+}
+
 char *
 screen_readln(const char *prompt,
              const char *value,