2005-02-19 Yoshinori K. Okuji <okuji@enbug.org>

This implements an Emacs-like menu entry editor.

  * normal/menu_entry.c: New file.

  * util/console.c (grub_ncurses_putchar): Translate some Unicode
  characters to ASCII.
  (saved_char): New variable.
  (grub_ncurses_checkkey): Rewritten completely.
  (grub_ncurses_getkey): Likewise.
  (grub_ncurses_init): Call raw instead of cbreak.

  * normal/menu.c (print_entry): Do not put a space.
  (init_page): Renamed to ...
  (grub_menu_init_page): ... this. All callers changed.
  (edit_menu_entry): Removed.
  (run_menu): Call grub_menu_entry_run instead of edit_menu_entry.

  * normal/cmdline.c (grub_cmdline_run): Call grub_setcursor.

  * kern/misc.c (grub_vprintf): Call grub_refresh.

  * normal/menu.c (DISP_LEFT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_LEFT): ... this.
  * normal/menu.c (DISP_UP): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_UP): ... this.
  * normal/menu.c (DISP_RIGHT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_RIGHT): ... this.
  * normal/menu.c (DISP_DOWN): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_DOWN): ... this.
  * normal/menu.c (DISP_HLINE): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_HLINE): ... this.
  * normal/menu.c (DISP_VLINE): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_VLINE): ... this.
  * normal/menu.c (DISP_UL): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_UL): ... this.
  * normal/menu.c (DISP_UR): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_UR): ... this.
  * normal/menu.c (DISP_LL): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_LL): ... this.
  * normal/menu.c (DISP_LR): Renamed to ...
  * include/grub/term.h (GRUB_TERM_DISP_LR): ... this.
  * normal/menu.c (TERM_WIDTH): Renamed to ...
  * include/grub/term.h (GRUB_TERM_WIDTH): ... this.
  * normal/menu.c (TERM_HEIGHT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_HEIGHT): ... this.
  * normal/menu.c (TERM_INFO_HEIGHT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_INFO_HEIGHT): ... this.
  * normal/menu.c (TERM_MARGIN): Renamed to ...
  * include/grub/term.h (GRUB_TERM_MARGIN): ... this.
  * normal/menu.c (TERM_SCROLL_WIDTH): Renamed to ...
  * include/grub/term.h (GRUB_TERM_SCROLL_WIDTH): ... this.
  * normal/menu.c (TERM_TOP_BORDER_Y): Renamed to ...
  * include/grub/term.h (GRUB_TERM_TOP_BORDER_Y): ... this.
  * normal/menu.c (TERM_LEFT_BORDER_X): Renamed to ...
  * include/grub/term.h (GRUB_TERM_LEFT_BORDER_X): ... this.
  * normal/menu.c (TERM_BORDER_WIDTH): Renamed to ...
  * include/grub/term.h (GRUB_TERM_BORDER_WIDTH): ... this.
  * normal/menu.c (TERM_MESSAGE_HEIGHT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): ... this.
  * normal/menu.c (TERM_BORDER_HEIGHT): Renamed to ...
  * include/grub/term.h (GRUB_TERM_BORDER_HEIGHT): ... this.
  * normal/menu.c (TERM_NUM_ENTRIES): Renamed to ...
  * include/grub/term.h (GRUB_TERM_NUM_ENTRIES): ... this.
  * normal/menu.c (TERM_FIRST_ENTRY_Y): Renamed to ...
  * include/grub/term.h (GRUB_TERM_FIRST_ENTRY_Y): ... this.
  * normal/menu.c (TERM_ENTRY_WIDTH): Renamed to ...
  * include/grub/term.h (GRUB_TERM_ENTRY_WIDTH): ... this.
  * normal/menu.c (TERM_CURSOR_X): Renamed to ...
  * include/grub/term.h (GRUB_TERM_CURSOR_X): ... this.
  All callers changed.

  * include/grub/normal.h: New prototype.

  * conf/i386-pc.rmk (grub_emu_SOURCES): Added
  normal/menu_entry.c.
  (normal_mod_SOURCES): Likewise.
  * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
  (normal_mod_SOURCES): Likewise.

