From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JEQ2w-0000iH-Nj for mharc-grub-devel@gnu.org; Mon, 14 Jan 2008 09:12:14 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JEQ2u-0000i9-G0 for grub-devel@gnu.org; Mon, 14 Jan 2008 09:12:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JEQ2t-0000hs-12 for grub-devel@gnu.org; Mon, 14 Jan 2008 09:12:12 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JEQ2s-0000hp-Ql for grub-devel@gnu.org; Mon, 14 Jan 2008 09:12:10 -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 1JEQ2s-0001xn-NW for grub-devel@gnu.org; Mon, 14 Jan 2008 09:12:10 -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 1JEQ2j-0002pO-81 for grub-devel@gnu.org; Mon, 14 Jan 2008 15:12:03 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JEQ11-00076e-53 for grub-devel@gnu.org; Mon, 14 Jan 2008 15:10:15 +0100 Date: Mon, 14 Jan 2008 15:10:15 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080114141015.GA27293@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline 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: [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: Mon, 14 Jan 2008 14:12:13 -0000 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline As subject says. Based on suggestions from Vesa. -- 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 /.) --dDRMvlgZJXvWKvBx Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="flickering_timeout.diff" * normal/menu.c (run_menu): Move timeout message to a separate (local) function, print_timeout(). 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 -urp grub2/normal/menu.c test/normal/menu.c --- grub2/normal/menu.c 2008-01-05 13:10:28.000000000 +0100 +++ test/normal/menu.c 2008-01-14 14:55:16.000000000 +0100 @@ -314,6 +314,20 @@ run_menu (grub_menu_t menu, int nested) int first, offset; unsigned long saved_time; int default_entry; + int timeout; + + auto void print_timeout (int); + void print_timeout (int second_stage) + { + char *prelude = " The highlighted entry will be booted automatically in"; + + grub_gotoxy (second_stage ? grub_strlen (prelude) : 0, GRUB_TERM_HEIGHT - 3); + /* NOTE: Do not remove the trailing space characters. + They are required to clear the line. */ + grub_printf ("%s %ds. ", second_stage ? "" : prelude, timeout); + grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset); + grub_refresh (); + }; first = 0; @@ -340,11 +354,14 @@ run_menu (grub_menu_t menu, int nested) print_entries (menu, first, offset); grub_refresh (); + timeout = get_timeout (); + + if (timeout > 0) + print_timeout (0); + while (1) { int c; - int timeout; - timeout = get_timeout (); if (timeout > 0) @@ -357,16 +374,8 @@ run_menu (grub_menu_t menu, int nested) timeout--; set_timeout (timeout); saved_time = current_time; + print_timeout (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) --dDRMvlgZJXvWKvBx--