Skip to contentSkip to conversation

Completion for arguments

PATCH Marco Gerards 2 participants 3 messages Aug 26, 2005 – Aug 29, 2005

lore
Share & tools
lore
#0 lore raw

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
diff -u -p -u -p -r1.21 normal.h
@@ -51,6 +51,7 @@ enum grub_completion_type
     GRUB_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
diff -u -p -u -p -r1.18 cmdline.c
@@ -187,6 +187,9 @@ print_completion (const char *item, grub
 	case 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
diff -u -p -u -p -r1.3 menu_entry.c
@@ -840,6 +840,9 @@ store_completion (const char *item, grub
 	case GRUB_COMPLETION_TYPE_PARTITION:
 	  what = "partitions";
 	  break;
+	case GRUB_COMPLETION_TYPE_ARGUMENT:
+	  what = "arguments";
+	  break;
 	default:
 	  what = "things";
 	  break;
#1 lore raw

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

#2 lore raw
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