merge from trunk
This commit is contained in:
commit
e8b2988803
108 changed files with 3024 additions and 5764 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <grub/reader.h>
|
||||
#include <grub/menu_viewer.h>
|
||||
#include <grub/auth.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#define GRUB_DEFAULT_HISTORY_SIZE 50
|
||||
|
||||
|
@ -414,7 +415,7 @@ grub_normal_execute (const char *config, int nested, int batch)
|
|||
read_command_list ();
|
||||
read_fs_list ();
|
||||
read_handler_list ();
|
||||
grub_command_execute ("parser.sh", 0, 0);
|
||||
grub_command_execute ("parser.grub", 0, 0);
|
||||
|
||||
reader_nested = nested;
|
||||
|
||||
|
@ -508,10 +509,10 @@ grub_normal_reader_init (void)
|
|||
grub_normal_init_page ();
|
||||
grub_setcursor (1);
|
||||
|
||||
grub_printf ("\
|
||||
grub_printf_ (N_("\
|
||||
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\
|
||||
lists possible command completions. Anywhere else TAB lists possible\n\
|
||||
device/file completions.%s ]\n\n",
|
||||
device/file completions.%s ]\n\n"),
|
||||
reader_nested ? " ESC at any time exits." : "");
|
||||
|
||||
return 0;
|
||||
|
@ -523,9 +524,9 @@ static grub_err_t
|
|||
grub_normal_read_line (char **line, int cont)
|
||||
{
|
||||
grub_parser_t parser = grub_parser_get_current ();
|
||||
char prompt[8 + grub_strlen (parser->name)];
|
||||
char prompt[sizeof("> ") + grub_strlen (parser->name)];
|
||||
|
||||
grub_sprintf (prompt, "%s:%s> ", parser->name, (cont) ? "" : "grub");
|
||||
grub_sprintf (prompt, "%s> ", parser->name);
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/auth.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
enum update_mode
|
||||
{
|
||||
|
@ -835,7 +836,9 @@ store_completion (const char *item, grub_completion_type_t type, int count)
|
|||
}
|
||||
|
||||
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf (" Possible %s are:\n ", what);
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Possible %s are:"), what);
|
||||
grub_printf ("\n ");
|
||||
}
|
||||
|
||||
/* Make sure that the completion buffer has enough room. */
|
||||
|
@ -996,7 +999,9 @@ run (struct screen *screen)
|
|||
}
|
||||
|
||||
grub_cls ();
|
||||
grub_printf (" Booting a command list\n\n");
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Booting a command list"));
|
||||
grub_printf ("\n\n");
|
||||
|
||||
|
||||
/* Execute the script, line for line. */
|
||||
|
@ -1176,6 +1181,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
|
|||
grub_cls ();
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
grub_putchar ('\n');
|
||||
grub_printf_ (N_("Press any key to continue..."));
|
||||
(void) grub_getkey ();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/menu_viewer.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
/* Time to delay after displaying an error message about a default/fallback
|
||||
entry failing to boot. */
|
||||
|
@ -38,11 +39,105 @@ static grub_uint8_t grub_color_menu_highlight;
|
|||
void
|
||||
grub_wait_after_message (void)
|
||||
{
|
||||
grub_printf ("\nPress any key to continue...");
|
||||
grub_putchar ('\n');
|
||||
grub_printf_ (N_("Press any key to continue..."));
|
||||
(void) grub_getkey ();
|
||||
grub_putchar ('\n');
|
||||
}
|
||||
|
||||
static void
|
||||
print_spaces (int number_spaces)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < number_spaces; i++)
|
||||
grub_putchar (' ');
|
||||
}
|
||||
|
||||
static void
|
||||
grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position)
|
||||
{
|
||||
while (str < last_position)
|
||||
{
|
||||
grub_putcode (*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
getstringwidth (grub_uint32_t * str, const grub_uint32_t * last_position)
|
||||
{
|
||||
grub_ssize_t width = 0;
|
||||
|
||||
while (str < last_position)
|
||||
{
|
||||
width += grub_getcharwidth (*str);
|
||||
str++;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
static void
|
||||
print_message_indented (const char *msg)
|
||||
{
|
||||
const int line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') * 15;
|
||||
|
||||
grub_uint32_t *unicode_msg;
|
||||
|
||||
grub_ssize_t msg_len = grub_strlen (msg);
|
||||
|
||||
unicode_msg = grub_malloc (msg_len * sizeof (*unicode_msg));
|
||||
|
||||
msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len,
|
||||
(grub_uint8_t *) msg, -1, 0);
|
||||
|
||||
if (!unicode_msg)
|
||||
{
|
||||
grub_printf ("print_message_indented ERROR1: %s", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg_len < 0)
|
||||
{
|
||||
grub_printf ("print_message_indented ERROR2: %s", msg);
|
||||
grub_free (unicode_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const grub_uint32_t *last_position = unicode_msg + msg_len;
|
||||
|
||||
grub_uint32_t *current_position = unicode_msg;
|
||||
|
||||
grub_uint32_t *next_new_line = unicode_msg;
|
||||
|
||||
while (current_position < last_position)
|
||||
{
|
||||
next_new_line = (grub_uint32_t *) last_position;
|
||||
|
||||
while (getstringwidth (current_position, next_new_line) > line_len
|
||||
|| (*next_new_line != ' ' && next_new_line > current_position &&
|
||||
next_new_line != last_position))
|
||||
{
|
||||
next_new_line--;
|
||||
}
|
||||
|
||||
if (next_new_line == current_position)
|
||||
{
|
||||
next_new_line = (next_new_line + line_len > last_position) ?
|
||||
(grub_uint32_t *) last_position : next_new_line + line_len;
|
||||
}
|
||||
|
||||
print_spaces (6);
|
||||
grub_print_ucs4 (current_position, next_new_line);
|
||||
grub_putchar ('\n');
|
||||
|
||||
next_new_line++;
|
||||
current_position = next_new_line;
|
||||
}
|
||||
grub_free (unicode_msg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw_border (void)
|
||||
{
|
||||
|
@ -86,22 +181,33 @@ print_message (int nested, int edit)
|
|||
|
||||
if (edit)
|
||||
{
|
||||
grub_printf ("\n\
|
||||
Minimum Emacs-like screen editing is supported. TAB lists\n\
|
||||
completions. Press Ctrl-x to boot, Ctrl-c for a command-line\n\
|
||||
or ESC to return menu.");
|
||||
grub_putchar ('\n');
|
||||
print_message_indented (_("Minimum Emacs-like screen editing is \
|
||||
supported. TAB lists completions. Press Ctrl-x to boot, Ctrl-c for a \
|
||||
command-line or ESC to return menu."));
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf ("\n\
|
||||
Use the %C and %C keys to select which entry is highlighted.\n",
|
||||
(grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
|
||||
grub_printf ("\
|
||||
Press enter to boot the selected OS, \'e\' to edit the\n\
|
||||
commands before booting or \'c\' for a command-line.");
|
||||
const char *msg = _("Use the %C and %C keys to select which \
|
||||
entry is highlighted.");
|
||||
char *msg_translated =
|
||||
grub_malloc (sizeof (char) * grub_strlen (msg) + 1);
|
||||
|
||||
grub_sprintf (msg_translated, msg, (grub_uint32_t) GRUB_TERM_DISP_UP,
|
||||
(grub_uint32_t) GRUB_TERM_DISP_DOWN);
|
||||
grub_putchar ('\n');
|
||||
print_message_indented (msg_translated);
|
||||
|
||||
grub_free (msg_translated);
|
||||
|
||||
print_message_indented (_("Press enter to boot the selected OS, \
|
||||
\'e\' to edit the commands before booting or \'c\' for a command-line."));
|
||||
|
||||
if (nested)
|
||||
grub_printf ("\n\
|
||||
ESC to return previous menu.");
|
||||
{
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("ESC to return previous menu."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,13 +392,17 @@ get_entry_number (grub_menu_t menu, const char *name)
|
|||
static void
|
||||
print_timeout (int timeout, int offset, int second_stage)
|
||||
{
|
||||
/* NOTE: Do not remove the trailing space characters.
|
||||
They are required to clear the line. */
|
||||
char *msg = " The highlighted entry will be booted automatically in %ds. ";
|
||||
const char *msg =
|
||||
_("The highlighted entry will be booted automatically in %ds.");
|
||||
const int msg_localized_len = grub_strlen (msg);
|
||||
const int number_spaces = GRUB_TERM_WIDTH - msg_localized_len - 3;
|
||||
|
||||
char *msg_end = grub_strchr (msg, '%');
|
||||
|
||||
grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_gotoxy (second_stage ? (msg_end - msg + 3) : 3, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf (second_stage ? msg_end : msg, timeout);
|
||||
print_spaces (second_stage ? number_spaces : 0);
|
||||
|
||||
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
||||
grub_refresh ();
|
||||
};
|
||||
|
@ -381,8 +491,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||
if (timeout >= 0)
|
||||
{
|
||||
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
||||
grub_printf ("\
|
||||
");
|
||||
print_spaces (GRUB_TERM_WIDTH - 1);
|
||||
|
||||
grub_env_unset ("timeout");
|
||||
grub_env_unset ("fallback");
|
||||
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
||||
|
@ -538,7 +648,9 @@ static void
|
|||
notify_booting (grub_menu_entry_t entry,
|
||||
void *userdata __attribute__((unused)))
|
||||
{
|
||||
grub_printf (" Booting \'%s\'\n\n", entry->title);
|
||||
grub_printf (" ");
|
||||
grub_printf_ (N_("Booting \'%s\'"), entry->title);
|
||||
grub_printf ("\n\n");
|
||||
}
|
||||
|
||||
/* Callback invoked when a default menu entry executed because of a timeout
|
||||
|
@ -548,7 +660,9 @@ static void
|
|||
notify_fallback (grub_menu_entry_t entry,
|
||||
void *userdata __attribute__((unused)))
|
||||
{
|
||||
grub_printf ("\n Falling back to \'%s\'\n\n", entry->title);
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("Falling back to \'%s\'"), entry->title);
|
||||
grub_printf ("\n\n");
|
||||
grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS);
|
||||
}
|
||||
|
||||
|
@ -562,7 +676,8 @@ notify_execution_failure (void *userdata __attribute__((unused)))
|
|||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
grub_printf ("\n Failed to boot default entries.\n");
|
||||
grub_printf ("\n ");
|
||||
grub_printf_ (N_("Failed to boot default entries.\n"));
|
||||
grub_wait_after_message ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue