From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JEl7w-0000zg-4T for mharc-grub-devel@gnu.org; Tue, 15 Jan 2008 07:42:48 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JEl7u-0000zP-J7 for grub-devel@gnu.org; Tue, 15 Jan 2008 07:42:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JEl7s-0000yt-JQ for grub-devel@gnu.org; Tue, 15 Jan 2008 07:42:45 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEl7s-0000yq-Eh for grub-devel@gnu.org; Tue, 15 Jan 2008 07:42:44 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JEl7r-00048o-Vs for grub-devel@gnu.org; Tue, 15 Jan 2008 07:42:44 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JEl7q-0004ti-NK for grub-devel@gnu.org; Tue, 15 Jan 2008 13:42:43 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JEl6R-00022P-9R for grub-devel@gnu.org; Tue, 15 Jan 2008 13:41:15 +0100 Date: Tue, 15 Jan 2008 13:41:15 +0100 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080115124115.GC924@thorin> References: <20080114141015.GA27293@thorin> <200801142132.39086.okuji@enbug.org> <20080114204751.GA6888@thorin> <87prw31dje.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: <87prw31dje.fsf@xs4all.nl> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] fix flickering timeout message for slow terminals (gfxterm) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2008 12:42:46 -0000 --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 15, 2008 at 01:25:25PM +0100, Marco Gerards wrote: > Robert Millan 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 I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --azLHFNyN32YCQGCU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="flickering_timeout.diff" * 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) --azLHFNyN32YCQGCU--