Move more things about stdscr in lib-ui.
[apps/madmutt.git] / lib-ui / curs_lib.c
index 53609b5..3c0f440 100644 (file)
@@ -317,6 +317,24 @@ void mutt_show_error (void)
   SETCOLOR (MT_COLOR_NORMAL);
 }
 
+void curses_initialize(void)
+{
+    ci_start_color();
+    keypad(stdscr, TRUE);
+    cbreak();
+    noecho();
+    typeahead (-1);               /* simulate smooth scrolling */
+    meta(stdscr, TRUE);
+}
+
+void curses_install(void)
+{
+    SETCOLOR(MT_COLOR_NORMAL);
+    wclear(stdscr);
+    mutt_error   = mutt_curses_error;
+    mutt_message = mutt_curses_message;
+}
+
 void mutt_endwin (const char *msg)
 {
   if (!option (OPTNOCURSES)) {
@@ -339,6 +357,27 @@ void _mutt_perror (const char *s, const char* filename, int line)
   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 = wgetch (stdscr);
+    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 ();
+}
+
 int mutt_any_key_to_continue (const char *s)
 {
   struct termios t;