From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KiWtv-0006s1-AJ for mharc-grub-devel@gnu.org; Wed, 24 Sep 2008 12:07:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KiWtu-0006rg-LI for grub-devel@gnu.org; Wed, 24 Sep 2008 12:07:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KiWtr-0006qQ-0H for grub-devel@gnu.org; Wed, 24 Sep 2008 12:07:38 -0400 Received: from [199.232.76.173] (port=54523 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KiWtq-0006qI-NP for grub-devel@gnu.org; Wed, 24 Sep 2008 12:07:34 -0400 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:47775 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KiWtq-0002ba-1V for grub-devel@gnu.org; Wed, 24 Sep 2008 12:07:34 -0400 Received: from pinux (21.61.221.87.dynamic.jazztel.es [87.221.61.21]) by mail.pina.cat (Postfix) with ESMTP id 83F0828906548 for ; Wed, 24 Sep 2008 18:07:25 +0200 (CEST) Received: by pinux (Postfix, from userid 1000) id 5177192A60; Wed, 24 Sep 2008 18:07:24 +0200 (CEST) Date: Wed, 24 Sep 2008 18:07:24 +0200 From: Carles Pina i Estany To: The development of GRUB 2 Message-ID: <20080924160724.GA10087@pina.cat> References: <20080920203745.GA27562@pina.cat> <20080924103424.GK6973@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline In-Reply-To: <20080924103424.GK6973@thorin> User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: [PATCH] Menu control for NPAGE and PPAGE 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: Wed, 24 Sep 2008 16:07:38 -0000 --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, On Sep/24/2008, Robert Millan wrote: > On Sat, Sep 20, 2008 at 10:37:45PM +0200, Carles Pina i Estany wrote: > > > > Hello, > > > > (This patch includes the changes for GRUB_TERM_NPAGE/PPAGE macros, that > > I sent in a previous mail) > > > > ChangeLog: > > -------- > > 2008-09-20 Carles Pina i Estany > > * normal/menu.c (run_menu): Add Previous and Next Page keys in > > grub-menu. > > > > * include/grub/powerpc/ieee1275/console.h (GRUB_TERM_NPAGE): > > Changed to 0x5100. > > (GRUB_TERM_PPAGE): Changed to 0x4900. > > > > * include/grub/sparc64/ieee1275/console.h: Likewise. > > > > * include/grub/i386/pc/console.h: Likewise. > > > > * include/grub/efi/console.h: Likewise. > > -------- > > The scancode part is merged already, please update/resync. done New ChangeLog entry: 2008-09-24 Carles Pina i Estany * normal/menu.c (run_menu): Add Previous and Next Page keys in grub-menu. > > + else > > + { > > + first = first - GRUB_TERM_NUM_ENTRIES; > > + > > + if (first < 0) > > + { > > + offset = offset + first; > > I'd suggest using '+=' and '-=' on these to make it more readable and > avoid redundancy. done! (I'm not a bit fan of it when there is three operators like in: offset += GRUB_TERM_NUM_ENTRIES - 1;, but yes, it's shorter :-) ) > > + case GRUB_TERM_NPAGE: > > + if (offset==0) > > + { > > + offset = offset + GRUB_TERM_NUM_ENTRIES -1 ; > > + if (first+offset>menu->size) > > + { > > + offset=menu->size-first-1; > > + } > > + } > > Please add spaces around '==', '>', '+', '-', etc. done! > > + if (offset > menu->size - 1 || offset > GRUB_TERM_NUM_ENTRIES - 1) > > Does this generate a compiler warning? no. At least not in my gcc: carles@pinux:~$ gcc --version gcc (Debian 4.3.1-2) 4.3.1 .... New patch is attached. I also improved some other thing. Feedback is welcomed :-) -- Carles Pina i Estany GPG id: 0x17756391 http://pinux.info --HlL+5n6rz5pIUxbD Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ppage_npage_control04.patch" Index: normal/menu.c =================================================================== --- normal/menu.c (revision 1872) +++ normal/menu.c (working copy) @@ -457,6 +457,57 @@ } } break; + + case GRUB_TERM_PPAGE: + if (first == 0) + { + offset = 0; + } + else + { + first -= GRUB_TERM_NUM_ENTRIES; + + if (first < 0) + { + offset += first; + first = 0; + } + } + print_entries (menu, first, offset); + break; + + case GRUB_TERM_NPAGE: + if (offset == 0) + { + offset += GRUB_TERM_NUM_ENTRIES - 1; + if (first+offset > menu->size) + { + offset = menu -> size-first - 1; + } + } + else + { + first += GRUB_TERM_NUM_ENTRIES; + + if (first + offset >= menu->size) + { + first -= GRUB_TERM_NUM_ENTRIES; + offset += GRUB_TERM_NUM_ENTRIES; + + if (offset > menu->size - 1 || + offset > GRUB_TERM_NUM_ENTRIES - 1) + { + offset = menu->size - first - 1; + } + if (offset > GRUB_TERM_NUM_ENTRIES) + { + first += offset - GRUB_TERM_NUM_ENTRIES + 1; + offset = GRUB_TERM_NUM_ENTRIES - 1; + } + } + } + print_entries (menu, first, offset); + break; case '\n': case '\r': --HlL+5n6rz5pIUxbD--