diff options
| author | Geoff Voelker | 1999-01-19 22:25:33 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1999-01-19 22:25:33 +0000 |
| commit | a1b9438c25bd7669673cb4026fcf47903f7e4645 (patch) | |
| tree | 6de67ddf98853fae4e046b96444dc5156f8b5cde /src | |
| parent | a4e691eeeb6679378996d775d799e23ec44c1161 (diff) | |
| download | emacs-a1b9438c25bd7669673cb4026fcf47903f7e4645.tar.gz emacs-a1b9438c25bd7669673cb4026fcf47903f7e4645.zip | |
Remove codepage macros. Remove redundant BIG5 macros.
(dumpglyphs): Move definitions out of block containing goto.
Remove redundant code for BIG5.
Use w32_codepage_for_font instead of
w32_codepage_for_charset. Add cast to int where float
operation is assigned to int.
(Vw32_charset_to_codepage_alist): New variable.
(w32_codepage_for_charset): Removed.
(w32_codepage_for_font): New function, replacing
w32_codepage_for_charset.
(syms_of_w32term): Add and initialize
w32-charset-to-codepage-alist.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 194 |
1 files changed, 107 insertions, 87 deletions
diff --git a/src/w32term.c b/src/w32term.c index de2ee00c80d..12d476ff9a7 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -55,39 +55,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 55 | #define min(x, y) (((x) < (y)) ? (x) : (y)) | 55 | #define min(x, y) (((x) < (y)) ? (x) : (y)) |
| 56 | #define max(x, y) (((x) > (y)) ? (x) : (y)) | 56 | #define max(x, y) (((x) > (y)) ? (x) : (y)) |
| 57 | 57 | ||
| 58 | /* Windows libraries do not define codepages other than ANSI and | ||
| 59 | Unicode. We need all the ones for the languages that Emacs supports | ||
| 60 | if languages other than that of the current locale are to be | ||
| 61 | displayed under NT. */ | ||
| 62 | #define CP_DEFAULT 1004 | 58 | #define CP_DEFAULT 1004 |
| 63 | #define CP_SJIS 932 | ||
| 64 | #define CP_GB2312 936 | ||
| 65 | #define CP_BIG5 950 | ||
| 66 | #define CP_KOREAN 949 | ||
| 67 | #define CP_THAI 874 | ||
| 68 | #define CP_LATIN1 1252 | ||
| 69 | #define CP_LATIN2 1250 | ||
| 70 | #define CP_LATIN3 1254 | ||
| 71 | #define CP_LATIN4 1257 | ||
| 72 | #define CP_CYRILLIC5 1251 | ||
| 73 | #define CP_ARABIC6 1256 | ||
| 74 | #define CP_GREEK7 1253 | ||
| 75 | #define CP_HEBREW8 1255 | ||
| 76 | #define CP_LATIN9 /*1258?*/ | ||
| 77 | #define CP_VIETNAM /*???*/ | ||
| 78 | |||
| 79 | /* ENCODE_SJIS is defined in coding.h, but ENCODE_BIG5 is only in | ||
| 80 | coding.c, so need our own copy here */ | ||
| 81 | #define BIG5_SAME_ROW (0xFF - 0xA1 + 0x7F - 0x40) | ||
| 82 | #define ENCODE_BIG5(charset, c1, c2, b1, b2) \ | ||
| 83 | do { \ | ||
| 84 | unsigned int temp = (c1 - 0x21) * (0xFF - 0xA1) + (c2 - 0x21); \ | ||
| 85 | if (charset == charset_big5_2) \ | ||
| 86 | temp += BIG5_SAME_ROW * (0xC9 - 0xA1); \ | ||
| 87 | b1 = temp / BIG5_SAME_ROW + 0xA1; \ | ||
| 88 | b2 = temp % BIG5_SAME_ROW; \ | ||
| 89 | b2 += b2 < 0x3F ? 0x40 : 0x62; \ | ||
| 90 | } while (0) | ||
| 91 | 59 | ||
| 92 | extern unsigned int msh_mousewheel; | 60 | extern unsigned int msh_mousewheel; |
| 93 | 61 | ||
| @@ -212,6 +180,9 @@ int last_mouse_scroll_bar_pos; | |||
| 212 | it's somewhat accurate. */ | 180 | it's somewhat accurate. */ |
| 213 | Time last_mouse_movement_time; | 181 | Time last_mouse_movement_time; |
| 214 | 182 | ||
| 183 | /* Associative list linking character set strings to Windows codepages. */ | ||
| 184 | Lisp_Object Vw32_charset_to_codepage_alist; | ||
| 185 | |||
| 215 | /* Incremented by w32_read_socket whenever it really tries to read events. */ | 186 | /* Incremented by w32_read_socket whenever it really tries to read events. */ |
| 216 | #ifdef __STDC__ | 187 | #ifdef __STDC__ |
| 217 | static int volatile input_signal_count; | 188 | static int volatile input_signal_count; |
| @@ -514,43 +485,41 @@ w32_cursor_to (row, col) | |||
| 514 | } | 485 | } |
| 515 | } | 486 | } |
| 516 | 487 | ||
| 488 | /* Get the Windows codepage corresponding to the specified font. The | ||
| 489 | charset info in the font name is used to look up | ||
| 490 | w32-charset-to-codepage-alist. */ | ||
| 517 | int | 491 | int |
| 518 | w32_codepage_for_charset (int charset) | 492 | w32_codepage_for_font (char *fontname) |
| 519 | { | 493 | { |
| 520 | /* The codepage is only used to convert to unicode, so we only need | 494 | Lisp_Object codepage; |
| 521 | to cover the languages that we may print via unicode. */ | 495 | char charset_str[20], *charset, *end; |
| 522 | if (charset == charset_latin_iso8859_1) | 496 | |
| 523 | return CP_LATIN1; | 497 | /* Extract charset part of font string. */ |
| 524 | else if (charset == charset_big5_1 || | 498 | if (sscanf (fontname, |
| 525 | charset == charset_big5_2) | 499 | "-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%19s", |
| 526 | return CP_BIG5; | 500 | charset_str) == EOF) |
| 527 | else if (charset == charset_jisx0208 | 501 | return CP_DEFAULT; |
| 528 | || charset == charset_jisx0208_1978 | 502 | |
| 529 | || charset == charset_katakana_jisx0201 | 503 | /* Remove leading "*-". */ |
| 530 | || charset == charset_latin_jisx0201 | 504 | if (strncmp ("*-", charset_str, 2) == 0) |
| 531 | || charset == charset_id_internal ("japanese-jisx0212")) | 505 | charset = charset_str + 2; |
| 532 | return CP_SJIS; | 506 | else |
| 533 | else if (charset == charset_id_internal ("chinese-gb2312")) | 507 | charset = charset_str; |
| 534 | return CP_GB2312; | 508 | |
| 535 | else if (charset == charset_id_internal ("korean-ksc5601")) | 509 | /* Stop match at wildcard (including preceding '-'). */ |
| 536 | return CP_KOREAN; | 510 | if (end = strchr (charset, '*')) |
| 537 | else if (charset == charset_id_internal ("latin-iso8859-2")) | 511 | { |
| 538 | return CP_LATIN2; | 512 | if (end > charset && *(end-1) == '-') |
| 539 | else if (charset == charset_id_internal ("latin-iso8859-3")) | 513 | end--; |
| 540 | return CP_LATIN3; | 514 | *end = '\0'; |
| 541 | else if (charset == charset_id_internal ("latin-iso8859-4")) | 515 | } |
| 542 | return CP_LATIN4; | 516 | |
| 543 | else if (charset == charset_id_internal ("cyrillic-iso8859-5")) | 517 | codepage = Fcdr (Fassoc (build_string(charset), |
| 544 | return CP_CYRILLIC5; | 518 | Vw32_charset_to_codepage_alist)); |
| 545 | else if (charset == charset_id_internal ("arabic-iso8859-6")) | 519 | |
| 546 | return CP_ARABIC6; | 520 | if (INTEGERP (codepage)) |
| 547 | else if (charset == charset_id_internal ("greek-iso8859-7")) | 521 | return XINT (codepage); |
| 548 | return CP_GREEK7; | 522 | else |
| 549 | else if (charset == charset_id_internal ("hebrew-iso8859-8")) | ||
| 550 | return CP_HEBREW8; | ||
| 551 | else if (charset == charset_id_internal ("thai-tis620")) | ||
| 552 | return CP_THAI; | ||
| 553 | else /* Don't care - return system default. */ | ||
| 554 | return CP_DEFAULT; | 523 | return CP_DEFAULT; |
| 555 | } | 524 | } |
| 556 | 525 | ||
| @@ -699,6 +668,9 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 699 | { | 668 | { |
| 700 | struct face *face = FRAME_DEFAULT_FACE (f); | 669 | struct face *face = FRAME_DEFAULT_FACE (f); |
| 701 | XFontStruct *font = NULL; | 670 | XFontStruct *font = NULL; |
| 671 | int fontset; | ||
| 672 | struct font_info *fontp; | ||
| 673 | int font_id; | ||
| 702 | COLORREF fg; | 674 | COLORREF fg; |
| 703 | COLORREF bg; | 675 | COLORREF bg; |
| 704 | int stippled = 0; | 676 | int stippled = 0; |
| @@ -763,9 +735,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 763 | /* Setting appropriate font and codepage for this charset. */ | 735 | /* Setting appropriate font and codepage for this charset. */ |
| 764 | if (charset != CHARSET_ASCII) | 736 | if (charset != CHARSET_ASCII) |
| 765 | { | 737 | { |
| 766 | int font_id; | 738 | fontset = FACE_FONTSET (face); |
| 767 | int fontset = FACE_FONTSET (face); | ||
| 768 | struct font_info *fontp; | ||
| 769 | 739 | ||
| 770 | if ((fontset < 0 && (fontset = FRAME_FONTSET (f)) < 0) | 740 | if ((fontset < 0 && (fontset = FRAME_FONTSET (f)) < 0) |
| 771 | || !(fontp = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), | 741 | || !(fontp = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), |
| @@ -773,7 +743,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 773 | goto font_not_found; | 743 | goto font_not_found; |
| 774 | 744 | ||
| 775 | font = (XFontStruct *) (fontp->font); | 745 | font = (XFontStruct *) (fontp->font); |
| 776 | codepage = w32_codepage_for_charset (charset); | 746 | codepage = w32_codepage_for_font (fontp->name); |
| 777 | print_via_unicode = w32_use_unicode_for_codepage (codepage); | 747 | print_via_unicode = w32_use_unicode_for_codepage (codepage); |
| 778 | 748 | ||
| 779 | /* tmLastChar will only exceed 255 if TEXTMETRICW is used | 749 | /* tmLastChar will only exceed 255 if TEXTMETRICW is used |
| @@ -797,20 +767,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 797 | } | 767 | } |
| 798 | 768 | ||
| 799 | /* We have to change code points in the following cases. */ | 769 | /* We have to change code points in the following cases. */ |
| 800 | if (charset == charset_big5_1 | 770 | if (fontp->font_encoder) |
| 801 | || charset == charset_big5_2) | ||
| 802 | { | ||
| 803 | /* Handle Big5 encoding specially rather than | ||
| 804 | requiring a CCL. */ | ||
| 805 | int big1, big2; | ||
| 806 | for (cp = x_2byte_buffer; cp < x_2byte_buffer + len; cp++) | ||
| 807 | { | ||
| 808 | ENCODE_BIG5 (charset, BYTE1 (*cp), BYTE2 (*cp), | ||
| 809 | big1, big2); | ||
| 810 | *cp = BUILD_WCHAR_T (big1, big2); | ||
| 811 | } | ||
| 812 | } | ||
| 813 | else if (fontp->font_encoder) | ||
| 814 | { | 771 | { |
| 815 | /* This font requires CCL program to calculate code | 772 | /* This font requires CCL program to calculate code |
| 816 | point of characters. */ | 773 | point of characters. */ |
| @@ -1103,7 +1060,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1103 | } | 1060 | } |
| 1104 | 1061 | ||
| 1105 | if (cmpcharp->cmp_rule) | 1062 | if (cmpcharp->cmp_rule) |
| 1106 | x_offset = (cmpcharp->col_offset[0] | 1063 | x_offset = (int)(cmpcharp->col_offset[0] |
| 1107 | * FONT_WIDTH (FRAME_FONT (f))); | 1064 | * FONT_WIDTH (FRAME_FONT (f))); |
| 1108 | 1065 | ||
| 1109 | i = 1; | 1066 | i = 1; |
| @@ -1226,7 +1183,7 @@ dumpglyphs (f, left, top, gp, n, hl, just_foreground, cmpcharp) | |||
| 1226 | if (bottom < lowest) | 1183 | if (bottom < lowest) |
| 1227 | lowest = bottom; | 1184 | lowest = bottom; |
| 1228 | y_offset = bottom + font->tm.tmDescent; | 1185 | y_offset = bottom + font->tm.tmDescent; |
| 1229 | x_offset = (cmpcharp->col_offset[gidx] | 1186 | x_offset = (int)(cmpcharp->col_offset[gidx] |
| 1230 | * FONT_WIDTH (FRAME_FONT(f))); | 1187 | * FONT_WIDTH (FRAME_FONT(f))); |
| 1231 | } | 1188 | } |
| 1232 | 1189 | ||
| @@ -5146,6 +5103,8 @@ w32_initialize () | |||
| 5146 | void | 5103 | void |
| 5147 | syms_of_w32term () | 5104 | syms_of_w32term () |
| 5148 | { | 5105 | { |
| 5106 | Lisp_Object codepage; | ||
| 5107 | |||
| 5149 | staticpro (&w32_display_name_list); | 5108 | staticpro (&w32_display_name_list); |
| 5150 | w32_display_name_list = Qnil; | 5109 | w32_display_name_list = Qnil; |
| 5151 | 5110 | ||
| @@ -5195,4 +5154,65 @@ Far-East Languages on Windows 95/98 from working properly.\n\ | |||
| 5195 | NT uses Unicode internally anyway, so this flag will probably have no\n\ | 5154 | NT uses Unicode internally anyway, so this flag will probably have no\n\ |
| 5196 | affect on NT machines."); | 5155 | affect on NT machines."); |
| 5197 | w32_enable_unicode_output = 1; | 5156 | w32_enable_unicode_output = 1; |
| 5157 | |||
| 5158 | /* w32-charset-to-codepage-alist is initialized in w32-win.el. */ | ||
| 5159 | DEFVAR_LISP ("w32-charset-to-codepage-alist", | ||
| 5160 | &Vw32_charset_to_codepage_alist, | ||
| 5161 | "Alist linking character sets to Windows Codepages."); | ||
| 5162 | Vw32_charset_to_codepage_alist = Qnil; | ||
| 5163 | /* Initialise the alist with some defaults. */ | ||
| 5164 | XSETFASTINT (codepage, 936); | ||
| 5165 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5166 | build_string ("gb2312"), codepage); | ||
| 5167 | XSETFASTINT (codepage, 950); | ||
| 5168 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5169 | build_string ("big5"), codepage); | ||
| 5170 | XSETFASTINT (codepage, 949); | ||
| 5171 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5172 | build_string ("ksc5601"), codepage); | ||
| 5173 | XSETFASTINT (codepage, 932); | ||
| 5174 | /* SJIS only contains a subset of JISX0212, but list it anyway. */ | ||
| 5175 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5176 | build_string ("jisx0212-sjis"), codepage); | ||
| 5177 | XSETFASTINT (codepage, 932); | ||
| 5178 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5179 | build_string ("jisx0208-sjis"), codepage); | ||
| 5180 | XSETFASTINT (codepage, 874); | ||
| 5181 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5182 | build_string ("tis620"), codepage); | ||
| 5183 | XSETFASTINT (codepage, 20866); | ||
| 5184 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5185 | build_string ("koi8-r"), codepage); | ||
| 5186 | /* iso8859-13 is not yet officially adopted, but it is conveniently | ||
| 5187 | covered by CP 1257. */ | ||
| 5188 | XSETFASTINT (codepage, 1257); | ||
| 5189 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5190 | build_string ("iso8859-13"), codepage); | ||
| 5191 | XSETFASTINT (codepage, 1254); | ||
| 5192 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5193 | build_string ("iso8859-9"), codepage); | ||
| 5194 | XSETFASTINT (codepage, 1255); | ||
| 5195 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5196 | build_string ("iso8859-8"), codepage); | ||
| 5197 | XSETFASTINT (codepage, 28597); | ||
| 5198 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5199 | build_string ("iso8859-7"), codepage); | ||
| 5200 | XSETFASTINT (codepage, 28596); | ||
| 5201 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5202 | build_string ("iso8859-6"), codepage); | ||
| 5203 | XSETFASTINT (codepage, 28595); | ||
| 5204 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5205 | build_string ("iso8859-5"), codepage); | ||
| 5206 | XSETFASTINT (codepage, 28594); | ||
| 5207 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5208 | build_string ("iso8859-4"), codepage); | ||
| 5209 | XSETFASTINT (codepage, 28593); | ||
| 5210 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5211 | build_string ("iso8859-3"), codepage); | ||
| 5212 | XSETFASTINT (codepage, 28592); | ||
| 5213 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5214 | build_string ("iso8859-2"), codepage); | ||
| 5215 | XSETFASTINT (codepage, 1252); | ||
| 5216 | store_in_alist (&Vw32_charset_to_codepage_alist, | ||
| 5217 | build_string ("iso8859-1"), codepage); | ||
| 5198 | } | 5218 | } |