WHAT_KEY has better equivalents in other tools.
[apps/madmutt.git] / lib-ui / curs_lib.c
index 8e74153..5ac5dcb 100644 (file)
@@ -26,6 +26,7 @@
 #include "mutt.h"
 #include "pager.h"
 #include "charset.h"
+#include "madtty.h"
 
 /* not possible to unget more than one char under some curses libs, and it
  * is impossible to unget function keys in SLang, so roll our own input
@@ -199,6 +200,7 @@ int mutt_yesorno (const char *msg, int def)
     waddstr (stdscr, (char *) (def == M_YES ? yes : no));
     mutt_refresh ();
   }
+  CLEARLINE(stdscr, LINES - 1);
   return (def);
 }
 
@@ -211,7 +213,7 @@ void mutt_query_exit (void)
     wtimeout (stdscr, -1);               /* restore blocking operation */
   if (mutt_yesorno (_("Exit Madmutt?"), M_YES) == M_YES) {
     mutt_endwin (NULL);
-    exit (1);
+    mutt_exit(1);
   }
   mutt_clear_error ();
   mutt_curs_set (-1);
@@ -308,39 +310,18 @@ void mutt_show_error (void)
 
 void curses_initialize(void)
 {
+    initscr();
+    if (start_color() == ERR || !has_colors() || COLORS < 8)
+        mutt_exit(-1);
+    madtty_init_colors();
     ci_start_color();
-    keypad(stdscr, true);
-    cbreak();
     noecho();
-    typeahead (-1);               /* simulate smooth scrolling */
+    raw();
+    keypad(stdscr, true);
+    typeahead(-1);
     meta(stdscr, true);
-}
-
-void _mutt_perror (const char *s, const char* filename, int line)
-{
-  char *p = strerror (errno);
-  mutt_error ("%s: %s (errno = %d) from %s:%i", s, p ? p : _("unknown error"), errno, filename, line);
-}
-
-/*
- * prompts the user to enter a keystroke, and displays the octal value back
- * to the user.
- */
-void mutt_what_key (void)
-{
-  int ch;
-
-  mvwprintw(stdscr, LINES - 1, 0, _("Enter keys (^G to abort): "));
-  do {
-    ch = getch();
-    if (ch != ERR && ch != ctrl ('G')) {
-      mutt_message (_("Char = %s, Octal = %o, Decimal = %d"),
-                    km_keyname (ch), ch, ch);
-    }
-  }
-  while (ch != ERR && ch != ctrl ('G'));
-
-  mutt_flushinp ();
+    curs_set(0);
+    ESCDELAY = 50;
 }
 
 int mutt_any_key_to_continue (const char *s)