From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Jo3Qj-0005fF-VY for mharc-grub-devel@gnu.org; Mon, 21 Apr 2008 17:20:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jo3Qj-0005fA-DO for grub-devel@gnu.org; Mon, 21 Apr 2008 17:20:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jo3Qd-0005eO-RJ for grub-devel@gnu.org; Mon, 21 Apr 2008 17:20:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jo3Qd-0005eL-KD for grub-devel@gnu.org; Mon, 21 Apr 2008 17:19:59 -0400 Received: from mailout06.t-online.de ([194.25.134.19]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jo3Qc-0004Pw-4a for grub-devel@gnu.org; Mon, 21 Apr 2008 17:19:59 -0400 Received: from fwd32.aul.t-online.de by mailout06.sul.t-online.de with smtp id 1Jo3QC-000192-02; Mon, 21 Apr 2008 23:19:32 +0200 Received: from [10.3.2.2] (rIAKlrZOwh4KyhvyN8GBjAxloe1G0cV1Fp2-P6MCqXC24uy-ST+afHPJ01alzKFwIE@[217.235.226.119]) by fwd32.aul.t-online.de with esmtp id 1Jo3Q9-1cMIfw0; Mon, 21 Apr 2008 23:19:29 +0200 Message-ID: <480D04E2.3050808@t-online.de> Date: Mon, 21 Apr 2008 23:19:30 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071128 SeaMonkey/1.1.7 MIME-Version: 1.0 To: grub-devel@gnu.org Content-Type: multipart/mixed; boundary="------------010901040007070508050108" X-ID: rIAKlrZOwh4KyhvyN8GBjAxloe1G0cV1Fp2-P6MCqXC24uy-ST+afHPJ01alzKFwIE X-TOI-MSGID: b3657df1-e2d0-426a-b9d7-daef45b12d11 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: [PATCH] Improve ESC key interrupt of cat and sleep 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, 21 Apr 2008 21:20:05 -0000 This is a multi-part message in MIME format. --------------010901040007070508050108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit A minor improvement of the ESC handling for 'sleep -i' and 'cat'. It may also make sense to add this to the 'hexdump' command. But this requires more changes, because the hexdump() function is also used in grub-fstest.c Christian 2008-04-21 Christian Franke * commands/cat.c (grub_cmd_cat): Remove non-ESC keys from keyboard queue to ensure that break with ESC will always work. * commands/sleep.c (grub_interruptible_millisleep): Likewise. Remove ESC from keyboard queue. --------------010901040007070508050108 Content-Type: text/x-patch; name="grub2-cat-sleep-break.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2-cat-sleep-break.patch" diff --git a/commands/cat.c b/commands/cat.c index 3a0d1f8..01fa3a4 100644 --- a/commands/cat.c +++ b/commands/cat.c @@ -34,6 +34,7 @@ grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)), grub_file_t file; char buf[GRUB_DISK_SECTOR_SIZE]; grub_ssize_t size; + int key = 0; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required"); @@ -42,7 +43,8 @@ grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)), if (! file) return 0; - while ((size = grub_file_read (file, buf, sizeof (buf))) > 0) + while ((size = grub_file_read (file, buf, sizeof (buf))) > 0 + && key != GRUB_TERM_ESC) { int i; @@ -60,11 +62,9 @@ grub_cmd_cat (struct grub_arg_list *state __attribute__ ((unused)), } } - if (GRUB_TERM_ASCII_CHAR (grub_checkkey ()) == GRUB_TERM_ESC) - { - grub_getkey (); - break; - } + while (grub_checkkey () >= 0 && + (key = GRUB_TERM_ASCII_CHAR (grub_getkey ())) != GRUB_TERM_ESC) + ; } grub_putchar ('\n'); diff --git a/commands/sleep.c b/commands/sleep.c index b239ef9..c4744c5 100644 --- a/commands/sleep.c +++ b/commands/sleep.c @@ -52,7 +52,8 @@ grub_interruptible_millisleep (grub_uint32_t ms) end_at = grub_get_rtc () + grub_div_roundup (ms * GRUB_TICKS_PER_SECOND, 1000); while (grub_get_rtc () < end_at) - if (GRUB_TERM_ASCII_CHAR (grub_checkkey ()) == GRUB_TERM_ESC) + if (grub_checkkey () >= 0 && + GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) return 1; return 0; --------------010901040007070508050108--