Bidi and diacritics support.
* Makefile.in (widthspec.bin): New target. (widthspec.h): Likewise. (TARGET_CFLAGS): Add -DHAVE_UNIFONT_WIDTHSPEC=1 if font was available. * autogen.sh: Generate unidata.c. * commands/cat.c (grub_cmd_cat): Don't use grub_putchar. * commands/ls.c (grub_ls_list_devices): Likewise. (grub_ls_list_files): Likewise. * commands/minicmd.c (grub_mini_cmd_cat): Likewise. (grub_mini_cmd_lsmod): Likewise. * commands/read.c: Likewise. * kern/corecmd.c (grub_core_cmd_ls): Likewise. * kern/rescue_reader.c (grub_rescue_read_line): Likewise. * lib/arg.c (grub_arg_show_help): Likewise. * lib/crypto.c (grub_password_get): Likewise. * normal/auth.c (grub_username_get): Likewise. * normal/misc.c (grub_normal_print_device_info): Likewise. * commands/help.c (grub_cmd_help): Use grub_unicode_aglomerate_comb. * conf/common.rmk (grub_mkfont_SOURCES): Add unidata.c. (gfxmenu_mod_SOURCES): Add gfxmenu/font.c. (normal/charset.c_DEPENDENCIES): New variable. (normal_mod_SOURCES): Add normal/charset.c and unidata.c. (pkglib_MODULES): Remove charset.mod. (charset_mod_SOURCES): Removed. (charset_mod_CFLAGS): Likewise. (charset_mod_LDFLAGS): Likewise. (pkglib_MODULES) [ieee1275]: Remove terminfo.mod. * conf/powerpc-ieee1275.rmk (kernel_img_SOURCES): Add term/terminfo.c and term/tparm.c. * conf/sparc64-ieee1275.rmk (kernel_img_SOURCES): Likewise. * conf/i386-ieee1275.rmk (kernel_img_SOURCES): Likewise. (kernel_img_HEADERS): Add terminfo.h. * font/font.c (ascii_glyph_lookup): Return NULL on failure. Fill ->font. Reverse ascii bitmaps. (grub_font_get_xheight): New function. * font/font.c (grub_font_get_string_width): Moved from here ... * gfxmenu/font.c (grub_font_get_string_width): ... here. * font/font.c (grub_font_draw_string): Moved from here ... * gfxmenu/font.c (grub_font_draw_string): ... here. * font/font.c (grub_font_dup_glyph): New function. (grub_font_blit_glyph): Likewise. (grub_font_blit_glyph_mirror): Likewise. (blit_comb): Likewise. (grub_font_construct_dry_run): Likewise. (grub_font_get_constructed_device_width): Likewise. (grub_font_construct_glyph): Likewise. * include/grub/charset.h (grub_ucs4_to_utf8): New proto. * include/grub/misc.h (grub_utf8_to_ucs4): Moved from here ... * include/grub/charset.h (grub_utf8_to_ucs4): ... here. * include/grub/font.h (GRUB_FONT_CODE_CHAR_MASK): New constant. (GRUB_FONT_CODE_RIGHT_JOINED): Likewise. (GRUB_FONT_CODE_LEFT_JOINED): Likewise. (grub_font_get_xheight): New proto. (grub_font_get_constructed_device_width): Likewise. (grub_font_construct_glyph): Likewise. * include/grub/font.h (grub_font_get_string_width): Moved from here ... * include/grub/gfxmenu_view.h (grub_font_get_string_width): ... here. * include/grub/font.h (grub_font_draw_string): Moved from here ... * include/grub/gfxmenu_view.h (grub_font_draw_string): ... here. * include/grub/i386/vga_common.h (grub_console_putchar): Moved from here.. * include/grub/i386/pc/console.h (grub_console_putchar): ... here. * include/grub/i386/vga_common.h (grub_console_real_putchar): Removed. (grub_console_getcharwidth): Likewise. * include/grub/misc.h (grub_xputs): New proto. (grub_puts): Inlined. * include/grub/normal.h (grub_print_ucs4): Add margin specification. (grub_normal_get_line_counter): Removed. (grub_install_newline_hook): Likewise. (grub_normal_get_char_counter): New proto. (grub_normal_reset_more): Likewise. (grub_xputs_normal): Likewise. * include/grub/powerpc/ieee1275/console.h: Removed. * include/grub/sparc64/ieee1275/console.h: Likewise. * include/grub/term.h (GRUB_TERM_CODE_TYPE_MASK): New definition. (GRUB_TERM_CODE_TYPE_ASCII): Likewise. (GRUB_TERM_CODE_TYPE_CP437): Likewise. (GRUB_TERM_CODE_TYPE_UTF8_LOGICAL): Likewise. (GRUB_TERM_CODE_TYPE_UTF8_VISUAL): Likewise. (GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS): Likewise. (grub_term_input): Pass reference to self. All users updated. (grub_term_output): Pass grub_unicode_glyph to putchar and getcharwidth. Pass reference to self. New fields normal_color, highlight_color and data. All users updated. (grub_putchar): Removed. (grub_putcode): Remove EXPORT_FUNC since it's not in kernel anymore. (grub_unicode_estimate_width): New function. (grub_term_getcharwidth): Add defaults. (GRUB_TERM_DEFAULT_NORMAL_COLOR): New definition. (GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR): Likewise. (GRUB_TERM_DEFAULT_STANDARD_COLOR): Likewise. (grub_cls): Remove EXPORT_FUNC. (grub_setcolorstate): Inline. (grub_newline_hook): Removed. * include/grub/terminfo.h: Rewritten. All users updated. * include/grub/unicode.h: New file. * include/grub/video.h (grub_video_signed_rect): New type. * kern/emu/console.c (grub_console_highlight_color): Removed. (grub_console_normal_color): Likewise. (grub_console_standard_color): Made static. (grub_ncurses_putchar): Remove mapping. (grub_ncurses_getcharwidth): Removed. (grub_ncurses_term_output): Declare as GRUB_TERM_CODE_TYPE_ASCII. (grub_ncurses_setcolor): Removed. (grub_ncurses_getcolor): Likewise. * kern/i386/pc/startup.S (grub_console_real_putchar): Renamed to ... (grub_console_putchar): ... this. (grub_console_putchar): Handle argument difference. * kern/ieee1275/init.c (grub_machine_init): Split console_init into console_init_early and console_init_lately. * kern/sparc64/ieee1275/init.c (grub_machine_init): Likewise. * kern/misc.c (grub_puts): Removed. (grub_vprintf): Store UTF-8 string instead of outputting it directly. (grub_vsnprintf_real): Remove str = NULL support. * kern/misc.c (grub_utf8_to_ucs4): Move from here ... * normal/charset.c (grub_utf8_to_ucs4): ... here. * kern/term.c (grub_putcode): Renamed to ... (grub_putcode_dumb): ... this. Pass grub_unicode_glyph instead of code. (grub_putchar): Removed. (grub_xputs_dumb): New function. (grub_xputs): New variable. * lib/charset.c: Move from here ... * normal/charset.c: ... to here. (grub_ucs4_to_utf8): New function. (grub_ucs4_to_utf8_alloc): Use grub_ucs4_to_utf8. (join_types): New variable. (unpack_join): New function. (bidi_types): New variable. (unpack_bidi): New function. (get_bidi_type): Likewise. (get_join_type): Likewise. (is_mirrored): Likewise. (grub_unicode_get_comb_type): Likewise. (grub_unicode_estimate_width) [HAVE_UNIFONT_WIDTHSPEC]: Likewise. (is_type_after): Likewise. (grub_unicode_aglomerate_comb): Likewise. (bidi_line_wrap): Likewise. (grub_bidi_line_logical_to_visual): Likewise. (grub_bidi_logical_to_visual): Likewise. (grub_unicode_mirror_code): Likewise. (grub_unicode_shape_code): Likewise. * normal/cmdline.c (grub_cmdline_get): Reset more counter. Don't use grub_putchar. * normal/main.c (grub_normal_init_page): Use grub_putcode. (grub_normal_reader_init): Likewise. (grub_xputs_saved): New variable. (GRUB_MOD_INIT): Set grub_xputs. (GRUB_MOD_FINI): Restore grub_xputs. * normal/menu.c (grub_wait_after_message): Don't use grub_putchar. (menu_init): Avoid printing gfxmenu error. (show_menu): Use grub_normal_get_char_counter. * normal/menu_entry.c (update_screen): Fix out-of-array. (complete): Avoid NULL dereferencing. * grub_menu_entry_run (grub_menu_entry_run): Don't use putchar. * normal/menu_text.c (print_spaces): Removed. (grub_print_ucs4): Likewise. (grub_print_message_indented): Use grub_print_ucs4. (print_message): Use grub_putcode. (print_entry): Hanlde diacritics. * normal/term.c (term_state): New type. (grub_more_lines): Removed. (term_states): New variable. (grub_normal_line_counter): Renamed to .. (grub_normal_char_counter): ...this. All users updated. (grub_normal_get_line_counter): Renamed to ... (grub_normal_get_char_counter): ... this. (grub_normal_reset_more): New function. (process_newline): Removed. (print_more): New function. (grub_install_newline_hook): Removed. (map_code): New function. (grub_puts_terminal): Use grub_print_ucs4. (putglyph): New function. (putcode_real): Likewise. (grub_putcode): Use putcode_real. (get_maxwidth): New function. (get_startwidth): Likewise. (print_ucs4_terminal): Likewise. (find_term_state): Likewise. (put_glyphs_terminal): Likewise. (print_backlog): Likewise. (print_ucs4_real): Likewise. (grub_print_ucs4): Likewise. (grub_xputs_normal): Likewise. * term/efi/console.c (grub_console_putchar): Output diacritics. (grub_console_getcharwidth): Removed. (grub_console_term_output): Declare as GRUB_TERM_CODE_TYPE_UCS4_VISUAL. * term/gfxterm.c (clear_char): Free chars. (scroll_up): Avoid leaking memory. (grub_gfxterm_putchar): Support diacritics. (grub_video_term): Declare as GRUB_TERM_CODE_TYPE_UCS4_VISUAL. * term/i386/pc/console.c (grub_console_term_output): Declare as GRUB_TERM_CODE_TYPE_VGA. * term/i386/pc/vga.c (grub_vga_term): Declare as GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS. * term/i386/pc/vga_text.c (grub_vga_text_term): Declare as GRUB_TERM_CODE_TYPE_VGA. * term/i386/vga_common.c (map_char): Removed. (grub_console_putchar): Likewise. (grub_console_getcharwidth): Likewise. * term/ieee1275/ofconsole.c: Simplify using terminfo. (colors): Reordered to match terminfo. (grub_ofconsole_normal_color): Removed. (grub_ofconsole_writeesc): Likewise. (grub_ofconsole_highlight_color): Likewise. (grub_ofconsole_getcharwidth): Likewise. (grub_ofconsole_setcolorstate): Likewise. (grub_ofconsole_setcolor): Likewise. (grub_ofconsole_getcolor): Likewise. (grub_ofconsole_readkey): Renamed to ... (readkey): ... this. Remove escape sequence handling. Return -1 on no key. (grub_ofconsole_checkkey): Removed. (grub_ofconsole_getkey): Likewise. (grub_ofconsole_getxy): Likewise. (grub_ofconsole_gotoxy): Likewise. (grub_ofconsole_cls): Likewise. (grub_ofconsole_refresh): Likewise. (grub_ofconsole_terminfo_input): New struct. (grub_ofconsole_terminfo_output): Likewise. (grub_ofconsole_term_input): Use terminfo. (grub_ofconsole_term_output): Likewise. (grub_console_init): Split into ... (grub_console_init_early): ...this and ... (grub_console_init_lately): ...this. Use terminfo. (grub_ofconsole_putchar): Renamed to ... (put): ... this. Remove mapping. (grub_ofconsole_term_output): Declare as GRUB_TERM_CODE_TYPE_ASCII. * term/serial.c: Simplify using terminfo. (xpos): Removed. (ypos): Likewise. (keep_track): Likewise. (registered): Likewise. (input_buf): Likewise. (npending): Likewise. (serial_translate_key_sequence): Likewise. (fill_input_buf): Likewise. (grub_serial_checkkey): Likewise. (grub_serial_getkey): Likewise. (grub_serial_getxy): Likewise. (grub_serial_gotoxy): Likewise. (grub_serial_putchar): Likewise. (grub_serial_cls): Likewise. (grub_serial_setcolorstate): Likewise. (grub_serial_setcursor): Likewise. (serial_hw_init): Use serial_hw_fetch. (grub_serial_terminfo_input): New variable. (grub_serial_terminfo_output): Likewise. (grub_serial_term_input): Use terminfo. (grub_serial_term_output): Likewise. * term/terminfo.c (putstr): Use put. (grub_terminfo_all_free): New function (grub_terminfo_set_current): New types vt100-color, ieee1275 and dumb. (grub_terminfo_output_register): New function. (grub_terminfo_output_unregister): Likewise. (grub_terminfo_getxy): Likewise. (grub_terminfo_readkey): Likewise. (grub_terminfo_checkkey): Likewise. (grub_terminfo_getkey): Likewise. (grub_terminfo_input_init): Likewise. (print_terminfo): Likewise. (grub_cmd_terminfo): Handle encoding. (grub_terminfo_gotoxy): Track position. (grub_terminfo_cls): Likewise. (grub_terminfo_putchar): Likewise. (grub_terminfo_setcolorstate): Handle colors (grub_terminfo_cursor_on): This ... (grub_terminfo_cursor_off): ... and this merged into ... (grub_terminfo_setcursor): ... this. * term/tparm.c (grub_terminfo_tparm): Avoid NULL dereferencing. * unicode/ArabicShaping.txt: New file (imported from Unicode). * unicode/BidiMirroring.txt: Likewise. * unicode/UnicodeData.txt: Likewise. * unicode/COPYING: Likewise. * util/grub-editenv.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/grub-fstest.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/grub-mkdevicemap.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/grub-probe.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/grub-script-check.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/i386/pc/grub-setup.c (grub_putchar): Removed. (grub_xputs_real): New function. (grub_xputs): New variable. * util/import_unicode.py: New file. * util/grub-mkfont.c (ft_errmsgs): New array. (grub_glyph_info): Make bitmap a pointer. (file_formats): New type WIDTH_SPEC. (grub_font_info): New members glyphs_unsorted, glyphs_sorted, num_glyphs. (options): Add width-spec. (help): Likewise. (add_char): Renamed to ... (add_glyph): ... this. (add_glyph): Use index. Show freetype errors. Cut blank space at borders. (glyph_replace): New type. (subst_rightjoin), (subst_leftjoin), (subst_medijoin): New variables. (add_char): New function. (add_subst): Likewise. (process_cursive): Likewise. (add_font): Handle GSUB. (write_font_width_spec): New function. (main): Sort glyphs. * commands/minicmd.c (grub_mini_cmd_clear): Moved from here ... * normal/main.c (grub_mini_cmd_clear): ..here. All users updated. * kern/term.c (grub_cls): Moved from here... * normal/term.c (grub_cls): ... here.
This commit is contained in:
commit
df3eb88f04
76 changed files with 28013 additions and 2141 deletions
|
@ -117,5 +117,11 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
|||
|
||||
int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
void
|
||||
grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
||||
grub_uint8_t *dest, grub_size_t destsize);
|
||||
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/unicode.h>
|
||||
|
||||
/* Forward declaration of opaque structure grub_font.
|
||||
Users only pass struct grub_font pointers to the font module functions,
|
||||
|
@ -69,6 +70,11 @@ struct grub_font_glyph
|
|||
grub_uint8_t bitmap[0];
|
||||
};
|
||||
|
||||
/* Part of code field which is really used as such. */
|
||||
#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
|
||||
#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
|
||||
#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
|
||||
|
||||
/* Initialize the font loader.
|
||||
Must be called before any fonts are loaded or used. */
|
||||
void grub_font_loader_init (void);
|
||||
|
@ -97,8 +103,7 @@ int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
|
|||
|
||||
int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
|
||||
|
||||
int EXPORT_FUNC (grub_font_get_string_width) (grub_font_t font,
|
||||
const char *str);
|
||||
int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
|
||||
|
||||
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
|
||||
grub_uint32_t code);
|
||||
|
@ -110,9 +115,11 @@ grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
|
|||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
|
||||
grub_err_t EXPORT_FUNC (grub_font_draw_string) (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int
|
||||
EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
|
||||
const struct grub_unicode_glyph *glyph_id);
|
||||
struct grub_font_glyph *
|
||||
EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
|
||||
const struct grub_unicode_glyph *glyph_id);
|
||||
|
||||
#endif /* ! GRUB_FONT_HEADER */
|
||||
|
|
|
@ -62,6 +62,14 @@ grub_gfxmenu_print_timeout (int timeout, void *data);
|
|||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data);
|
||||
|
||||
grub_err_t grub_font_draw_string (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int grub_font_get_string_width (grub_font_t font,
|
||||
const char *str);
|
||||
|
||||
|
||||
/* Implementation details -- this should not be used outside of the
|
||||
view itself. */
|
||||
|
||||
|
|
|
@ -40,12 +40,15 @@
|
|||
#include <grub/i386/vga_common.h>
|
||||
|
||||
/* These are global to share code between C and asm. */
|
||||
int grub_console_checkkey (void);
|
||||
int grub_console_getkey (void);
|
||||
grub_uint16_t grub_console_getxy (void);
|
||||
void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y);
|
||||
void grub_console_cls (void);
|
||||
void grub_console_setcursor (int on);
|
||||
int grub_console_checkkey (struct grub_term_input *term);
|
||||
int grub_console_getkey (struct grub_term_input *term);
|
||||
grub_uint16_t grub_console_getxy (struct grub_term_output *term);
|
||||
void grub_console_gotoxy (struct grub_term_output *term,
|
||||
grub_uint8_t x, grub_uint8_t y);
|
||||
void grub_console_cls (struct grub_term_output *term);
|
||||
void grub_console_setcursor (struct grub_term_output *term, int on);
|
||||
void grub_console_putchar (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
|
|
|
@ -25,16 +25,8 @@
|
|||
|
||||
extern grub_uint8_t grub_console_cur_color;
|
||||
|
||||
void grub_console_putchar (grub_uint32_t c);
|
||||
grub_ssize_t grub_console_getcharwidth (grub_uint32_t c);
|
||||
grub_uint16_t grub_console_getwh (void);
|
||||
void grub_console_setcolorstate (grub_term_color_state state);
|
||||
void grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color);
|
||||
void grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
|
||||
|
||||
/* Implemented in both kern/i386/pc/startup.S and vga_text.c; this symbol
|
||||
is not exported, so there's no collision, but vga_common.c expects this
|
||||
prototype to be the same. */
|
||||
void grub_console_real_putchar (int c);
|
||||
grub_uint16_t grub_console_getwh (struct grub_term_output *term);
|
||||
void grub_console_setcolorstate (struct grub_term_output *term,
|
||||
grub_term_color_state state);
|
||||
|
||||
#endif /* ! GRUB_VGA_COMMON_CPU_HEADER */
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include <grub/symbol.h>
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
void grub_console_init_early (void);
|
||||
void grub_console_init_lately (void);
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
|
@ -237,7 +237,19 @@ void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
|||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_puts) (const char *s);
|
||||
|
||||
extern void (*EXPORT_VAR (grub_xputs)) (const char *str);
|
||||
|
||||
static inline int
|
||||
grub_puts (const char *s)
|
||||
{
|
||||
const char nl[2] = "\n";
|
||||
grub_xputs (s);
|
||||
grub_xputs (nl);
|
||||
|
||||
return 1; /* Cannot fail. */
|
||||
}
|
||||
|
||||
int EXPORT_FUNC(grub_puts_) (const char *s);
|
||||
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||
const int line,
|
||||
|
@ -253,11 +265,6 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
|
|||
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args);
|
||||
void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
|
||||
void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
|
||||
grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest,
|
||||
grub_size_t destsize,
|
||||
const grub_uint8_t *src,
|
||||
grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
||||
grub_uint32_t d, grub_uint32_t *r);
|
||||
|
||||
|
|
|
@ -77,9 +77,11 @@ void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
|
|||
|
||||
/* Defined in `menu_text.c'. */
|
||||
void grub_wait_after_message (void);
|
||||
void grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
void
|
||||
grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
int margin_left, int margin_right,
|
||||
struct grub_term_output *term);
|
||||
grub_ssize_t grub_getstringwidth (grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
|
@ -110,7 +112,9 @@ void read_terminal_list (const char *prefix);
|
|||
|
||||
void grub_set_more (int onoff);
|
||||
|
||||
int grub_normal_get_line_counter (void);
|
||||
void grub_install_newline_hook (void);
|
||||
int grub_normal_get_char_counter (void);
|
||||
void grub_normal_reset_more (void);
|
||||
|
||||
void grub_xputs_normal (const char *str);
|
||||
|
||||
#endif /* ! GRUB_NORMAL_HEADER */
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,2005,2007 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_CONSOLE_MACHINE_HEADER
|
||||
#define GRUB_CONSOLE_MACHINE_HEADER 1
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
||||
|
||||
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,2005,2007 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_CONSOLE_MACHINE_HEADER
|
||||
#define GRUB_CONSOLE_MACHINE_HEADER 1
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
||||
|
||||
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
|
|
@ -38,6 +38,7 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/unicode.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
/* These are used to represent the various color states we use. */
|
||||
|
@ -63,11 +64,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. */
|
||||
|
@ -75,20 +90,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. */
|
||||
|
@ -122,19 +123,21 @@ 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);
|
||||
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_term_input *grub_term_input_t;
|
||||
|
||||
|
@ -147,52 +150,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);
|
||||
|
@ -208,7 +217,7 @@ 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));
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +226,7 @@ static inline void
|
|||
grub_term_register_input_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -231,7 +240,7 @@ 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));
|
||||
}
|
||||
|
@ -241,7 +250,7 @@ static inline void
|
|||
grub_term_register_output_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
@ -267,14 +276,11 @@ grub_term_unregister_output (grub_term_output_t term)
|
|||
#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);
|
||||
int EXPORT_FUNC(grub_getkey) (void);
|
||||
int EXPORT_FUNC(grub_checkkey) (void);
|
||||
int EXPORT_FUNC(grub_getkeystatus) (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);
|
||||
|
@ -282,12 +288,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. */
|
||||
|
@ -331,20 +337,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
|
||||
|
@ -352,17 +358,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. */
|
||||
|
@ -370,14 +385,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);
|
||||
|
@ -385,11 +400,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;
|
||||
}
|
||||
|
@ -398,17 +438,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;
|
||||
|
|
|
@ -23,15 +23,55 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
char *grub_terminfo_get_current (void);
|
||||
grub_err_t grub_terminfo_set_current (const char *);
|
||||
char *EXPORT_FUNC(grub_terminfo_get_current) (struct grub_term_output *term);
|
||||
grub_err_t EXPORT_FUNC(grub_terminfo_set_current) (struct grub_term_output *term,
|
||||
const char *);
|
||||
|
||||
void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y,
|
||||
grub_term_output_t oterm);
|
||||
void grub_terminfo_cls (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_off (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_off (grub_term_output_t oterm);
|
||||
#define GRUB_TERMINFO_READKEY_MAX_LEN 4
|
||||
struct grub_terminfo_input_state
|
||||
{
|
||||
int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN];
|
||||
int npending;
|
||||
int (*readkey) (void);
|
||||
};
|
||||
|
||||
struct grub_terminfo_output_state
|
||||
{
|
||||
struct grub_term_output *next;
|
||||
|
||||
char *name;
|
||||
|
||||
char *gotoxy;
|
||||
char *cls;
|
||||
char *reverse_video_on;
|
||||
char *reverse_video_off;
|
||||
char *cursor_on;
|
||||
char *cursor_off;
|
||||
char *setcolor;
|
||||
|
||||
unsigned int xpos, ypos;
|
||||
|
||||
void (*put) (const int c);
|
||||
};
|
||||
|
||||
void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,
|
||||
grub_uint8_t x, grub_uint8_t y);
|
||||
void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term);
|
||||
grub_uint16_t EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term);
|
||||
void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term,
|
||||
const int on);
|
||||
void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
|
||||
const grub_term_color_state state);
|
||||
|
||||
|
||||
int EXPORT_FUNC (grub_terminfo_checkkey) (struct grub_term_input *term);
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term);
|
||||
int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
|
||||
void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term,
|
||||
const char *type);
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_output_unregister) (struct grub_term_output *term);
|
||||
|
||||
#endif /* ! GRUB_TERMINFO_HEADER */
|
||||
|
|
272
include/grub/unicode.h
Normal file
272
include/grub/unicode.h
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_BIDI_HEADER
|
||||
#define GRUB_BIDI_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
struct grub_unicode_bidi_pair
|
||||
{
|
||||
grub_uint32_t key;
|
||||
grub_uint32_t replace;
|
||||
};
|
||||
|
||||
struct grub_unicode_compact_range
|
||||
{
|
||||
grub_uint32_t start:21;
|
||||
grub_uint32_t end:21;
|
||||
grub_uint8_t bidi_type:5;
|
||||
grub_uint8_t comb_type;
|
||||
grub_uint8_t bidi_mirror:1;
|
||||
grub_uint8_t join_type:3;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Old-style Arabic shaping. Used for "visual UTF-8" and
|
||||
in grub-mkfont to find variant glyphs in absence of GPOS tables. */
|
||||
struct grub_unicode_arabic_shape
|
||||
{
|
||||
grub_uint32_t code;
|
||||
grub_uint32_t isolated;
|
||||
grub_uint32_t right_linked;
|
||||
grub_uint32_t both_linked;
|
||||
grub_uint32_t left_linked;
|
||||
};
|
||||
|
||||
extern struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[];
|
||||
|
||||
enum grub_bidi_type
|
||||
{
|
||||
GRUB_BIDI_TYPE_L = 0,
|
||||
GRUB_BIDI_TYPE_LRE,
|
||||
GRUB_BIDI_TYPE_LRO,
|
||||
GRUB_BIDI_TYPE_R,
|
||||
GRUB_BIDI_TYPE_AL,
|
||||
GRUB_BIDI_TYPE_RLE,
|
||||
GRUB_BIDI_TYPE_RLO,
|
||||
GRUB_BIDI_TYPE_PDF,
|
||||
GRUB_BIDI_TYPE_EN,
|
||||
GRUB_BIDI_TYPE_ES,
|
||||
GRUB_BIDI_TYPE_ET,
|
||||
GRUB_BIDI_TYPE_AN,
|
||||
GRUB_BIDI_TYPE_CS,
|
||||
GRUB_BIDI_TYPE_NSM,
|
||||
GRUB_BIDI_TYPE_BN,
|
||||
GRUB_BIDI_TYPE_B,
|
||||
GRUB_BIDI_TYPE_S,
|
||||
GRUB_BIDI_TYPE_WS,
|
||||
GRUB_BIDI_TYPE_ON
|
||||
};
|
||||
|
||||
enum grub_join_type
|
||||
{
|
||||
GRUB_JOIN_TYPE_NONJOINING = 0,
|
||||
GRUB_JOIN_TYPE_LEFT = 1,
|
||||
GRUB_JOIN_TYPE_RIGHT = 2,
|
||||
GRUB_JOIN_TYPE_DUAL = 3,
|
||||
GRUB_JOIN_TYPE_CAUSING = 4,
|
||||
GRUB_JOIN_TYPE_TRANSPARENT = 5
|
||||
};
|
||||
|
||||
enum grub_comb_type
|
||||
{
|
||||
GRUB_UNICODE_COMB_NONE = 0,
|
||||
GRUB_UNICODE_COMB_OVERLAY = 1,
|
||||
GRUB_UNICODE_COMB_HEBREW_SHEVA = 10,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL = 11,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH = 12,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS = 13,
|
||||
GRUB_UNICODE_COMB_HEBREW_HIRIQ = 14,
|
||||
GRUB_UNICODE_COMB_HEBREW_TSERE = 15,
|
||||
GRUB_UNICODE_COMB_HEBREW_SEGOL = 16,
|
||||
GRUB_UNICODE_COMB_HEBREW_PATAH = 17,
|
||||
GRUB_UNICODE_COMB_HEBREW_QAMATS = 18,
|
||||
GRUB_UNICODE_COMB_HEBREW_HOLAM = 19,
|
||||
GRUB_UNICODE_COMB_HEBREW_QUBUTS = 20,
|
||||
GRUB_UNICODE_COMB_HEBREW_DAGESH = 21,
|
||||
GRUB_UNICODE_COMB_HEBREW_METEG = 22,
|
||||
GRUB_UNICODE_COMB_HEBREW_RAFE = 23,
|
||||
GRUB_UNICODE_COMB_HEBREW_SHIN_DOT = 24,
|
||||
GRUB_UNICODE_COMB_HEBREW_SIN_DOT = 25,
|
||||
GRUB_UNICODE_COMB_HEBREW_VARIKA = 26,
|
||||
GRUB_UNICODE_COMB_ARABIC_FATHATAN = 27,
|
||||
GRUB_UNICODE_COMB_ARABIC_DAMMATAN = 28,
|
||||
GRUB_UNICODE_COMB_ARABIC_KASRATAN = 29,
|
||||
GRUB_UNICODE_COMB_ARABIC_FATHAH = 30,
|
||||
GRUB_UNICODE_COMB_ARABIC_DAMMAH = 31,
|
||||
GRUB_UNICODE_COMB_ARABIC_KASRA = 32,
|
||||
GRUB_UNICODE_COMB_ARABIC_SHADDA = 33,
|
||||
GRUB_UNICODE_COMB_ARABIC_SUKUN = 34,
|
||||
GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF = 35,
|
||||
GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH = 36,
|
||||
GRUB_UNICODE_STACK_ATTACHED_BELOW = 202,
|
||||
GRUB_UNICODE_STACK_ATTACHED_ABOVE = 214,
|
||||
GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT = 216,
|
||||
GRUB_UNICODE_STACK_BELOW = 220,
|
||||
GRUB_UNICODE_COMB_BELOW_RIGHT = 222,
|
||||
GRUB_UNICODE_COMB_ABOVE_LEFT = 228,
|
||||
GRUB_UNICODE_STACK_ABOVE = 230,
|
||||
GRUB_UNICODE_COMB_ABOVE_RIGHT = 232,
|
||||
GRUB_UNICODE_COMB_YPOGEGRAMMENI = 240,
|
||||
/* If combining nature is indicated only by class and
|
||||
not "combining type". */
|
||||
GRUB_UNICODE_COMB_ME = 253,
|
||||
GRUB_UNICODE_COMB_MC = 254,
|
||||
GRUB_UNICODE_COMB_MN = 255,
|
||||
};
|
||||
|
||||
/* This structure describes a glyph as opposed to character. */
|
||||
struct grub_unicode_glyph
|
||||
{
|
||||
grub_uint32_t base;
|
||||
grub_uint16_t variant:9;
|
||||
grub_uint8_t attributes:5;
|
||||
grub_size_t ncomb;
|
||||
struct grub_unicode_combining {
|
||||
grub_uint32_t code;
|
||||
enum grub_comb_type type;
|
||||
} *combining;
|
||||
/* Hint by unicode subsystem how wide this character usually is.
|
||||
Real width is determined by font. Set only in UTF-8 stream. */
|
||||
int estimated_width;
|
||||
};
|
||||
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT 1
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED 0x2
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
|
||||
<< GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
|
||||
/* Set iff the corresponding joining flags come from ZWJ or ZWNJ. */
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT 0x8
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
|
||||
<< GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT)
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_UNICODE_COMBINING_GRAPHEME_JOINER = 0x034f,
|
||||
GRUB_UNICODE_HEBREW_WAW = 0x05d5,
|
||||
GRUB_UNICODE_ARABIC_START = 0x0600,
|
||||
GRUB_UNICODE_ARABIC_END = 0x0700,
|
||||
GRUB_UNICODE_THAANA_ABAFILI = 0x07a6,
|
||||
GRUB_UNICODE_THAANA_AABAAFILI = 0x07a7,
|
||||
GRUB_UNICODE_THAANA_IBIFILI = 0x07a8,
|
||||
GRUB_UNICODE_THAANA_EEBEEFILI = 0x07a9,
|
||||
GRUB_UNICODE_THAANA_UBUFILI = 0x07aa,
|
||||
GRUB_UNICODE_THAANA_OOBOOFILI = 0x07ab,
|
||||
GRUB_UNICODE_THAANA_EBEFILI = 0x07ac,
|
||||
GRUB_UNICODE_THAANA_EYBEYFILI = 0x07ad,
|
||||
GRUB_UNICODE_THAANA_OBOFILI = 0x07ae,
|
||||
GRUB_UNICODE_THAANA_OABOAFILI = 0x07af,
|
||||
GRUB_UNICODE_THAANA_SUKUN = 0x07b0,
|
||||
GRUB_UNICODE_ZWNJ = 0x200c,
|
||||
GRUB_UNICODE_ZWJ = 0x200d,
|
||||
GRUB_UNICODE_LEFTARROW = 0x2190,
|
||||
GRUB_UNICODE_UPARROW = 0x2191,
|
||||
GRUB_UNICODE_RIGHTARROW = 0x2192,
|
||||
GRUB_UNICODE_DOWNARROW = 0x2193,
|
||||
GRUB_UNICODE_LIGHT_HLINE = 0x2500,
|
||||
GRUB_UNICODE_HLINE = 0x2501,
|
||||
GRUB_UNICODE_LIGHT_VLINE = 0x2502,
|
||||
GRUB_UNICODE_VLINE = 0x2503,
|
||||
GRUB_UNICODE_LIGHT_CORNER_UL = 0x250c,
|
||||
GRUB_UNICODE_CORNER_UL = 0x250f,
|
||||
GRUB_UNICODE_LIGHT_CORNER_UR = 0x2510,
|
||||
GRUB_UNICODE_CORNER_UR = 0x2513,
|
||||
GRUB_UNICODE_LIGHT_CORNER_LL = 0x2514,
|
||||
GRUB_UNICODE_CORNER_LL = 0x2517,
|
||||
GRUB_UNICODE_LIGHT_CORNER_LR = 0x2518,
|
||||
GRUB_UNICODE_CORNER_LR = 0x251b,
|
||||
GRUB_UNICODE_BLACK_UP_TRIANGLE = 0x25b2,
|
||||
GRUB_UNICODE_BLACK_RIGHT_TRIANGLE = 0x25ba,
|
||||
GRUB_UNICODE_BLACK_DOWN_TRIANGLE = 0x25bc,
|
||||
GRUB_UNICODE_BLACK_LEFT_TRIANGLE = 0x25c4,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_1 = 0xfe00,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_16 = 0xfe0f,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_17 = 0xe0100,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_256 = 0xe01ef
|
||||
};
|
||||
|
||||
extern struct grub_unicode_compact_range grub_unicode_compact[];
|
||||
extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
|
||||
|
||||
#define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
|
||||
/* Unicode mandates an arbitrary limit. */
|
||||
#define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
|
||||
|
||||
grub_ssize_t
|
||||
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
||||
grub_size_t logical_len,
|
||||
struct grub_unicode_glyph **visual_out,
|
||||
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
||||
grub_size_t max_width,
|
||||
grub_size_t start_width);
|
||||
|
||||
enum grub_comb_type
|
||||
grub_unicode_get_comb_type (grub_uint32_t c);
|
||||
grub_size_t
|
||||
grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
|
||||
struct grub_unicode_glyph *out);
|
||||
|
||||
static inline struct grub_unicode_glyph *
|
||||
grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
|
||||
{
|
||||
struct grub_unicode_glyph *out = grub_malloc (sizeof (*out));
|
||||
if (!out)
|
||||
return NULL;
|
||||
grub_memcpy (out, in, sizeof (*in));
|
||||
if (in->combining)
|
||||
{
|
||||
out->combining = grub_malloc (in->ncomb * sizeof (*in));
|
||||
if (!out->combining)
|
||||
{
|
||||
grub_free (out);
|
||||
return NULL;
|
||||
}
|
||||
grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline struct grub_unicode_glyph *
|
||||
grub_unicode_glyph_from_code (grub_uint32_t code)
|
||||
{
|
||||
struct grub_unicode_glyph *ret;
|
||||
ret = grub_zalloc (sizeof (*ret));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->base = code;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_uint32_t
|
||||
grub_unicode_mirror_code (grub_uint32_t in);
|
||||
grub_uint32_t
|
||||
grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr);
|
||||
|
||||
#endif
|
|
@ -168,6 +168,15 @@ struct grub_video_rect
|
|||
};
|
||||
typedef struct grub_video_rect grub_video_rect_t;
|
||||
|
||||
struct grub_video_signed_rect
|
||||
{
|
||||
signed x;
|
||||
signed y;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
};
|
||||
typedef struct grub_video_signed_rect grub_video_signed_rect_t;
|
||||
|
||||
struct grub_video_palette_data
|
||||
{
|
||||
grub_uint8_t r; /* Red color value (0-255). */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue