help command fix (II)
PATCH 1/1 help command fix (II)
Hello,
Some days ago I sent:
http://lists.gnu.org/archive/html/grub-devel/2009-12/msg00433.html
As Vladimir commented on IRC: patch was not checking how long the strings appears on the screen (multiple-byte chars, etc.)
Find attached a new version, measuring the width of the strings. I have tested it adding some long summary in some commands and works fine (apparently at least).
Thank you,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
=== modified file 'ChangeLog'
ChangeLog +11 -0
@@ -1,3 +1,14 @@ +2010-01-01 Carles Pina i Estany <[email protected]> + + * commands/help.c: Include `grub/mm.h' and `grub/normal.h'. + (grub_cmd_help): Print the cmd->name before the cmd->summary. Cut the + string using string width. + * normal/menu_text.c (grub_print_message_indented): Use + grub_print_spaces and not print_spaces. + (print_timeout): Likewise. + (print_spaces): Move to... + * include/grub/term.h: ... here. Change the name to grub_print_spaces. + 2010-01-01 Robert Millan <[email protected]> Import from Gnulib.
=== modified file 'commands/help.c'
help.c +37 -12
62 lines not on this page · raw message
=== modified file 'include/grub/term.h'
grub/term.h +8 -0
@@ -299,6 +299,14 @@ int EXPORT_FUNC(grub_getcursor) (void);void EXPORT_FUNC (grub_refresh ) (void );void EXPORT_FUNC (grub_set_more ) (int onoff); +static inline void +grub_print_spaces (int number_spaces) +{ +while (--number_spaces >=0 ) +grub_putchar (' ' ); +} + +/* For convenience. */ #define GRUB_TERM_ASCII_CHAR (c) ((c) & 0xff)
=== modified file 'normal/menu_text.c'
menu_text.c +3 -11
@@ -45,14 +45,6 @@ grub_wait_after_message (void)grub_putchar ('\n' ); } -static void -print_spaces (int number_spaces) -{ -int i; -for (i =0 ; i < number_spaces; i++) -grub_putchar (' ' ); -} -void grub_print_ucs4 (const grub_uint32_t * str,const grub_uint32_t * last_position)
@@ -149,7 +141,7 @@ grub_print_message_indented (const char (grub_uint32_t *) last_position : next_new_line + line_len; } -print_spaces (margin_left); +grub_print_spaces (margin_left);grub_print_ucs4 (current_position, next_new_line); next_new_line++;
@@ -405,7 +397,7 @@ print_timeout (int timeout, int offset)int posx; posx =grub_getxy () >>8 ; -print_spaces (GRUB_TERM_WIDTH - posx -1 ); +grub_print_spaces (GRUB_TERM_WIDTH - posx -1 );grub_gotoxy (GRUB_TERM_CURSOR_X ,GRUB_TERM_FIRST_ENTRY_Y + offset);grub_refresh ();
@@ -495,7 +487,7 @@ run_menu (grub_menu_t menu, int nested,if (timeout >=0 ) {grub_gotoxy (0 ,GRUB_TERM_HEIGHT -3 ); -print_spaces (GRUB_TERM_WIDTH -1 ); +grub_print_spaces (GRUB_TERM_WIDTH -1 );grub_env_unset ("timeout" );grub_env_unset ("fallback" );
Hi,
Quoted 1 line · Carles Pina i Estany
Find attached a new version, measuring the width of the strings. I have
After some comments from Vladimir on IRC, committed.
Signature · 2 lines
Carles Pina i Estany http://pinux.info