2005-02-15  Yoshinori K. Okuji  <okuji@enbug.org>

  * include/grub/normal.h (grub_halt_init): New prototype.
  (grub_halt_fini): Likewise.
  (grub_reboot_init): Likewise.
  (grub_reboot_fini): Likewise.

  * util/grub-emu.c: Include signal.h.
  (main_env): New global variable.
  (grub_machine_init): Ignore SIGINT. Otherwise grub-emu cannot
  catch C-c.
  (grub_machine_fini): New function.
  (main): Call grub_halt_init and grub_reboot_init before
  grub_main, and grub_reboot_fini and grub_halt_fini after it.
  Call setjmp with MAIN_ENV to go back afterwards.
  Call grub_machine_fini right before return.

  * include/grub/util/misc.h: Include setjmp.h.
  (main_env): New prototype.

  * include/grub/kernel.h (grub_machine_fini): New prototype.
  * include/grub/i386/pc/biosdisk.h (grub_biosdisk_fini): Likewise.
  * include/grub/i386/pc/console.h (grub_console_fini): Likewise.

  * disk/i386/pc/biosdisk.c (grub_biosdisk_fini): New function.
  * kern/i386/pc/init.c (grub_machine_fini): Likewise.
  * term/i386/pc/console.c (grub_console_fini): Likewise.

  * util/i386/pc/misc.c: New file.

  * conf/i386-pc.rmk (grub_emu_SOURCES): Added
  util/i386/pc/misc.c, commands/i386/pc/halt.c and
  commands/i386/pc/reboot.c.
This commit is contained in:
okuji 2005-02-19 20:56:07 +00:00
parent e6b92c8afb
commit 4d4e372ebd
11 changed files with 1334 additions and 143 deletions

View File

