Completion for arguments
Hi,
Here is a patch that makes it possible to complete arguments. If no one objects, I will apply it on Sunday.
Thanks,
Marco
2005-08-27 Marco Gerards <[email protected]>
* include/grub/normal.h (enum grub_completion_type): Added `GRUB_COMPLETION_TYPE_ARGUMENT'.
* normal/cmdline.c (print_completion): Handle the `GRUB_COMPLETION_TYPE_ARGUMENT' type.
* normal/menu_entry.c (store_completion): Likewise.
* normal/completion.c (complete_arguments): New function. (grub_normal_do_completion): Call `complete_arguments' when the current words start with a dash.
Index: include/grub/normal.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/normal.h,v retrieving revision 1.21
grub/normal.h +1 -0
@@ -51,6 +51,7 @@ enum grub_completion_typeGRUB_COMPLETION_TYPE_DEVICE ,GRUB_COMPLETION_TYPE_PARTITION ,GRUB_COMPLETION_TYPE_FILE , + GRUB_COMPLETION_TYPE_ARGUMENT };typedef enum grub_completion_type grub_completion_type_t ;
Index: normal/cmdline.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/cmdline.c,v
retrieving revision 1.18
cmdline.c +3 -0
@@ -187,6 +187,9 @@ print_completion (const char *item, grubcase GRUB_COMPLETION_TYPE_PARTITION : what ="partitions" ;break ; +case GRUB_COMPLETION_TYPE_ARGUMENT : + what ="arguments" ; +break ;default : what ="things" ;break ;
Index: normal/completion.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/completion.c,v retrieving revision 1.2
completion.c +61 -1
74 lines not on this page · raw message
Index: normal/menu_entry.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/menu_entry.c,v retrieving revision 1.3
menu_entry.c +3 -0
@@ -840,6 +840,9 @@ store_completion (const char *item, grubcase GRUB_COMPLETION_TYPE_PARTITION : what ="partitions" ;break ; +case GRUB_COMPLETION_TYPE_ARGUMENT : + what ="arguments" ; +break ;default : what ="things" ;break ;
completion.c complete_file (void) · line 326
Quoted 5 lines · Marco Gerards
completion.c +5
-0+/* Add the short arguments. */ +for (option = cmd->options; option->doc; option++) + { +if (!option->shortarg) +continue ;
This should be:
if (! grub_isgraph (option->shortarg))
continue;
because we sometimes want to specify non-graph short arguments for convenience.
Okuji
Quoted 9 lines · Yoshinori K. Okuji
completion.c complete_file (void) · line 326
Quoted 5 lines · Marco Gerards
completion.c +5
-0+/* Add the short arguments. */ +for (option = cmd->options; option->doc; option++) + { +if (!option->shortarg) +continue ;This should be:
Quoted 5 lines
if (!
grub_isgraph(option->shortarg))continue;because we sometimes want to specify non-graph short arguments for convenience.
You are right, I will fix this next time when I commit a patch.
Thanks,
Marco