From 6fb2acab15d7fd84a287cc50ef472d34018636bd Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 11 Aug 2007 16:25:49 +0200 Subject: [PATCH] Move more things about stdscr in lib-ui. Signed-off-by: Pierre Habouzit --- keymap.c | 21 --------------------- keymap.h | 1 - lib-ui/curs_lib.c | 39 +++++++++++++++++++++++++++++++++++++++ lib-ui/curses.h | 5 ++++- main.c | 18 +++++------------- 5 files changed, 48 insertions(+), 36 deletions(-) diff --git a/keymap.c b/keymap.c index 5e32da0..4349989 100644 --- a/keymap.c +++ b/keymap.c @@ -848,24 +848,3 @@ int mutt_parse_exec (BUFFER * buf, BUFFER * s, unsigned long data __attribute__ return 0; } - -/* - * 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 (); -} diff --git a/keymap.h b/keymap.h index 5e2bb87..1c26ed1 100644 --- a/keymap.h +++ b/keymap.h @@ -41,7 +41,6 @@ int km_expand_key (char *, size_t, struct keymap_t *); struct keymap_t *km_find_func (int, int); void km_init (void); void km_error_key (int); -void mutt_what_key (void); enum { MENU_ALIAS, diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 53609b5..3c0f440 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -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; diff --git a/lib-ui/curses.h b/lib-ui/curses.h index f438395..fc9e19f 100644 --- a/lib-ui/curses.h +++ b/lib-ui/curses.h @@ -50,6 +50,9 @@ void mutt_curs_set (int); event_t mutt_getch (void); +void curses_initialize(void); +void curses_install(void); + void mutt_endwin (const char *); void mutt_flushinp (void); void mutt_refresh (void); @@ -127,6 +130,7 @@ ssize_t mutt_pretty_size(char *s, ssize_t len, ssize_t n); int mutt_addwch (wchar_t); int mutt_alloc_color (int fg, int bg); int mutt_any_key_to_continue (const char *); +void mutt_what_key (void); int mutt_complete (char *, ssize_t); #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL) int _mutt_enter_fname (const char *, char *, ssize_t, int *, int, int, @@ -155,7 +159,6 @@ extern COLOR_LINE *ColorHdrList; extern COLOR_LINE *ColorBodyList; extern COLOR_LINE *ColorIndexList; -void ci_init_color (void); void ci_start_color (void); #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0) diff --git a/main.c b/main.c index 3d8f6ef..75ab623 100644 --- a/main.c +++ b/main.c @@ -225,12 +225,7 @@ static void start_curses (void) exit (1); } mutt_signal_initialize (); - ci_start_color (); - keypad (stdscr, TRUE); - cbreak (); - noecho (); - typeahead (-1); /* simulate smooth scrolling */ - meta (stdscr, TRUE); + curses_initialize(); } #define M_IGNORE (1<<0) /* -z */ @@ -425,7 +420,7 @@ int main (int argc, char **argv) /* This must come before mutt_init() because curses needs to be started before calling the init_pair() function to set the color scheme. */ if (!option (OPTNOCURSES)) - start_curses (); + start_curses(); /* set defaults and read init files */ mutt_init (flags & M_NOSYSRC, commands); @@ -457,15 +452,12 @@ int main (int argc, char **argv) if (newMagic) mx_set_magic (newMagic); - if (!option (OPTNOCURSES)) { - SETCOLOR (MT_COLOR_NORMAL); - wclear (stdscr); - mutt_error = mutt_curses_error; - mutt_message = mutt_curses_message; + if (!option(OPTNOCURSES)) { + curses_install(); } /* Create the Maildir directory if it doesn't exist. */ - if (!option (OPTNOCURSES) && Maildir) { + if (!option(OPTNOCURSES) && Maildir) { struct stat sb; char fpath[_POSIX_PATH_MAX]; char mesg[STRING]; -- 2.20.1