Fix the scrollbar handling for insanely huge menus
authorH. Peter Anvin <hpa@zytor.com>
Wed, 20 Feb 2008 02:25:08 +0000 (18:25 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 20 Feb 2008 02:25:08 +0000 (18:25 -0800)
The handling of the scrollbar for insanely huge menus was broken,
causing it to disappear off the bottom of the menu window.

com32/menu/menumain.c

index d563198..2bbbc4f 100644 (file)
@@ -297,10 +297,9 @@ draw_menu(int sel, int top, int edit_line)
   int tabmsg_len;
 
   if ( cm->nentries > MENU_ROWS ) {
-    int sblen = MENU_ROWS*MENU_ROWS/cm->nentries;
+    int sblen = max(MENU_ROWS*MENU_ROWS/cm->nentries, 1);
     sbtop = (MENU_ROWS-sblen+1)*top/(cm->nentries-MENU_ROWS+1);
-    sbbot = max(sbtop, sbtop+sblen-1);
-
+    sbbot = sbtop+sblen-1;
     sbtop += 4;  sbbot += 4;   /* Starting row of scrollbar */
   }