Jump to content











Photo
- - - - -

New grub4dos with improved numbered menu support


  • Please log in to reply
7 replies to this topic

#1 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 08 May 2011 - 02:19 PM

As many of you may have noticed, grub4dos has a problem when using numbered menu items.

It always counts from 0 and if you have blank menu separators, this is still counted by grub4dos as a menu item. e.g. you have to number the menu items like this:


0 menu aaa

1 menu bbb

---- DOS commands ---

3 menu ccc

4 menu ddd


so if you type 3, it goes to the 4th menu item and, in this example, the menu item numbered 2 has to be missing as a menu separator is used for this entry.
Also if the user presses '2' on the keyboard, the separator (--- DOS commands ---) is selected.

I have modified grub4dos, so that IF your menu title starts with a number, the user can press that number to select the item. This means your menu can start from 1 and not 0, and you can have separators. So the menu above now becomes:


 My Heading                                                                      heading/separator here or just have title <space> for a blank entry

1 menu aaa

2 menu bbb

---- DOS commands ---

3 menu ccc

4 menu ddd


Menu entries larger than 10 are supported.

This new version has a few 'foibles' (gnumber=grub4dos number which starts at 0 and each menu item has a gnumber, mnumber= the menu number which is taken from the number at the start of the menu title text)
1. If the user presses 3 to select the 3 menu cc item in the above example, '4' will be displayed at the top right corner as it is the gnumber menu item #4 in grub4dos-speak
2. If some of the menu items are unnumbered (no mnumber), the unnumbered items cannot be selected by pressing the appropriate gnumber key (so separator menu entries can never be selected by the user - which is a good thing!) - unless the mnumber numbered item does not exist.
3. The multiple key feature (pressing the same number 5 times to change it to the down-cursor key) will not work if the menu is numbered and you press a number key - letter keys do work though.
4. A menu entry 0 (i.e. an entry before the 1 xxx entry) needs to exist if you have more than 9 entries, otherwise entering numbers larger than 9 won't work. To fix this make sure the first menu entry is either blank or any heading you like or number it as '0 xxxxx'.
5. The first few menu entries should exist even if not numbered. For example if you have 34 entries, then menu entries 0, 1 , 2 and 3 (in grub4dos numbering - gnumber) must exist or else typing 33 to select entry 33 will not work.
6. You cannot number a menu entry with a number higher than the last grub4dos number. For example you cannot have menu with six entries but have the last one as 'title 99 Reboot'.
7. Leading 0's can be used in a title, so you can number from 00 to 99, if the user presses 4 or 04 then the menu item numbered 04 (mnumber) will be highlighted.
8. If two or more menu items have the same mnumber, only the first one will be selected when the user types that number.


The basic rules are: if you use numbered menu items, use the first item (gnumber 0) either as a separator/heading or a number 0 item and number the next three (or so) menu items - after that you should consecutively number all items but you can use separators wherever you like.

GFXmenu numbers it's menu items from 1 and not from 0. This means you can now have a grub4dos menu starting at 1-9 and then later add GFXMenu and keep the same numbering if all your menu items are numbered!

There may be a few more quirks. Please could you try it and let me know if you think this is an improvement that should be included in all newer versions? Just replace your current grldr file with this new one. I will pass the code change over to chenall for suggested inclusion if you think this is a good idea.

[Edit] Replaced by newer version of grub4dos (latest chenall build) which supports (bd), etc.).[/Edit]

Attached Files



#2 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 08 May 2011 - 03:01 PM

It is nice to give a svn diff against svn head version and submit the diff to http://code.google.c...all/issues/list

#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 08 May 2011 - 03:04 PM

It is nice to give a svn diff against svn head version and submit the diff to http://code.google.c...all/issues/list

probably, if I knew what on earth you were talking about! Posted Image How would I do that and what changes do I need to make? Do I need to uprev it? If so how?

#4 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 08 May 2011 - 04:00 PM

probably, if I knew what on earth you were talking about! Posted Image How would I do that and what changes do I need to make? Do I need to uprev it? If so how?

If the sources that you use it from the svn, that's easy: (assume you didn't run autoconf/autoreconf/automake i.e. just use the supplied configure/Makefile)
* run "svn diff > my-patch.diff" (without quote) to generate a diff file for your changes.
-OR-
* if you use TortoiseSVN for the SVN jobs, right click -> TortoiseSVN -> Create patch...

If you are NOT using svn head as your base, then it will be a bit harder:
- extract the original source to another directory (e.g. grub4dos-original)
- run "diff -ru3 grub4dos-original/ grub4dos/ > my-patch.diff" (without quote) in upper directory in msys prompt

References:
Basic SVN commands: http://www.linuxfrom.../chapter03.html
diff: http://ss64.com/bash/diff.html

#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 08 May 2011 - 04:07 PM

Here is diff file. I am not very experienced with C, so it probably is not the best code! any comments welcome!

Attached Files



#6 sbaeder

sbaeder

    Gold Member

  • .script developer
  • 1338 posts
  • Location:usa - massachusettes
  •  
    United States

Posted 08 May 2011 - 08:39 PM

Just a comment - I like the iso/syslinux way of jumping to a menu, which is to use an "^" character in front of any character in the menu label ( which it makes BOLD so it stands out) Then you have just hit that character, and it jumps to that location...I guess it could be a number

I use this sort of thing all the time...


MENU LABEL ^Win7PE

MENU LABEL ^Active Boot Disk  v.5.1.3

MENU LABEL ^Ultimate Boot CD v5.03

MENU LABEL ^Hiren&#39;s Boot CD

MENU LABEL ^Parted Magic Linux 5.10

MENU LABEL ^SpinRite  v.6.0

MENU LABEL ^MemTest86+ 4.20



etc...

Of course, you can't "reuse" the same letter more than once, so that can get tricky (like if you had more than 9 numeric entries... :unsure:

Just something to consider...

#7 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 08 May 2011 - 10:27 PM

Unfortunately, g4dos uses some letters already (b,c,d) and also it would be very difficult to implement.

#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 09 May 2011 - 06:26 PM

chenall has now included this in the latest build at http://code.google.c.../downloads/list




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users