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:
parent
e6b92c8afb
commit
4d4e372ebd
11 changed files with 1334 additions and 143 deletions
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue