On Tue, Jan 15, 2008 at 01:25:25PM +0100, Marco Gerards wrote:
> Robert Millan <[EMAIL PROTECTED]> writes:
> 
> > On Mon, Jan 14, 2008 at 09:32:39PM +0100, Yoshinori K. Okuji wrote:
> >> On Monday 14 January 2008 15:10, Robert Millan wrote:
> >> > As subject says.  Based on suggestions from Vesa.
> >> 
> >> Why do you want to use a nested function?
> >
> > No special reason;  just to restrict the namespace use to the scope where
> > it'll be needed, and avoid passing of parameters (offset, timeout).
> >
> > I'm fine with moving it out if that's preferred.
> 
> If it doesn't uglify your code, that's usually a better thing to do.

Ok, here's a new patch.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
	* normal/menu.c (run_menu): Move timeout message from here ...
	(print_timeout): ... to here.
	(run_menu): Use print_timeout() once during initial draw to print
	the whole message, and again in every clock tick to update only
	the number of seconds.

diff -x '*~' -x configure -x config.h.in -ur grub2/normal/menu.c flickery/normal/menu.c
--- grub2/normal/menu.c	2008-01-05 13:10:28.000000000 +0100
+++ flickery/normal/menu.c	2008-01-15 13:37:54.000000000 +0100
@@ -308,12 +308,27 @@
   return entry;
 }
 
+void
+print_timeout (int timeout, int offset, int second_stage)
+{
+  /* NOTE: Do not remove the trailing space characters.
+     They are required to clear the line.  */
+  char *msg = "   The highlighted entry will be booted automatically in %ds.    ";
+  char *msg_end = grub_strchr (msg, '%');
+  
+  grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
+  grub_printf (second_stage ? msg_end : msg, timeout);
+  grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
+  grub_refresh ();
+};
+
 static int
 run_menu (grub_menu_t menu, int nested)
 {
   int first, offset;
   unsigned long saved_time;
   int default_entry;
+  int timeout;
   
   first = 0;
   
@@ -340,11 +355,14 @@
   print_entries (menu, first, offset);
   grub_refresh ();
 
+  timeout = get_timeout ();
+
+  if (timeout > 0)
+    print_timeout (timeout, offset, 0);
+
   while (1)
     {
       int c;
-      int timeout;
-
       timeout = get_timeout ();
       
       if (timeout > 0)
@@ -357,16 +375,8 @@
 	      timeout--;
 	      set_timeout (timeout);
 	      saved_time = current_time;
+	      print_timeout (timeout, offset, 1);
 	    }
-	  
-	  grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
-	  /* NOTE: Do not remove the trailing space characters.
-	     They are required to clear the line.  */
-	  grub_printf ("\
-   The highlighted entry will be booted automatically in %d s.    ",
-		       timeout);
-	  grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
-	  grub_refresh ();
 	}
 
       if (timeout == 0)
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to