Merge mainline into keylayouts

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-08-18 22:28:47 +02:00
commit 2cccf4b0c4
342 changed files with 46791 additions and 19202 deletions

View file

@ -38,6 +38,7 @@
#define GRUB_TERM_KEY_DC (GRUB_TERM_EXTENDED | 7)
#define GRUB_TERM_KEY_PPAGE (GRUB_TERM_EXTENDED | 8)
#define GRUB_TERM_KEY_NPAGE (GRUB_TERM_EXTENDED | 9)
/* Used by keylayouts code. Never returned in grub_getkey. */
#define GRUB_TERM_KEY_102 (GRUB_TERM_EXTENDED | 10)
#define GRUB_TERM_KEY_SHIFT_102 (GRUB_TERM_EXTENDED | 11)
@ -51,7 +52,8 @@
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/handler.h>
#include <grub/unicode.h>
#include <grub/list.h>
/* These are used to represent the various color states we use. */
typedef enum
@ -76,11 +78,25 @@ grub_term_color_state;
to NULL. */
/* Set when input characters shouldn't be echoed back. */
#define GRUB_TERM_NO_ECHO (1 << 0)
#define GRUB_TERM_NO_ECHO (1 << 0)
/* Set when the editing feature should be disabled. */
#define GRUB_TERM_NO_EDIT (1 << 1)
#define GRUB_TERM_NO_EDIT (1 << 1)
/* Set when the terminal cannot do fancy things. */
#define GRUB_TERM_DUMB (1 << 2)
#define GRUB_TERM_DUMB (1 << 2)
/* Which encoding does terminal expect stream to be. */
#define GRUB_TERM_CODE_TYPE_SHIFT 3
#define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT)
/* Only ASCII characters accepted. */
#define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT)
/* Expects CP-437 characters (ASCII + pseudographics). */
#define GRUB_TERM_CODE_TYPE_CP437 (1 << GRUB_TERM_CODE_TYPE_SHIFT)
/* UTF-8 stream in logical order. Usually used for terminals
which just forward the stream to another computer. */
#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
/* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints. */
#define GRUB_TERM_CODE_TYPE_UTF8_VISUAL (3 << GRUB_TERM_CODE_TYPE_SHIFT)
/* Glyph description in visual order. */
#define GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS (4 << GRUB_TERM_CODE_TYPE_SHIFT)
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
@ -88,20 +104,6 @@ grub_term_color_state;
#define GRUB_TERM_STATUS_CTRL (1 << 1)
#define GRUB_TERM_STATUS_ALT (1 << 2)
/* 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. */
/* The number of lines of "GRUB version..." at the top. */
@ -135,21 +137,23 @@ struct grub_term_input
const char *name;
/* Initialize the terminal. */
grub_err_t (*init) (void);
grub_err_t (*init) (struct grub_term_input *term);
/* Clean up the terminal. */
grub_err_t (*fini) (void);
grub_err_t (*fini) (struct grub_term_input *term);
/* Check if any input character is available. */
int (*checkkey) (void);
int (*checkkey) (struct grub_term_input *term);
/* Get a character. */
int (*getkey) (void);
int (*getkey) (struct grub_term_input *term);
/* Get keyboard modifier status. */
int (*getkeystatus) (void);
int (*getkeystatus) (struct grub_term_input *term);
grub_uint32_t flags;
void *data;
};
typedef struct grub_term_input *grub_term_input_t;
@ -166,52 +170,58 @@ struct grub_term_output
const char *name;
/* Initialize the terminal. */
grub_err_t (*init) (void);
grub_err_t (*init) (struct grub_term_output *term);
/* Clean up the terminal. */
grub_err_t (*fini) (void);
grub_err_t (*fini) (struct grub_term_output *term);
/* Put a character. C is encoded in Unicode. */
void (*putchar) (grub_uint32_t c);
void (*putchar) (struct grub_term_output *term,
const struct grub_unicode_glyph *c);
/* Get the number of columns occupied by a given character C. C is
encoded in Unicode. */
grub_ssize_t (*getcharwidth) (grub_uint32_t c);
grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
const struct grub_unicode_glyph *c);
/* Get the screen size. The return value is ((Width << 8) | Height). */
grub_uint16_t (*getwh) (void);
grub_uint16_t (*getwh) (struct grub_term_output *term);
/* Get the cursor position. The return value is ((X << 8) | Y). */
grub_uint16_t (*getxy) (void);
grub_uint16_t (*getxy) (struct grub_term_output *term);
/* Go to the position (X, Y). */
void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
void (*gotoxy) (struct grub_term_output *term,
grub_uint8_t x, grub_uint8_t y);
/* Clear the screen. */
void (*cls) (void);
void (*cls) (struct grub_term_output *term);
/* Set the current color to be used */
void (*setcolorstate) (grub_term_color_state state);
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
/* Get the normal color and the highlight color. The format of each
color is VGA's. */
void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
void (*setcolorstate) (struct grub_term_output *term,
grub_term_color_state state);
/* Turn on/off the cursor. */
void (*setcursor) (int on);
void (*setcursor) (struct grub_term_output *term, int on);
/* Update the screen. */
void (*refresh) (void);
void (*refresh) (struct grub_term_output *term);
/* The feature flags defined above. */
grub_uint32_t flags;
/* Current color state. */
grub_uint8_t normal_color;
grub_uint8_t highlight_color;
void *data;
};
typedef struct grub_term_output *grub_term_output_t;
#define GRUB_TERM_DEFAULT_NORMAL_COLOR 0x07
#define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
#define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled);
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled);
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
@ -227,11 +237,19 @@ grub_term_register_input (const char *name __attribute__ ((unused)),
else
{
/* If this is the first terminal, enable automatically. */
if (! term->init || term->init () == GRUB_ERR_NONE)
if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
}
}
static inline void
grub_term_register_input_active (const char *name __attribute__ ((unused)),
grub_term_input_t term)
{
if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
}
static inline void
grub_term_register_output (const char *name __attribute__ ((unused)),
grub_term_output_t term)
@ -242,12 +260,21 @@ grub_term_register_output (const char *name __attribute__ ((unused)),
else
{
/* If this is the first terminal, enable automatically. */
if (! term->init || term->init () == GRUB_ERR_NONE)
if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
GRUB_AS_LIST (term));
}
}
static inline void
grub_term_register_output_active (const char *name __attribute__ ((unused)),
grub_term_output_t term)
{
if (! term->init || term->init (term) == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
GRUB_AS_LIST (term));
}
static inline void
grub_term_unregister_input (grub_term_input_t term)
{
@ -264,18 +291,15 @@ grub_term_unregister_output (grub_term_output_t term)
GRUB_AS_LIST (term));
}
#define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next)
#define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next)
#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next)
#define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next)
#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
#define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled))
#define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
#define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
void EXPORT_FUNC(grub_putchar) (int c);
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,
struct grub_term_output *term);
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
extern int (*EXPORT_VAR(grub_getkey)) (void);
int grub_checkkey (void);
void EXPORT_FUNC(grub_cls) (void);
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
void grub_cls (void);
void EXPORT_FUNC(grub_refresh) (void);
void grub_puts_terminal (const char *str, struct grub_term_output *term);
grub_uint16_t *grub_term_save_pos (void);
@ -283,12 +307,12 @@ void grub_term_restore_pos (grub_uint16_t *pos);
static inline unsigned grub_term_width (struct grub_term_output *term)
{
return ((term->getwh()&0xFF00)>>8);
return ((term->getwh(term)&0xFF00)>>8);
}
static inline unsigned grub_term_height (struct grub_term_output *term)
{
return (term->getwh()&0xFF);
return (term->getwh(term)&0xFF);
}
/* The width of the border. */
@ -332,20 +356,20 @@ grub_term_cursor_x (struct grub_term_output *term)
static inline grub_uint16_t
grub_term_getxy (struct grub_term_output *term)
{
return term->getxy ();
return term->getxy (term);
}
static inline void
grub_term_refresh (struct grub_term_output *term)
{
if (term->refresh)
term->refresh ();
term->refresh (term);
}
static inline void
grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
{
term->gotoxy (x, y);
term->gotoxy (term, x, y);
}
static inline void
@ -353,17 +377,26 @@ grub_term_setcolorstate (struct grub_term_output *term,
grub_term_color_state state)
{
if (term->setcolorstate)
term->setcolorstate (state);
term->setcolorstate (term, state);
}
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
static inline void
grub_setcolorstate (grub_term_color_state state)
{
struct grub_term_output *term;
FOR_ACTIVE_TERM_OUTPUTS(term)
grub_term_setcolorstate (term, state);
}
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
static inline void
grub_term_setcolor (struct grub_term_output *term,
grub_uint8_t normal_color, grub_uint8_t highlight_color)
{
if (term->setcolor)
term->setcolor (normal_color, highlight_color);
term->normal_color = normal_color;
term->highlight_color = highlight_color;
}
/* Turn on/off the cursor. */
@ -371,14 +404,14 @@ static inline void
grub_term_setcursor (struct grub_term_output *term, int on)
{
if (term->setcursor)
term->setcursor (on);
term->setcursor (term, on);
}
static inline void
grub_term_cls (struct grub_term_output *term)
{
if (term->cls)
(term->cls) ();
(term->cls) (term);
else
{
grub_putcode ('\n', term);
@ -386,11 +419,36 @@ grub_term_cls (struct grub_term_output *term)
}
}
#ifdef HAVE_UNIFONT_WIDTHSPEC
grub_ssize_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
#else
static inline grub_ssize_t
grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused)))
{
if (grub_unicode_get_comb_type (c->base))
return 0;
return 1;
}
#endif
static inline grub_ssize_t
grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c)
grub_term_getcharwidth (struct grub_term_output *term,
const struct grub_unicode_glyph *c)
{
if (term->getcharwidth)
return term->getcharwidth (c);
return term->getcharwidth (term, c);
else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)
== GRUB_TERM_CODE_TYPE_UTF8_LOGICAL)
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
== GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
== GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS))
return grub_unicode_estimate_width (c);
else
return 1;
}
@ -399,17 +457,10 @@ static inline void
grub_term_getcolor (struct grub_term_output *term,
grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
{
if (term->getcolor)
term->getcolor (normal_color, highlight_color);
else
{
*normal_color = 0x07;
*highlight_color = 0x07;
}
*normal_color = term->normal_color;
*highlight_color = term->highlight_color;
}
extern void (*EXPORT_VAR (grub_newline_hook)) (void);
struct grub_term_autoload
{
struct grub_term_autoload *next;