Index: ChangeLog =================================================================== RCS file: /cvsroot/grub/grub/ChangeLog,v retrieving revision 1.525 diff -u -r1.525 ChangeLog --- ChangeLog 10 Oct 2002 01:26:16 -0000 1.525 +++ ChangeLog 14 Oct 2002 13:17:14 -0000 @@ -1,3 +1,26 @@ +2002-10-14 Adam Lackorzynski + + * stage2/stage2.c: Add menu history support. + (cmain): Save history in history buffer. + (run_menu): Add history, go one entry back in history on key left. + + * stage2/stage2.c (run_menu): Make right key to do the same + as enter in the menu. + + * stage2/stage2.c (run_menu): Add page up and page down support. + * stage2/asm.S (translation_table): Add 3 and 7 for page up and down. + * stage2/serial.c (serial_translate_key_sequence): Add page up and + down. + * grub/asmstub.c (console_translate_key): Likewise. + + * stage2/stage2.c (run_menu): Display number of current entry + in the right upper corner of the menu frame. + + * stage2/stage2.c (run_menu): Add 'r' key to reload menu. + + * stage2/stage2.c (run_menu): Add vi like up and down keys + ("j" and "k"). + 2002-10-10 Jason Thomas * stage2/builtins.c (setup_func): Added missing space to --force-lba Index: grub/asmstub.c =================================================================== RCS file: /cvsroot/grub/grub/grub/asmstub.c,v retrieving revision 1.76 diff -u -r1.76 asmstub.c --- grub/asmstub.c 22 Aug 2002 05:59:55 -0000 1.76 +++ grub/asmstub.c 14 Oct 2002 13:17:15 -0000 @@ -627,6 +627,10 @@ return 1; case KEY_END: return 5; + case KEY_NPAGE: + return 7; + case KEY_PPAGE: + return 3; default: break; } Index: stage2/asm.S =================================================================== RCS file: /cvsroot/grub/grub/stage2/asm.S,v retrieving revision 1.62 diff -u -r1.62 asm.S --- stage2/asm.S 5 Oct 2002 23:36:25 -0000 1.62 +++ stage2/asm.S 14 Oct 2002 13:17:15 -0000 @@ -1920,6 +1920,8 @@ .word KEY_END, 5 .word KEY_DC, 4 .word KEY_BACKSPACE, 8 + .word KEY_PPAGE, 3 + .word KEY_NPAGE, 7 .word 0 /* Index: stage2/serial.c =================================================================== RCS file: /cvsroot/grub/grub/stage2/serial.c,v retrieving revision 1.11 diff -u -r1.11 serial.c --- stage2/serial.c 13 Sep 2002 11:27:41 -0000 1.11 +++ stage2/serial.c 14 Oct 2002 13:17:15 -0000 @@ -218,7 +218,9 @@ four_code_table[] = { {('1' | ('~' << 8)), 1}, - {('3' | ('~' << 8)), 4} + {('3' | ('~' << 8)), 4}, + {('6' | (126 << 8)), 3}, + {('5' | (126 << 8)), 7}, }; /* The buffer must start with ``ESC [''. */ Index: stage2/stage2.c =================================================================== RCS file: /cvsroot/grub/grub/stage2/stage2.c,v retrieving revision 1.38 diff -u -r1.38 stage2.c --- stage2/stage2.c 22 Aug 2002 05:59:55 -0000 1.38 +++ stage2/stage2.c 14 Oct 2002 13:17:15 -0000 @@ -76,6 +76,21 @@ #endif /* ! PRESET_MENU_STRING && ! SUPPORT_DISKLESS */ +/* config_file is 128 Bytes long (see grub/asmstub.c) */ +#define CONFIG_FILE_LEN 128 +#define CONFIG_FILE_HISTORY_ENTRIES 10 +struct config_file_history_struct { + char filename[CONFIG_FILE_LEN]; + int entryno; + int first_entry; +}; +static struct config_file_history_struct + config_file_history[CONFIG_FILE_HISTORY_ENTRIES]; +static int config_file_history_pos, config_file_history_start, + config_file_history_prev_pos; +static int config_file_history_menu_pos = -1; + + static char * get_entry (char *list, int num, int nested) { @@ -234,6 +249,15 @@ */ restart: + + if (config_file_history_menu_pos != -1) + { + /* we're in a history back movement, set menu values to previous ones */ + entryno = config_file_history[config_file_history_menu_pos].entryno; + first_entry = config_file_history[config_file_history_menu_pos].first_entry; + config_file_history_menu_pos = -1; + } + /* Dumb terminal always use all entries for display invariant for TERM_DUMB: first_entry == 0 */ if (! (current_term->flags & TERM_DUMB)) @@ -313,8 +337,10 @@ { if (config_entries) printf ("\ - Press enter to boot the selected OS, \'e\' to edit the\n\ - commands before booting, or \'c\' for a command-line."); + Press enter or %c to boot the selected OS, \'e\' to edit the\n\ + commands before booting, \'c\' for a command-line, \'r\' to reload or\n\ + or %c to go back if possible.", + DISP_RIGHT, DISP_LEFT); else printf ("\ Press \'b\' to boot, \'e\' to edit the selected command in the\n\ @@ -362,6 +388,18 @@ grub_timeout--; } + /* Print the number of the current entry in the right upper corner of + * the menu, up to 999 entries are supported, modify the coordinates + * and putchar command to add more */ + if (! (current_term->flags & TERM_DUMB)) + { + gotoxy(69, 3); + grub_printf("[%d]", first_entry + entryno); + grub_putchar(DISP_HORIZ); + grub_putchar(DISP_HORIZ); + gotoxy(74, 4 + entryno); + } + /* Check for a keypress, however if TIMEOUT has been expired (GRUB_TIMEOUT == -1) relax in GETKEY even if no key has been pressed. @@ -392,7 +430,7 @@ /* We told them above (at least in SUPPORT_SERIAL) to use '^' or 'v' so accept these keys. */ - if (c == 16 || c == '^') + if (c == 16 || c == '^' || c == 'k') { if (current_term->flags & TERM_DUMB) { @@ -421,7 +459,7 @@ } } } - else if ((c == 14 || c == 'v') + else if ((c == 14 || c == 'v' || c == 'j') && first_entry + entryno + 1 < num_entries) { if (current_term->flags & TERM_DUMB) @@ -448,10 +486,103 @@ } } + /* PAGE UP */ + if (c == 7 && !(current_term->flags & TERM_DUMB)) + { + if (first_entry > 11) + { + first_entry -= 12; + print_entries (3, 12, first_entry, entryno, menu_entries); + } + else if (first_entry) + { + print_entry (4 + entryno, 0, + get_entry (menu_entries, + first_entry + entryno, + 0)); + if (entryno + first_entry - 12 < 0) + entryno = 0; + else + entryno = first_entry + entryno - 12; + first_entry = 0; + print_entries (3, 12, first_entry, entryno, menu_entries); + } + else if (entryno) + { + print_entry (4 + entryno, 0, + get_entry (menu_entries, + first_entry + entryno, + 0)); + entryno = 0; + print_entry (4, 1, get_entry (menu_entries, 0, 0)); + + } + } + /* PAGE DOWN */ + else if (c == 3 && !(current_term->flags & TERM_DUMB)) + { + if (first_entry + 12 < num_entries) + { + if (first_entry + 23 < num_entries) + first_entry += 12; + else + { + print_entry (4 + entryno, 0, + get_entry (menu_entries, + first_entry + entryno, + 0)); + if (entryno + first_entry + 12 >= num_entries) + entryno = 11; + else + entryno += 24 + first_entry - num_entries; + first_entry = num_entries - 12; + } + print_entries (3, 12, first_entry, entryno, menu_entries); + } + else if (first_entry + entryno + 1 != num_entries) + { + print_entry (4 + entryno, 0, + get_entry (menu_entries, + first_entry + entryno, + 0)); + entryno = num_entries - first_entry - 1; + print_entry (4 + entryno, 1, + get_entry (menu_entries, + first_entry + entryno, + 0)); + } + } + if (config_entries) { - if ((c == '\n') || (c == '\r')) - break; + if (c == 'r') + return; + + if ((c == '\n') || (c == '\r') || (c == 6)) + { + config_file_history[config_file_history_prev_pos].entryno = + entryno; + config_file_history[config_file_history_prev_pos].first_entry = + first_entry; + + break; + } + + if (c == 2) /* KEY_LEFT */ + { + /* go back in history if possible */ + int p = config_file_history_prev_pos; + if (p != config_file_history_start) + { + p = (p == 0) ? CONFIG_FILE_HISTORY_ENTRIES - 1 : p - 1; + memmove(config_file, config_file_history[p].filename, + CONFIG_FILE_LEN); + config_file_history_pos = p; + config_file_history_menu_pos = p; + + return; + } + } } else { @@ -938,6 +1069,18 @@ close_preset_menu (); else grub_close (); + + /* Save history for config_file */ + memmove(config_file_history[config_file_history_pos].filename, + config_file, + CONFIG_FILE_LEN); + config_file_history_prev_pos = config_file_history_pos; + if (++config_file_history_pos == CONFIG_FILE_HISTORY_ENTRIES) + config_file_history_pos = 0; + if (config_file_history_start == config_file_history_pos && + ++config_file_history_start == CONFIG_FILE_HISTORY_ENTRIES) + config_file_history_start = 0; + } while (is_preset); }