📄 patch-chinese.diff
字号:
" lists possible command completions. Anywhere else TAB lists the possible\n" " completions of a device/filename.%s ]\n", (forever ? "" : " ESC at any time exits."));++#else+ printf (" [ Minimal BASH-like line editing is supported. For the first word, TAB\n"+ " lists possible command completions. Anywhere else TAB lists the possible\n"+ " completions of a device/filename.%s ]\n",+ (forever ? "" : " ESC at any time exits."));+#endif } /* Find the builtin whose command name is COMMAND and return thediff -Naur grub-0.97_splash/stage2/graphics.c grub-0.97_chinese/stage2/graphics.c--- grub-0.97_splash/stage2/graphics.c 2008-08-01 22:57:40.000000000 +0800+++ grub-0.97_chinese/stage2/graphics.c 2008-08-09 00:16:56.000000000 +0800@@ -1,4 +1,5 @@ /* graphics.c - graphics mode support for GRUB */+/* Chinese double-byte character support by Gandalf <f22_storm@163.com> */ /* Implemented as a terminal type by Jeremy Katz <katzj@redhat.com> based * on a patch by Paulo C閟ar Pereira de Andrade <pcpa@conectiva.com.br> */@@ -30,6 +31,10 @@ #include <shared.h> #include <graphics.h> +#define BASE_FONT_ADDR 0x500000; /* Raw base address for Chinese Font.*/++unsigned short stg2_ptborder = 0; /* Is called from stage2 drawing the menu border? */+ static int saved_videomode = 0; static unsigned char *font8x16 = 0; @@ -62,6 +67,9 @@ static int fontx = 0; static int fonty = 0; +//static char* chrMsg = "(r)Powered by Gandalf, f22_storm@163.com, 07/15/2004";++unsigned short ushFontReaded = 0; /* font loaded? */ /* global state so that we don't try to recursively scroll or cursor */ static int no_scroll = 0; @@ -118,11 +126,41 @@ saved_videomode = set_videomode (0x12); } + if (! ushFontReaded)+ {+ ushFontReaded = 1;+ + /* remove them all. + grub_open("/boot/grub/fonts") ||+ grub_open("/boot/fonts") ||+ grub_open("/grub/fonts") ||+ grub_open("/fonts") + */ + + if (grub_strlen (fontfile) > 0)+ {+ if (grub_open (fontfile) )+ {+ grub_read ((char *) RAW_ADDR (0x500000), -1);+ + grub_close ();+ }+ else+ {+ ushFontReaded = 0; + grub_printf ("load fontfile failed!\n");+ }+ }+ }+ if (! read_image (splashimage)) {- set_videomode (saved_videomode);- grub_printf("failed to read image\n");- return 0;+ if (! ushFontReaded)+ {+ set_videomode (saved_videomode);+ grub_printf ("failed to read image\n");+ return 0; /* graphics_init failure! */+ } } font8x16 = (unsigned char *) graphics_get_font (); /* code in asm.S */@@ -133,7 +171,7 @@ graphics_highlight_color = ((graphics_normal_color >> 4) | ((graphics_normal_color & 0xf) << 4)); - return 1;+ return 1; /* graphics_init success */ } /* Leave graphics mode */@@ -144,6 +182,7 @@ { set_videomode (saved_videomode); graphics_inited = 0;+ ushFontReaded = 0; } } @@ -515,25 +554,92 @@ static unsigned char chr[16 << 2]; static unsigned char mask[16];+static unsigned char by[32], chsa[16], chsb[16]; +/* This function was modified by Gandalf for Chinese Support + *+ * Change Log:+ * N/A+ * TODO:+ * There is a empty line of the center of Chinese Character. !!!+ */ static void graphics_cursor (int set) { unsigned char *pat, *mem, *ptr;- int i, ch, offset;+ int i, ch, offset, n, ch1, ch2; int invert = 0; + int dotpos;++ int fontloaded;+ if (set && no_scroll) return; offset = cursorY * 80 + fontx;+ fontloaded = 0;+ ch = text[fonty * 80 + fontx] & 0xff; if (ch != ' ' || ! disable_space_highlight) invert = (text[fonty * 80 + fontx] & /*0xff00*/ 0xffff0000) != 0;+ pat = font8x16 + (ch << 4);+ + if (ushFontReaded && ch >= 0xa1 &&+ (! stg2_ptborder ||+ (ch != DISP_VERT &&+ ch != DISP_UR &&+ ch != DISP_LL &&+ ch != DISP_HORIZ &&+ ch != DISP_LR &&+ ch != DISP_UL+ )+ )+ )+ {+ /* here is one trick, look one line as a string with '\0' ended, so,+ * if the last byte is the 1st byte of a Chinese Character,,, ,,, */+ for (n = 0; n < fontx; n++)+ {+ ch1 = text[fonty * 80 + n] & 0xff;+ ch2 = text[fonty * 80 + n+1] & 0xff;++ if ((ch1>=0xa1 && ch1<=0xfe)&&(ch2>=0xa1 && ch2<=0xfe))+ {+ if (n == fontx-1)+ {++ fontloaded = 1;+ dotpos = (ch1-0xa1)*94 + ch2 - 0xa1;+ dotpos<<=5;++ grub_memmove(by, (unsigned char *) RAW_ADDR (0x500000 + dotpos), 32);++ for (i = 0; i <32; i ++)+ {+ if (i%2)+ chsb[i/2] = by[i];+ else+ chsa[i/2] = by[i]; + }+ }+ n++;+ }+ }+ } mem = (unsigned char*)VIDEOMEM + offset; + if (fontloaded)+ {+ mem--;//mem = (unsigned char*)VIDEOMEM + offset -1;+ offset--;+ pat = chsa;+ }++write_char:+ if (set) { MapMask(15);@@ -622,6 +728,17 @@ } MapMask(15);+ + if (fontloaded)+ {+ fontloaded = 0;++ /* reset the mem position */+ mem++;//mem += 1;//mem = (unsigned char*)VIDEOMEM + offset;+ offset = cursorY * 80 + fontx;+ pat = chsb;+ goto write_char;+ } } #endif /* SUPPORT_GRAPHICS */diff -Naur grub-0.97_splash/stage2/shared.h grub-0.97_chinese/stage2/shared.h--- grub-0.97_splash/stage2/shared.h 2008-07-21 14:15:08.000000000 +0800+++ grub-0.97_chinese/stage2/shared.h 2008-08-09 00:16:56.000000000 +0800@@ -395,6 +395,12 @@ * Below this should be ONLY defines and other constructs for C code. */ ++extern char fontfile[256];+unsigned short stg2_ptborder;+extern int graphics_inited;+extern unsigned short ushFontReaded;+ /* multiboot stuff */ #include "mb_header.h"@@ -979,6 +985,10 @@ char *short_doc; /* The long version of the documentation. */ char *long_doc;+ /* The short-chinese version of the documentation. */+ char *sc_short_doc;+ /* The long version-chinese of the documentation. */+ char *sc_long_doc; }; /* All the builtins are registered in this. */diff -Naur grub-0.97_splash/stage2/stage2.c grub-0.97_chinese/stage2/stage2.c--- grub-0.97_splash/stage2/stage2.c 2008-08-04 13:41:26.000000000 +0800+++ grub-0.97_chinese/stage2/stage2.c 2008-08-09 00:16:56.000000000 +0800@@ -281,6 +281,8 @@ gotoxy (MENU_BOX_X - 2, y); + stg2_ptborder = 1; /* Chinese Season */+ grub_putchar (DISP_UL); for (i = 0; i < MENU_BOX_W + 1; i++) grub_putchar (DISP_HORIZ);@@ -306,6 +308,8 @@ grub_putchar (DISP_HORIZ); grub_putchar (DISP_LR); + stg2_ptborder = 0;+ if (current_term->setcolorstate) current_term->setcolorstate (COLOR_STATE_STANDARD); }@@ -380,8 +384,14 @@ grub_timeout--; /* Print a message. */- grub_printf ("\rPress `ESC' to enter the menu... %d ",- grub_timeout);+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf ("\r 按 Esc 键进入菜单…… %d ",+ grub_timeout);+ else+#endif+ grub_printf ("\rPress ESC to enter the menu... %d ",+ grub_timeout); } } }@@ -397,27 +407,57 @@ else print_border (MENU_BOX_Y - 1, MENU_BOX_H); - grub_printf ("\nUse the %c and %c keys to highlight an entry.",- DISP_UP, DISP_DOWN);+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf ("\n 用 %c 和 %c 两键将一个菜单项置为高亮。",+ DISP_UP, DISP_DOWN);+ else+#endif+ grub_printf ("\nUse the %c and %c keys to highlight an entry.",+ DISP_UP, DISP_DOWN); if (! auth && password) {- printf (" Press ENTER or \'b\' to boot.\n"- "Press \'p\' to gain privileged control.");+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ printf ("按回车或 b 键启动。按 p 键取得\n"+ " 特权控制功能。");+ else+#endif+ printf (" Press ENTER or \'b\' to boot.\n"+ "Press \'p\' to gain privileged control."); } else { if (config_entries)- printf (" Press ENTER or \'b\' to boot.\n"- "Press \'e\' to edit the commands before booting, or \'c\' for a command-line.");+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ printf ("按回车或 b 键启动;按 e 键可在\n"+ " 启动前逐条编辑菜单中的命令序列;按 c 键进入命令行。"); + else+#endif+ printf (" Press ENTER or \'b\' to boot.\n"+ "Press \'e\' to edit the commands before booting, or \'c\' for a command-line."); else- printf (" At a selected line, press \'e\' to\n"- "edit, \'d\' to delete, or \'O\'/\'o\' to open a new line before/after. When done,\n"- "press \'b\' to boot, \'c\' for a command-line, or ESC to go back to the main menu.");+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ printf (" 按 e 键编辑当前行;按 d 键删\n"+ " 除当前行;按 O 键或 o 键分别在当前行之前或之后插入一个新行。编辑结束时,\n"+ " 按 b 键启动;按 c 键进入命令行;按 Esc 键退回到主菜单。");+ else+#endif+ printf (" At a selected line, press \'e\' to\n"+ "edit, \'d\' to delete, or \'O\'/\'o\' to open a new line before/after. When done,\n"+ "press \'b\' to boot, \'c\' for a command-line, or ESC to go back to the main menu."); } if (current_term->flags & TERM_DUMB)- grub_printf ("\n\nThe selected entry is %d ", entryno);+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf ("\n\n 当前选中项为:%d ", entryno);+ else+#endif+ grub_printf ("\n\nThe selected entry is %d ", entryno); else print_entries (first_entry, entryno, menu_entries); }@@ -443,15 +483,27 @@ time2 = time1; if (current_term->flags & TERM_DUMB)- grub_printf ("\r Entry %d will be booted automatically in %d seconds. ", - entryno, grub_timeout);+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf ("\r 条目 %d 将会自动运行于 %d 秒之后。 ", + entryno, grub_timeout);+ else+#endif+ grub_printf ("\r Entry %d will be booted automatically in %d seconds. ", + entryno, grub_timeout); else { gotoxy (MENU_BOX_X - 2, MENU_BOX_H + 7);- grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",- grub_timeout);+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf (" 高亮选中的条目将会自动运行于 %d 秒之后。 ",+ grub_timeout);+ else+#endif+ grub_printf ("The highlighted entry will be booted automatically in %d seconds. ",+ grub_timeout); gotoxy (MENU_BOX_E, MENU_BOX_Y + entryno);- }+ } grub_timeout--; }@@ -467,7 +519,14 @@ since we're comming in here also on GRUB_TIMEOUT == -1 and hang in GETKEY */ if (current_term->flags & TERM_DUMB)- grub_printf ("\r Highlighted entry is %d: ", entryno);+ {+#ifdef SUPPORT_GRAPHICS+ if (graphics_inited && ushFontReaded)+ grub_printf ("\r 高亮选中的条目为 %d: ", entryno);+ else+#endif+ grub_printf ("\r Highlighted entry is %d: ", entryno);+ } c = /*ASCII_CHAR*/ (getkey ());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -