improve the dumb terminal support and fix some bugs related to the support.

This commit is contained in:
okuji 2000-09-05 08:44:31 +00:00
parent 9015cd0364
commit 36854134df
5 changed files with 118 additions and 26 deletions

View file

@ -1,3 +1,44 @@
2000-09-04 OKUJI Yoshinori <okuji@gnu.org>
* stage2/stage2.c (run_menu) [GRUB_UTIL]: Set DISP_UP and
DISP_DOWN to ACS_UARROW and ACS_DARROW, respectively. Don't call
grub_printf here.
(run_menu) [!GRUB_UTIL]: Don't call grub_printf here. Instead,
call it...
(run_menu): ... here.
* stage2/shared.h (ACS_ULCORNER): Always define this ourselves,
whether your curses library has the definition.
(ACS_URCORNER): Likewise.
(ACS_LLCORNER): Likewise.
(ACS_LRCORNER): Likewise.
(ACS_HLINE): Likewise.
(ACS_VLINE): Likewise.
(ACS_LARROW): Likewise.
(ACS_RARROW): Likewise.
(ACS_UARROW): Likewise.
(ACS_DARROW): Likewise.
* stage2/char_io.c [SUPPORT_SERIAL] (serial_cls): If the
terminal is dumb, just put a newline.
* stage2/builtins.c (terminal_func) [SUPPORT_SERIAL]: When
choosing a terminal, don't set TERMINAL to the type of the
terminal. Instead, apply a logical AND operation with
TERMINAL_DUMB, since previous code brushed off the dumb
attribute.
2000-09-04 OKUJI Yoshinori <okuji@gnu.org>
* stage2/stage2.c (run_menu): If SHOW_MENU is zero, print a
message with the timeout per second.
If GRUB_TIMEOUT is negative, set SHOW_MENU to one, since the
condition "no timeout and no interface" is nonsense.
If GRUB_TIMEOUT is equal to or greater than zero and the
terminal is dumb, set SHOW_MENU to zero.
If SHOW_MENU is non-zero and the terminal is dumb, enter the
command-line interface instead. If AUTH is false and PASSWORD is
non-NULL, prompt the user to enter a password until the entered
password is identical to PASSWORD.
2000-09-03 OKUJI Yoshinori <okuji@gnu.org>
* util/grub-install.in: Fix a typo: grub_dir -> grubdir.

View file

