From 9d1cde418a4f0dc6cccf4af7eae340e75de2f3d4 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 23 May 2009 19:33:36 -0700 Subject: [PATCH] Don't set the autocr flag on the serial console; clean up crap libutil would set the autocr flag on the serial console, which really never was any point -- we already do \n -> \r\n conversion explicitly in the serial code. This was always very annoying to deal with if the menu was interrupted. Furthermore, drop completely unnecessary initialization/deinitialization routines that completely duplicated other code. Signed-off-by: H. Peter Anvin --- NEWS | 1 + com32/libutil/ansiline.c | 12 +++--------- com32/libutil/ansiraw.c | 12 +++--------- com32/menu/menu.c | 11 ----------- com32/menu/menumain.c | 5 ----- com32/menu/vesamenu.c | 11 ----------- 6 files changed, 7 insertions(+), 45 deletions(-) diff --git a/NEWS b/NEWS index 7acd25b..8c940b1 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ Changes in 3.81: has changed, so the isohybrid utility must version-match isolinux.bin. * Drop support for ACPI 3 extended memory flags. + * Menu system: don't set the autocr flag on the serial console. Changes in 3.80: * New shuffler mechanism and API. diff --git a/com32/libutil/ansiline.c b/com32/libutil/ansiline.c index 4cdac02..fffb2ba 100644 --- a/com32/libutil/ansiline.c +++ b/com32/libutil/ansiline.c @@ -38,16 +38,9 @@ #include #include -static void __attribute__((destructor)) console_cleanup(void) -{ - /* For the serial console, be nice and clean up */ - fputs("\033[0m\033[20l", stdout); -} - void console_ansi_std(void) { openconsole(&dev_stdcon_r, &dev_ansiserial_w); - fputs("\033[0m\033[20h", stdout); } #else @@ -64,7 +57,6 @@ static void __attribute__((constructor)) console_init(void) static void __attribute__((destructor)) console_cleanup(void) { - fputs("\033[0m\033[20l", stdout); tcsetattr(0, TCSANOW, &original_termios_settings); } @@ -83,8 +75,10 @@ void console_ansi_std(void) tio.c_iflag &= ~ICRNL; tio.c_iflag |= IGNCR; tio.c_lflag |= ICANON|ECHO; + if (!tio.c_oflag & OPOST) + tio.c_oflag = 0; + tio.c_oflag |= OPOST|ONLCR; tcsetattr(0, TCSANOW, &tio); - fputs("\033[0m\033[20h", stdout); } #endif diff --git a/com32/libutil/ansiraw.c b/com32/libutil/ansiraw.c index c192744..c55a82e 100644 --- a/com32/libutil/ansiraw.c +++ b/com32/libutil/ansiraw.c @@ -38,16 +38,9 @@ #include #include -static void __attribute__((destructor)) console_cleanup(void) -{ - /* For the serial console, be nice and clean up */ - fputs("\033[0m\033[20l", stdout); -} - void console_ansi_raw(void) { openconsole(&dev_rawcon_r, &dev_ansiserial_w); - fputs("\033[0m\033[20h", stdout); } #else @@ -64,7 +57,6 @@ static void __attribute__((constructor)) console_init(void) static void __attribute__((destructor)) console_cleanup(void) { - fputs("\033[0m\033[20l", stdout); tcsetattr(0, TCSANOW, &original_termios_settings); } @@ -83,10 +75,12 @@ void console_ansi_raw(void) tio.c_iflag &= ~ICRNL; tio.c_iflag |= IGNCR; tio.c_lflag &= ~(ISIG|ICANON|ECHO); + if (!tio.c_oflag & OPOST) + tio.c_oflag = 0; + tio.c_oflag |= OPOST|ONLCR; tio.c_cc[VMIN] = 0; tio.c_cc[VTIME] = 1; /* Don't 100% busy-wait in Linux */ tcsetattr(0, TCSAFLUSH, &tio); - fputs("\033[0m\033[20h", stdout); } #endif diff --git a/com32/menu/menu.c b/com32/menu/menu.c index 9a6ad89..6d64bad 100644 --- a/com32/menu/menu.c +++ b/com32/menu/menu.c @@ -20,16 +20,6 @@ #include #include "menu.h" -void console_prepare(void) -{ - /* Nothing special to do */ -} - -void console_cleanup(void) -{ - /* Nothing special to do */ -} - int draw_background(const char *arg) { /* Nothing to do... */ @@ -40,6 +30,5 @@ int draw_background(const char *arg) int main(int argc, char *argv[]) { console_ansi_raw(); - return menu_main(argc, argv); } diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c index b3131fa..81780ea 100644 --- a/com32/menu/menumain.c +++ b/com32/menu/menumain.c @@ -1052,8 +1052,6 @@ int menu_main(int argc, char *argv[]) (void)argc; - console_prepare(); - if (getscreensize(1, &rows, &cols)) { /* Unknown screen size? */ rows = 24; @@ -1084,7 +1082,6 @@ 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, KT_NONE); @@ -1093,7 +1090,5 @@ int menu_main(int argc, char *argv[]) } else { return 0; /* Exit */ } - - console_prepare(); /* If we're looping... */ } } diff --git a/com32/menu/vesamenu.c b/com32/menu/vesamenu.c index 094b8f6..4dd4586 100644 --- a/com32/menu/vesamenu.c +++ b/com32/menu/vesamenu.c @@ -25,17 +25,6 @@ #include "menu.h" -void console_prepare(void) -{ - fputs("\033[0m\033[25l", stdout); -} - -void console_cleanup(void) -{ - /* For the serial console, be nice and clean up */ - fputs("\033[0m", stdout); -} - int draw_background(const char *what) { if (!what) -- 2.7.4