@ -1,3 +1,84 @@
2005-02-19 Yoshinori K. Okuji <okuji@enbug.org>
This implements an Emacs-like menu entry editor.
* normal/menu_entry.c: New file.
* util/console.c (grub_ncurses_putchar): Translate some Unicode
characters to ASCII.
(saved_char): New variable.
(grub_ncurses_checkkey): Rewritten completely.
(grub_ncurses_getkey): Likewise.
(grub_ncurses_init): Call raw instead of cbreak.
* normal/menu.c (print_entry): Do not put a space.
(init_page): Renamed to ...
(grub_menu_init_page): ... this. All callers changed.
(edit_menu_entry): Removed.
(run_menu): Call grub_menu_entry_run instead of edit_menu_entry.
* normal/cmdline.c (grub_cmdline_run): Call grub_setcursor.
* kern/misc.c (grub_vprintf): Call grub_refresh.
* normal/menu.c (DISP_LEFT): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_LEFT): ... this.
* normal/menu.c (DISP_UP): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_UP): ... this.
* normal/menu.c (DISP_RIGHT): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_RIGHT): ... this.
* normal/menu.c (DISP_DOWN): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_DOWN): ... this.
* normal/menu.c (DISP_HLINE): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_HLINE): ... this.
* normal/menu.c (DISP_VLINE): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_VLINE): ... this.
* normal/menu.c (DISP_UL): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_UL): ... this.
* normal/menu.c (DISP_UR): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_UR): ... this.
* normal/menu.c (DISP_LL): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_LL): ... this.
* normal/menu.c (DISP_LR): Renamed to ...
* include/grub/term.h (GRUB_TERM_DISP_LR): ... this.
* normal/menu.c (TERM_WIDTH): Renamed to ...
* include/grub/term.h (GRUB_TERM_WIDTH): ... this.
* normal/menu.c (TERM_HEIGHT): Renamed to ...
* include/grub/term.h (GRUB_TERM_HEIGHT): ... this.
* normal/menu.c (TERM_INFO_HEIGHT): Renamed to ...
* include/grub/term.h (GRUB_TERM_INFO_HEIGHT): ... this.
* normal/menu.c (TERM_MARGIN): Renamed to ...
* include/grub/term.h (GRUB_TERM_MARGIN): ... this.
* normal/menu.c (TERM_SCROLL_WIDTH): Renamed to ...
* include/grub/term.h (GRUB_TERM_SCROLL_WIDTH): ... this.
* normal/menu.c (TERM_TOP_BORDER_Y): Renamed to ...
* include/grub/term.h (GRUB_TERM_TOP_BORDER_Y): ... this.
* normal/menu.c (TERM_LEFT_BORDER_X): Renamed to ...
* include/grub/term.h (GRUB_TERM_LEFT_BORDER_X): ... this.
* normal/menu.c (TERM_BORDER_WIDTH): Renamed to ...
* include/grub/term.h (GRUB_TERM_BORDER_WIDTH): ... this.
* normal/menu.c (TERM_MESSAGE_HEIGHT): Renamed to ...
* include/grub/term.h (GRUB_TERM_MESSAGE_HEIGHT): ... this.
* normal/menu.c (TERM_BORDER_HEIGHT): Renamed to ...
* include/grub/term.h (GRUB_TERM_BORDER_HEIGHT): ... this.
* normal/menu.c (TERM_NUM_ENTRIES): Renamed to ...
* include/grub/term.h (GRUB_TERM_NUM_ENTRIES): ... this.
* normal/menu.c (TERM_FIRST_ENTRY_Y): Renamed to ...
* include/grub/term.h (GRUB_TERM_FIRST_ENTRY_Y): ... this.
* normal/menu.c (TERM_ENTRY_WIDTH): Renamed to ...
* include/grub/term.h (GRUB_TERM_ENTRY_WIDTH): ... this.
* normal/menu.c (TERM_CURSOR_X): Renamed to ...
* include/grub/term.h (GRUB_TERM_CURSOR_X): ... this.
All callers changed.
* include/grub/normal.h: New prototype.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added
normal/menu_entry.c.
(normal_mod_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
2005-02-15 Yoshinori K. Okuji <okuji@enbug.org>
* include/grub/normal.h (grub_halt_init): New prototype.

View File

@ -507,15 +507,15 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \
kern/partition.c kern/rescue.c kern/term.c \
normal/arg.c normal/cmdline.c normal/command.c normal/main.c \
normal/menu.c \
normal/menu.c normal/menu_entry.c \
partmap/amiga.c partmap/apple.c partmap/pc.c \
util/console.c util/grub-emu.c util/misc.c \
util/i386/pc/biosdisk.c util/i386/pc/getroot.c \
util/i386/pc/misc.c
CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d
CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d
grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
grub_emu-commands_boot.o: commands/boot.c
@ -798,6 +798,14 @@ grub_emu-normal_menu.d: normal/menu.c
-include grub_emu-normal_menu.d
grub_emu-normal_menu_entry.o: normal/menu_entry.c
$(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
grub_emu-normal_menu_entry.d: normal/menu_entry.c
set -e; $(BUILD_CC) -Inormal -I$(srcdir)/normal $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $< | sed 's,menu_entry\.o[ :]*,grub_emu-normal_menu_entry.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include grub_emu-normal_menu_entry.d
grub_emu-partmap_amiga.o: partmap/amiga.c
$(BUILD_CC) -Ipartmap -I$(srcdir)/partmap $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
@ -1330,10 +1338,11 @@ linux_mod-loader_i386_pc_linux_normal.d: loader/i386/pc/linux_normal.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
# For normal.mod.
normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \
normal/menu.c normal/arg.c normal/i386/setjmp.S
CLEANFILES += normal.mod mod-normal.o mod-normal.c pre-normal.o normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_arg.o normal_mod-normal_i386_setjmp.o def-normal.lst und-normal.lst
MOSTLYCLEANFILES += normal_mod-normal_cmdline.d normal_mod-normal_command.d normal_mod-normal_main.d normal_mod-normal_menu.d normal_mod-normal_arg.d normal_mod-normal_i386_setjmp.d
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
normal/main.c normal/menu.c normal/menu_entry.c \
normal/i386/setjmp.S
CLEANFILES += normal.mod mod-normal.o mod-normal.c pre-normal.o normal_mod-normal_arg.o normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_menu_entry.o normal_mod-normal_i386_setjmp.o def-normal.lst und-normal.lst
MOSTLYCLEANFILES += normal_mod-normal_arg.d normal_mod-normal_cmdline.d normal_mod-normal_command.d normal_mod-normal_main.d normal_mod-normal_menu.d normal_mod-normal_menu_entry.d normal_mod-normal_i386_setjmp.d
DEFSYMFILES += def-normal.lst
UNDSYMFILES += und-normal.lst
@ -1342,7 +1351,7 @@ normal.mod: pre-normal.o mod-normal.o
$(LD) -r -d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-normal.o: normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_arg.o normal_mod-normal_i386_setjmp.o
pre-normal.o: normal_mod-normal_arg.o normal_mod-normal_cmdline.o normal_mod-normal_command.o normal_mod-normal_main.o normal_mod-normal_menu.o normal_mod-normal_menu_entry.o normal_mod-normal_i386_setjmp.o
-rm -f $@
$(LD) -r -d -o $@ $^
@ -1359,6 +1368,14 @@ und-normal.lst: pre-normal.o
echo 'normal' > $@
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
normal_mod-normal_arg.o: normal/arg.c
$(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $<
normal_mod-normal_arg.d: normal/arg.c
set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -M $< | sed 's,arg\.o[ :]*,normal_mod-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include normal_mod-normal_arg.d
normal_mod-normal_cmdline.o: normal/cmdline.c
$(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $<
@ -1391,13 +1408,13 @@ normal_mod-normal_menu.d: normal/menu.c
-include normal_mod-normal_menu.d
normal_mod-normal_arg.o: normal/arg.c
normal_mod-normal_menu_entry.o: normal/menu_entry.c
$(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $<
normal_mod-normal_arg.d: normal/arg.c
set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -M $< | sed 's,arg\.o[ :]*,normal_mod-normal_arg.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
normal_mod-normal_menu_entry.d: normal/menu_entry.c
set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -M $< | sed 's,menu_entry\.o[ :]*,normal_mod-normal_menu_entry.o $@ : ,g' > $@; [ -s $@ ] || rm -f $@
-include normal_mod-normal_arg.d
-include normal_mod-normal_menu_entry.d
normal_mod-normal_i386_setjmp.o: normal/i386/setjmp.S
$(CC) -Inormal/i386 -I$(srcdir)/normal/i386 $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -c -o $@ $<

View File

@ -75,7 +75,7 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
kern/file.c kern/fs.c kern/loader.c kern/main.c kern/misc.c \
kern/partition.c kern/rescue.c kern/term.c \
normal/arg.c normal/cmdline.c normal/command.c normal/main.c \
normal/menu.c \
normal/menu.c normal/menu_entry.c \
partmap/amiga.c partmap/apple.c partmap/pc.c \
util/console.c util/grub-emu.c util/misc.c \
util/i386/pc/biosdisk.c util/i386/pc/getroot.c \
@ -141,8 +141,9 @@ linux_mod_SOURCES = loader/i386/pc/linux_normal.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
# For normal.mod.
normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \
normal/menu.c normal/arg.c normal/i386/setjmp.S
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
normal/main.c normal/menu.c normal/menu_entry.c \
normal/i386/setjmp.S
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_ASFLAGS = $(COMMON_ASFLAGS)

View File

@ -39,7 +39,7 @@ grub_emu_SOURCES = kern/main.c kern/device.c \
util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \
fs/jfs.c fs/iso9660.c \
normal/cmdline.c normal/command.c normal/main.c normal/menu.c \
normal/arg.c kern/partition.c \
normal/menu_entry.c normal/arg.c kern/partition.c \
util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \
kern/env.c disk/loopback.c commands/ls.c commands/help.c \
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c
@ -108,8 +108,9 @@ linux_mod_SOURCES = loader/powerpc/ieee1275/linux_normal.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
# For normal.mod.
normal_mod_SOURCES = normal/cmdline.c normal/command.c normal/main.c \
normal/menu.c normal/arg.c normal/powerpc/setjmp.S
normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
normal/main.c normal/menu.c normal/menu_entry.c \
normal/powerpc/setjmp.S
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_ASFLAGS = $(COMMON_ASFLAGS)

View File

@ -140,6 +140,7 @@ int grub_iterate_commands (int (*iterate) (grub_command_t));
int grub_command_execute (char *cmdline);
void grub_command_init (void);
void grub_normal_init_page (void);
void grub_menu_init_page (int nested, int edit);
int grub_arg_parse (grub_command_t parser, int argc, char **argv,
struct grub_arg_list *usr, char ***args, int *argnum);
void grub_arg_show_help (grub_command_t cmd);

View File

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
* Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -55,6 +55,73 @@ grub_term_color_state;
/* Set when the terminal needs to be initialized. */
#define GRUB_TERM_NEED_INIT (1 << 16)
/* Unicode characters for fancy graphics. */
#define GRUB_TERM_DISP_LEFT 0x2190
#define GRUB_TERM_DISP_UP 0x2191
#define GRUB_TERM_DISP_RIGHT 0x2192
#define GRUB_TERM_DISP_DOWN 0x2193
#define GRUB_TERM_DISP_HLINE 0x2501
#define GRUB_TERM_DISP_VLINE 0x2503
#define GRUB_TERM_DISP_UL 0x250F
#define GRUB_TERM_DISP_UR 0x2513
#define GRUB_TERM_DISP_LL 0x2517
#define GRUB_TERM_DISP_LR 0x251B
/* Menu-related geometrical constants. */
/* FIXME: These should be dynamically obtained from a terminal. */
#define GRUB_TERM_WIDTH 80
#define GRUB_TERM_HEIGHT 25
/* The number of lines of "GRUB version..." at the top. */
#define GRUB_TERM_INFO_HEIGHT 1
/* The number of columns/lines between messages/borders/etc. */
#define GRUB_TERM_MARGIN 1
/* The number of columns of scroll information. */
#define GRUB_TERM_SCROLL_WIDTH 1
/* The Y position of the top border. */
#define GRUB_TERM_TOP_BORDER_Y (GRUB_TERM_MARGIN + GRUB_TERM_INFO_HEIGHT \
+ GRUB_TERM_MARGIN)
/* The X position of the left border. */
#define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN
/* The width of the border. */
#define GRUB_TERM_BORDER_WIDTH (GRUB_TERM_WIDTH \
- GRUB_TERM_MARGIN * 3 \
- GRUB_TERM_SCROLL_WIDTH)
/* The number of lines of messages at the bottom. */
#define GRUB_TERM_MESSAGE_HEIGHT 8
/* The height of the border. */
#define GRUB_TERM_BORDER_HEIGHT (GRUB_TERM_HEIGHT \
- GRUB_TERM_TOP_BORDER_Y \
- GRUB_TERM_MESSAGE_HEIGHT)
/* The number of entries shown at a time. */
#define GRUB_TERM_NUM_ENTRIES (GRUB_TERM_BORDER_HEIGHT - 2)
/* The Y position of the first entry. */
#define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1)
/* The max column number of an entry. The last "-1" is for a
continuation marker. */
#define GRUB_TERM_ENTRY_WIDTH (GRUB_TERM_BORDER_WIDTH - 2 \
- GRUB_TERM_MARGIN * 2 - 1)
/* The standard X position of the cursor. */
#define GRUB_TERM_CURSOR_X (GRUB_TERM_LEFT_BORDER_X \
+ GRUB_TERM_BORDER_WIDTH \
- GRUB_TERM_MARGIN \
- 1)
struct grub_term
{
/* The terminal name. */

View File

@ -131,7 +131,11 @@ grub_printf (const char *fmt, ...)
int
grub_vprintf (const char *fmt, va_list args)
{
return grub_vsprintf (0, fmt, args);
int ret;
ret = grub_vsprintf (0, fmt, args);
grub_refresh ();
return ret;
}
int

View File

@ -431,6 +431,7 @@ void
grub_cmdline_run (int nested)
{
grub_normal_init_page ();
grub_setcursor (1);
grub_printf ("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\

View File

@ -24,67 +24,6 @@
#include <grub/mm.h>
#include <grub/machine/time.h>
/* FIXME: These below are all runaround. */
#define DISP_LEFT 0x2190
#define DISP_UP 0x2191
#define DISP_RIGHT 0x2192
#define DISP_DOWN 0x2193
#define DISP_HLINE 0x2501
#define DISP_VLINE 0x2503
#define DISP_UL 0x250F
#define DISP_UR 0x2513
#define DISP_LL 0x2517
#define DISP_LR 0x251B
/* FIXME: These should be dynamically obtained from a terminal. */
#define TERM_WIDTH 80
#define TERM_HEIGHT 25
/* The number of lines of "GRUB version..." at the top. */
#define TERM_INFO_HEIGHT 1
/* The number of columns/lines between messages/borders/etc. */
#define TERM_MARGIN 1
/* The number of columns of scroll information. */
#define TERM_SCROLL_WIDTH 1
/* The Y position of the top border. */
#define TERM_TOP_BORDER_Y (TERM_MARGIN + TERM_INFO_HEIGHT + TERM_MARGIN)
/* The X position of the left border. */
#define TERM_LEFT_BORDER_X TERM_MARGIN
/* The width of the border. */
#define TERM_BORDER_WIDTH (TERM_WIDTH \
- TERM_MARGIN * 3 \
- TERM_SCROLL_WIDTH)
/* The number of lines of messages at the bottom. */
#define TERM_MESSAGE_HEIGHT 8
/* The height of the border. */
#define TERM_BORDER_HEIGHT (TERM_HEIGHT \
- TERM_TOP_BORDER_Y \
- TERM_MESSAGE_HEIGHT)
/* The number of entries shown at a time. */
#define TERM_NUM_ENTRIES (TERM_BORDER_HEIGHT - 2)
/* The Y position of the first entry. */
#define TERM_FIRST_ENTRY_Y (TERM_TOP_BORDER_Y + 1)
/* The max column number of an entry. The last "-1" is for a
continuation marker. */
#define TERM_ENTRY_WIDTH (TERM_BORDER_WIDTH - 2 - TERM_MARGIN * 2 - 1)
/* The standard X position of the cursor. */
#define TERM_CURSOR_X (TERM_LEFT_BORDER_X \
+ TERM_BORDER_WIDTH \
- TERM_MARGIN \
- 1)
static void
draw_border (void)
{
@ -92,29 +31,29 @@ draw_border (void)
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
grub_gotoxy (TERM_MARGIN, TERM_TOP_BORDER_Y);
grub_putcode (DISP_UL);
for (i = 0; i < TERM_BORDER_WIDTH - 2; i++)
grub_putcode (DISP_HLINE);
grub_putcode (DISP_UR);
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y);
grub_putcode (GRUB_TERM_DISP_UL);
for (i = 0; i < GRUB_TERM_BORDER_WIDTH - 2; i++)
grub_putcode (GRUB_TERM_DISP_HLINE);
grub_putcode (GRUB_TERM_DISP_UR);
for (i = 0; i < (unsigned) TERM_NUM_ENTRIES; i++)
for (i = 0; i < (unsigned) GRUB_TERM_NUM_ENTRIES; i++)
{
grub_gotoxy (TERM_MARGIN, TERM_TOP_BORDER_Y + i + 1);
grub_putcode (DISP_VLINE);
grub_gotoxy (TERM_MARGIN + TERM_BORDER_WIDTH - 1, TERM_TOP_BORDER_Y + i + 1);
grub_putcode (DISP_VLINE);
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + i + 1);
grub_putcode (GRUB_TERM_DISP_VLINE);
grub_gotoxy (GRUB_TERM_MARGIN + GRUB_TERM_BORDER_WIDTH - 1, GRUB_TERM_TOP_BORDER_Y + i + 1);
grub_putcode (GRUB_TERM_DISP_VLINE);
}
grub_gotoxy (TERM_MARGIN, TERM_TOP_BORDER_Y + TERM_NUM_ENTRIES + 1);
grub_putcode (DISP_LL);
for (i = 0; i < TERM_BORDER_WIDTH - 2; i++)
grub_putcode (DISP_HLINE);
grub_putcode (DISP_LR);
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES + 1);
grub_putcode (GRUB_TERM_DISP_LL);
for (i = 0; i < GRUB_TERM_BORDER_WIDTH - 2; i++)
grub_putcode (GRUB_TERM_DISP_HLINE);
grub_putcode (GRUB_TERM_DISP_LR);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
grub_gotoxy (TERM_MARGIN, TERM_TOP_BORDER_Y + TERM_NUM_ENTRIES + TERM_MARGIN + 1);
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES + GRUB_TERM_MARGIN + 1);
}
static void
@ -131,7 +70,7 @@ print_message (int nested, int edit)
{
grub_printf ("\n\
Use the %C and %C keys to select which entry is highlighted.\n",
(grub_uint32_t) DISP_UP, (grub_uint32_t) DISP_DOWN);
(grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
grub_printf ("\
Press enter to boot the selected OS, \'e\' to edit the\n\
commands before booting or \'c\' for a command-line.");
@ -165,23 +104,23 @@ print_entry (int y, int highlight, grub_menu_entry_t entry)
? GRUB_TERM_COLOR_HIGHLIGHT
: GRUB_TERM_COLOR_NORMAL);
grub_gotoxy (TERM_LEFT_BORDER_X + TERM_MARGIN, y);
grub_putchar (' ');
for (x = TERM_LEFT_BORDER_X + TERM_MARGIN + 1;
x < TERM_LEFT_BORDER_X + TERM_BORDER_WIDTH - TERM_MARGIN;
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN, y);
for (x = GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1;
x < GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - GRUB_TERM_MARGIN;
x++)
{
if (*title && x <= TERM_LEFT_BORDER_X + TERM_BORDER_WIDTH - TERM_MARGIN - 1)
if (*title && x <= GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - GRUB_TERM_MARGIN - 1)
{
if (x == TERM_LEFT_BORDER_X + TERM_BORDER_WIDTH - TERM_MARGIN - 1)
grub_putcode (DISP_RIGHT);
if (x == GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - GRUB_TERM_MARGIN - 1)
grub_putcode (GRUB_TERM_DISP_RIGHT);
else
grub_putchar (*title++);
}
else
grub_putchar (' ');
}
grub_gotoxy (TERM_CURSOR_X, y);
grub_gotoxy (GRUB_TERM_CURSOR_X, y);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
}
@ -192,49 +131,45 @@ print_entries (grub_menu_t menu, int first, int offset)
grub_menu_entry_t e;
int i;
grub_gotoxy (TERM_LEFT_BORDER_X + TERM_BORDER_WIDTH,
TERM_FIRST_ENTRY_Y);
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH,
GRUB_TERM_FIRST_ENTRY_Y);
if (first)
grub_putcode (DISP_UP);
grub_putcode (GRUB_TERM_DISP_UP);
else
grub_putchar (' ');
e = get_entry (menu, first);
for (i = 0; i < TERM_NUM_ENTRIES; i++)
for (i = 0; i < GRUB_TERM_NUM_ENTRIES; i++)
{
print_entry (TERM_FIRST_ENTRY_Y + i, offset == i, e);
print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, offset == i, e);
if (e)
e = e->next;
}
grub_gotoxy (TERM_LEFT_BORDER_X + TERM_BORDER_WIDTH,
TERM_TOP_BORDER_Y + TERM_NUM_ENTRIES);
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH,
GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES);
if (e)
grub_putcode (DISP_DOWN);
grub_putcode (GRUB_TERM_DISP_DOWN);
else
grub_putchar (' ');
grub_gotoxy (TERM_CURSOR_X, TERM_FIRST_ENTRY_Y + offset);
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
}
static void
init_page (int nested, int edit)
/* Initialize the screen. If NESTED is non-zero, assume that this menu
is run from another menu or a command-line. If EDIT is non-zero, show
a message for the menu entry editor. */
void
grub_menu_init_page (int nested, int edit)
{
grub_normal_init_page ();
draw_border ();
print_message (nested, edit);
}
/* Edit a menu entry with an Emacs-like interface. */
static void
edit_menu_entry (grub_menu_entry_t entry)
{
/* Not yet implemented. */
}
static int
run_menu (grub_menu_t menu, int nested)
{
@ -243,10 +178,10 @@ run_menu (grub_menu_t menu, int nested)
first = 0;
offset = menu->default_entry;
if (offset > TERM_NUM_ENTRIES - 1)
if (offset > GRUB_TERM_NUM_ENTRIES - 1)
{
first = offset - (TERM_NUM_ENTRIES - 1);
offset = TERM_NUM_ENTRIES - 1;
first = offset - (GRUB_TERM_NUM_ENTRIES - 1);
offset = GRUB_TERM_NUM_ENTRIES - 1;
}
/* Initialize the time. */
@ -254,7 +189,7 @@ run_menu (grub_menu_t menu, int nested)
refresh:
grub_setcursor (0);
init_page (nested, 0);
grub_menu_init_page (nested, 0);
print_entries (menu, first, offset);
grub_refresh ();
@ -273,13 +208,13 @@ run_menu (grub_menu_t menu, int nested)
saved_time = current_time;
}
grub_gotoxy (0, TERM_HEIGHT - 3);
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
/* NOTE: Do not remove the trailing space characters.
They are required to clear the line. */
grub_printf ("\
The highlighted entry will be booted automatically in %d seconds. ",
menu->timeout);
grub_gotoxy (TERM_CURSOR_X, TERM_FIRST_ENTRY_Y + offset);
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
grub_refresh ();
}
@ -292,12 +227,12 @@ run_menu (grub_menu_t menu, int nested)
if (menu->timeout >= 0)
{
grub_gotoxy (0, TERM_HEIGHT - 3);
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
grub_printf ("\
");
menu->timeout = -1;
menu->fallback_entry = -1;
grub_gotoxy (TERM_CURSOR_X, TERM_FIRST_ENTRY_Y + offset);
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
}
switch (c)
@ -306,10 +241,10 @@ run_menu (grub_menu_t menu, int nested)
case '^':
if (offset > 0)
{
print_entry (TERM_FIRST_ENTRY_Y + offset, 0,
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0,
get_entry (menu, first + offset));
offset--;
print_entry (TERM_FIRST_ENTRY_Y + offset, 1,
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1,
get_entry (menu, first + offset));
}
else if (first > 0)
@ -323,12 +258,12 @@ run_menu (grub_menu_t menu, int nested)
case 'v':
if (menu->size > first + offset + 1)
{
if (offset < TERM_NUM_ENTRIES - 1)
if (offset < GRUB_TERM_NUM_ENTRIES - 1)
{
print_entry (TERM_FIRST_ENTRY_Y + offset, 0,
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0,
get_entry (menu, first + offset));
offset++;
print_entry (TERM_FIRST_ENTRY_Y + offset, 1,
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1,
get_entry (menu, first + offset));
}
else
@ -354,12 +289,11 @@ run_menu (grub_menu_t menu, int nested)
break;
case 'c':
grub_setcursor (1);
grub_cmdline_run (1);
goto refresh;
case 'e':
edit_menu_entry (get_entry (menu, first + offset));
grub_menu_entry_run (get_entry (menu, first + offset));
goto refresh;
default:

1016
normal/menu_entry.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,44 @@ static int grub_console_attr = A_NORMAL;
static void
grub_ncurses_putchar (grub_uint32_t c)
{
/* Better than nothing. */
switch (c)
{
case GRUB_TERM_DISP_LEFT:
c = '<';
break;
case GRUB_TERM_DISP_UP:
c = '^';
break;
case GRUB_TERM_DISP_RIGHT:
c = '>';
break;
case GRUB_TERM_DISP_DOWN:
c = 'v';
break;
case GRUB_TERM_DISP_HLINE:
c = '-';
break;
case GRUB_TERM_DISP_VLINE:
c = '|';
break;
case GRUB_TERM_DISP_UL:
case GRUB_TERM_DISP_UR:
case GRUB_TERM_DISP_LL:
case GRUB_TERM_DISP_LR:
c = '+';
break;
default:
break;
}
addch (c | grub_console_attr);
}
@ -57,16 +95,46 @@ grub_ncurses_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
color_set (normal_color << 8 | highlight_color, 0);
}
static int saved_char = ERR;
static int
grub_ncurses_checkkey (void)
{
return 1;
int c;
/* Check for SAVED_CHAR. This should not be true, because this
means checkkey is called twice continuously. */
if (saved_char != ERR)
return 1;
wtimeout (stdscr, 100);
c = getch ();
/* If C is not ERR, then put it back in the input queue. */
if (c != ERR)
{
saved_char = c;
return 1;
}
return 0;
}
static int
grub_ncurses_getkey (void)
{
int c = getch ();
int c;
/* If checkkey has already got a character, then return it. */
if (saved_char != ERR)
{
c = saved_char;
saved_char = ERR;
}
else
{
wtimeout (stdscr, -1);
c = getch ();
}
switch (c)
{
@ -161,7 +229,7 @@ static grub_err_t
grub_ncurses_init (void)
{
initscr ();
cbreak ();
raw ();
noecho ();
scrollok (stdscr, TRUE);