]> git.proxmox.com Git - grub2.git/blobdiff - grub-core/commands/sleep.c
Lift 255x255 erminal sie restriction to 65535x65535. Also change from
[grub2.git] / grub-core / commands / sleep.c
index ead279506ed82b12a54008e8555944525d9a9884..e77e7900facd33316a386a268f39f0affbd1ee47 100644 (file)
 #include <grub/extcmd.h>
 #include <grub/i18n.h>
 
+GRUB_MOD_LICENSE ("GPLv3+");
+
 static const struct grub_arg_option options[] =
   {
     {"verbose", 'v', 0, N_("Verbose countdown."), 0, 0},
-    {"interruptible", 'i', 0, N_("Interruptible with ESC."), 0, 0},
+    {"interruptible", 'i', 0, N_("Allow to interrupt with ESC."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
-static grub_uint16_t *pos;
+static struct grub_term_coordinate *pos;
 
 static void
 do_print (int n)
@@ -41,6 +43,7 @@ do_print (int n)
   /* NOTE: Do not remove the trailing space characters.
      They are required to clear the line.  */
   grub_printf ("%d    ", n);
+  grub_refresh ();
 }
 
 /* Based on grub_millisleep() from kern/generic/millisleep.c.  */
@@ -52,21 +55,20 @@ grub_interruptible_millisleep (grub_uint32_t ms)
   start = grub_get_time_ms ();
 
   while (grub_get_time_ms () - start < ms)
-    if (grub_checkkey () >= 0 &&
-       GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC)
+    if (grub_getkey_noblock () == GRUB_TERM_ESC)
       return 1;
 
   return 0;
 }
 
 static grub_err_t
-grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args)
+grub_cmd_sleep (grub_extcmd_context_t ctxt, int argc, char **args)
 {
-  struct grub_arg_list *state = cmd->state;
+  struct grub_arg_list *state = ctxt->state;
   int n;
 
   if (argc != 1)
-    return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand");
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
 
   n = grub_strtoul (args[0], 0, 10);
 
@@ -76,6 +78,8 @@ grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args)
       return 0;
     }
 
+  grub_refresh ();
+
   pos = grub_term_save_pos ();
 
   for (; n; n--)
@@ -101,7 +105,7 @@ static grub_extcmd_t cmd;
 \f
 GRUB_MOD_INIT(sleep)
 {
-  cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, GRUB_COMMAND_FLAG_BOTH,
+  cmd = grub_register_extcmd ("sleep", grub_cmd_sleep, 0,
                              N_("NUMBER_OF_SECONDS"),
                              N_("Wait for a specified number of seconds."),
                              options);