@ -3364,13 +3364,13 @@ terminal_func (char *arg, int flags)
{
if ((terminal & TERMINAL_CONSOLE) && console_checkkey () != -1)
{
terminal = TERMINAL_CONSOLE;
terminal &= (TERMINAL_CONSOLE | TERMINAL_DUMB);
(void) getkey ();
return 0;
}
else if ((terminal & TERMINAL_SERIAL) && serial_checkkey () != -1)
{
terminal = TERMINAL_SERIAL;
terminal &= (TERMINAL_SERIAL | TERMINAL_DUMB);
(void) getkey ();
/* If the interface is currently the command-line, restart
@ -3392,8 +3392,7 @@ terminal_func (char *arg, int flags)
}
/* Expired. */
terminal &= TERMINAL_DUMB;
terminal |= default_terminal;
terminal &= (default_terminal | TERMINAL_DUMB);
}
#endif /* SUPPORT_SERIAL */

View file

@ -1215,7 +1215,11 @@ cls (void)
void
serial_cls (void)
{
grub_printf ("\e[H\e[J");
/* If the terminal is dumb, there is no way to clean the terminal. */
if (terminal & TERMINAL_DUMB)
grub_putchar ('\n');
else
grub_printf ("\e[H\e[J");
}
#endif /* SUPPORT_SERIAL */
#endif /* ! STAGE1_5 */

View file

@ -298,19 +298,29 @@ extern char *grub_scratch_mem;
# endif /* ! A_STANDOUT */
#endif /* ! A_REVERSE */
/* Make sure that ACS_* are defined. */
#ifndef ACS_ULCORNER
# define ACS_ULCORNER '+'
# define ACS_URCORNER '+'
# define ACS_LLCORNER '+'
# define ACS_LRCORNER '+'
# define ACS_HLINE '-'
# define ACS_VLINE '|'
# define ACS_LARROW '<'
# define ACS_RARROW '>'
# define ACS_UARROW '^'
# define ACS_DARROW 'v'
#endif /* ! ACS_ULCORNER */
/* Define ACS_* ourselves, since the definitions are not consistent among
various curses implementations. */
#undef ACS_ULCORNER
#undef ACS_URCORNER
#undef ACS_LLCORNER
#undef ACS_LRCORNER
#undef ACS_HLINE
#undef ACS_VLINE
#undef ACS_LARROW
#undef ACS_RARROW
#undef ACS_UARROW
#undef ACS_DARROW
#define ACS_ULCORNER '+'
#define ACS_URCORNER '+'
#define ACS_LLCORNER '+'
#define ACS_LRCORNER '+'
#define ACS_HLINE '-'
#define ACS_VLINE '|'
#define ACS_LARROW '<'
#define ACS_RARROW '>'
#define ACS_UARROW '^'
#define ACS_DARROW 'v'
/* Special graphics characters for IBM displays. */
#ifdef GRUB_UTIL

View file

@ -239,7 +239,7 @@ run_menu (char *menu_entries, char *config_entries, int num_entries,
char *cur_entry = 0;
int disp_up = DISP_UP;
int disp_down = DISP_DOWN;
/*
* Main loop for menu UI.
*/
@ -251,12 +251,18 @@ restart:
entryno--;
}
/* If the timeout was expired or wasn't set, force to show the menu
interface. If the terminal is dumb and the timeout is set, hide
the menu to boot the default entry automatically when the timeout
is expired. */
if (grub_timeout < 0)
show_menu = 1;
else if (terminal & TERMINAL_DUMB)
show_menu = 0;
/* If SHOW_MENU is false, don't display the menu until ESC is pressed. */
if (! show_menu)
{
/* Print a message. */
grub_printf ("Press `ESC' to enter the menu...\n");
/* Get current time. */
while ((time1 = getrtsecs ()) == 0xFF)
;
@ -284,10 +290,40 @@ restart:
time2 = time1;
grub_timeout--;
/* Print a message. */
if (terminal & TERMINAL_DUMB)
grub_printf ("\rPress `ESC' to enter the command-line... %d ",
grub_timeout);
else
grub_printf ("\rPress `ESC' to enter the menu... %d ",
grub_timeout);
}
}
}
/* If the terminal is dumb, enter the command-line interface instead. */
if (show_menu && (terminal & TERMINAL_DUMB))
{
if (! auth && password)
{
/* The user must enter a correct password. */
char entered[32];
/* Make sure that PASSWORD is NUL-terminated. */
nul_terminate (password);
do
{
grub_memset (entered, 0, sizeof (entered));
get_cmdline ("Password: ", entered, 31, '*', 0);
}
while (grub_strcmp (password, entered) != 0);
}
enter_cmdline (heap, 1);
}
/* Only display the menu if the user wants to see it. */
if (show_menu)
{
@ -302,8 +338,9 @@ restart:
print_border (3, 12);
#ifdef GRUB_UTIL
grub_printf ("\n\
Use the up and down arrows to select which entry is highlighted.\n");
/* In the grub shell, always use ACS_*. */
disp_up = ACS_UARROW;
disp_down = ACS_DARROW;
#else /* ! GRUB_UTIL */
# ifdef SUPPORT_SERIAL
if (terminal & TERMINAL_CONSOLE)
@ -317,10 +354,11 @@ restart:
disp_down = ACS_DARROW;
}
# endif /* SUPPORT_SERIAL */
#endif /* ! GRUB_UTIL */
grub_printf ("\n\
Use the %c and %c keys to select which entry is highlighted.\n",
disp_up, disp_down);
#endif /* ! GRUB_UTIL */
if (! auth && password)
{