From 591d2a1bcd68cef5a938df3d7ccf0f73571a42b2 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 1 Nov 2006 15:26:56 -0800 Subject: [PATCH] menu: handle console setup/cleanup differently --- com32/modules/menu.c | 10 ++++++++++ com32/modules/menu.h | 2 ++ com32/modules/menumain.c | 6 ++++++ com32/modules/vesamenu.c | 8 ++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/com32/modules/menu.c b/com32/modules/menu.c index b733864..1f2c510 100644 --- a/com32/modules/menu.c +++ b/com32/modules/menu.c @@ -20,6 +20,16 @@ #include #include "menu.h" +void console_prepare(void) +{ + /* Nothing special to do */ +} + +void console_cleanup(void) +{ + /* Nothing special to do */ +} + int main(int argc, char *argv[]) { console_ansi_raw(); diff --git a/com32/modules/menu.h b/com32/modules/menu.h index e856977..a70ba92 100644 --- a/com32/modules/menu.h +++ b/com32/modules/menu.h @@ -74,5 +74,7 @@ static inline int my_isspace(char c) } int menu_main(int argc, char *argv[]); +void console_prepare(void); +void console_cleanup(void); #endif /* MENU_H */ diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c index d0c0243..9d33bab 100644 --- a/com32/modules/menumain.c +++ b/com32/modules/menumain.c @@ -848,6 +848,8 @@ int menu_main(int argc, char *argv[]) (void)argc; + console_prepare(); + install_default_color_table(); if (getscreensize(1, &rows, &cols)) { /* Unknown screen size? */ @@ -876,6 +878,8 @@ int menu_main(int argc, char *argv[]) cmdline = run_menu(); printf("\033[?25h\033[%d;1H\033[0m", END_ROW); + console_cleanup(); + if ( cmdline ) { execute(cmdline); if ( onerror ) @@ -883,5 +887,7 @@ int menu_main(int argc, char *argv[]) } else { return 0; /* Exit */ } + + console_prepare(); /* If we're looping... */ } } diff --git a/com32/modules/vesamenu.c b/com32/modules/vesamenu.c index 88fe78d..6316eae 100644 --- a/com32/modules/vesamenu.c +++ b/com32/modules/vesamenu.c @@ -23,7 +23,12 @@ #include #include "menu.h" -static void __attribute__((destructor)) console_cleanup(void) +void console_prepare(void) +{ + fputs("\033[0m\033[20h\033[25l", stdout); +} + +void console_cleanup(void) { /* For the serial console, be nice and clean up */ fputs("\033[0m\033[20l", stdout); @@ -34,7 +39,6 @@ int vesacon_load_background(const char *); int main(int argc, char *argv[]) { openconsole(&dev_rawcon_r, &dev_vesaserial_w); - fputs("\033[0m\033[20h\033[25l", stdout); draw_background = vesacon_load_background; -- 2.7.4