Merge mainline into multiterm
This commit is contained in:
commit
519634516f
239 changed files with 3529 additions and 1873 deletions
|
@ -1,7 +1,7 @@
|
|||
/* help.c - command to show a help text. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,6 +21,10 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/charset.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
||||
|
@ -37,26 +41,51 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
|
||||
(cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
|
||||
{
|
||||
struct grub_term_output *cur;
|
||||
int desclen = grub_strlen (cmd->summary);
|
||||
FOR_ACTIVE_TERM_OUTPUTS(cur)
|
||||
{
|
||||
int width = grub_term_width(cur);
|
||||
char description[width / 2];
|
||||
struct grub_term_output *term;
|
||||
const char *summary_translated = _(cmd->summary);
|
||||
char *command_help;
|
||||
grub_uint32_t *unicode_command_help;
|
||||
grub_uint32_t *unicode_last_position;
|
||||
|
||||
/* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
|
||||
with the description followed by spaces. */
|
||||
grub_memset (description, ' ', width / 2 - 1);
|
||||
description[width / 2 - 1] = '\0';
|
||||
grub_memcpy (description, cmd->summary,
|
||||
(desclen < width / 2 - 1
|
||||
? desclen : width / 2 - 1));
|
||||
grub_puts_terminal (description, cur);
|
||||
command_help = grub_malloc (grub_strlen (cmd->name) +
|
||||
sizeof (" ") - 1 +
|
||||
grub_strlen (summary_translated));
|
||||
|
||||
grub_sprintf(command_help, "%s %s", cmd->name, summary_translated);
|
||||
|
||||
grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
|
||||
&unicode_last_position);
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
{
|
||||
unsigned stringwidth;
|
||||
grub_uint32_t *unicode_last_screen_position;
|
||||
|
||||
unicode_last_screen_position = unicode_command_help;
|
||||
|
||||
stringwidth = 0;
|
||||
|
||||
while (unicode_last_screen_position < unicode_last_position &&
|
||||
stringwidth < ((grub_term_width (term) / 2) - 2))
|
||||
{
|
||||
stringwidth
|
||||
+= grub_term_getcharwidth (term,
|
||||
*unicode_last_screen_position);
|
||||
unicode_last_screen_position++;
|
||||
}
|
||||
|
||||
grub_print_ucs4 (unicode_command_help,
|
||||
unicode_last_screen_position, term);
|
||||
if (!(cnt % 2))
|
||||
grub_print_spaces (term, grub_term_width (term) / 2
|
||||
- stringwidth);
|
||||
}
|
||||
if ((cnt++) % 2)
|
||||
if (cnt % 2)
|
||||
grub_printf ("\n");
|
||||
else
|
||||
grub_printf (" ");
|
||||
cnt++;
|
||||
|
||||
grub_free (command_help);
|
||||
grub_free (unicode_command_help);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,8 +102,8 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
|
|||
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
|
||||
grub_arg_show_help ((grub_extcmd_t) cmd->data);
|
||||
else
|
||||
grub_printf ("Usage: %s\n%s\b", cmd->summary,
|
||||
cmd->description);
|
||||
grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary),
|
||||
_(cmd->description));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -106,8 +135,8 @@ GRUB_MOD_INIT(help)
|
|||
{
|
||||
cmd = grub_register_extcmd ("help", grub_cmd_help,
|
||||
GRUB_COMMAND_FLAG_CMDLINE,
|
||||
"help [PATTERN ...]",
|
||||
"Show a help message.", 0);
|
||||
N_("[PATTERN ...]"),
|
||||
N_("Show a help message."), 0);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(help)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue