Changeset 1679
- Timestamp:
- 02/17/98 01:45:17 (11 years ago)
- Files:
-
- branches/GNU/src/w16select.c (modified) (9 diffs)
- branches/GNU/src/w32.c (modified) (3 diffs)
- branches/GNU/src/w32console.c (modified) (8 diffs)
- branches/GNU/src/w32faces.c (added)
- branches/GNU/src/w32fns.c (modified) (64 diffs)
- branches/GNU/src/w32heap.c (modified) (2 diffs)
- branches/GNU/src/w32heap.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/GNU/src/w16select.c
r1651 r1679 78 78 /* The segment address and the size of the buffer in low 79 79 memory used to move data between us and WinOldAp module. */ 80 80 81 static struct { 81 82 unsigned long size; 82 83 unsigned short rm_segment; 83 84 } clipboard_xfer_buf_info; 84 85 /* The last text we put into the clipboard. This is used to prevent86 passing back our own text from the clipboard, instead of using the87 kill ring. The former is undesirable because the clipboard data88 could be MULEtilated by inappropriately chosen89 (next-)selection-coding-system. For this reason, we must store the90 text *after* it was encoded/Unix-to-DOS-converted. */91 static unsigned char *last_clipboard_text;92 93 /* The size of allocated storage for storing the clipboard data. */94 static size_t clipboard_storage_size;95 85 96 86 /* Emulation of `__dpmi_int' and friends for DJGPP v1.x */ … … 274 264 /* Move the buffer into the low memory, convert LF into CR-LF if needed. */ 275 265 if (Raw) 276 { 277 dosmemput (Data, Size, xbuf_addr); 278 279 /* Terminate with a null, otherwise Windows does strange things 280 when the text size is an integral multiple of 32 bytes. */ 281 _farpokeb (_dos_ds, xbuf_addr + Size, '\0'); 282 } 266 dosmemput (Data, truelen, __tb); 283 267 else 284 268 { … … 296 280 _farnspokeb (buf_offset++, *dp++); 297 281 } 298 299 /* Terminate with a null, otherwise Windows does strange things 300 when the text size is an integral multiple of 32 bytes. */ 301 _farnspokeb (buf_offset, '\0'); 302 } 303 304 /* Stash away the data we are about to put into the clipboard, so we 305 could later check inside get_clipboard_data whether the clipboard 306 still holds our data. */ 307 if (clipboard_storage_size < truelen) 308 { 309 clipboard_storage_size = truelen + 100; 310 last_clipboard_text = 311 (char *) xrealloc (last_clipboard_text, clipboard_storage_size); 312 } 313 if (last_clipboard_text) 314 dosmemget (xbuf_addr, truelen, last_clipboard_text); 282 } 283 284 /* Terminate with a null, otherwise Windows does strange things when 285 the text size is an integral multiple of 32 bytes. */ 286 _farnspokeb (buf_offset, *dp); 315 287 316 288 /* Calls Int 2Fh/AX=1703h with: … … 330 302 free_xfer_buf (); 331 303 332 /* If the above failed, invalidate the local copy of the clipboard. */333 if (regs.x.ax == 0)334 *last_clipboard_text = '\0';335 336 304 /* Zero means success, otherwise (1 or 2) it's an error. */ 337 305 return regs.x.ax > 0 ? 0 : 1; … … 370 338 unsigned long xbuf_addr; 371 339 unsigned char *dp = Data; 340 /* The last 32-byte aligned block of data. See commentary below. */ 341 unsigned char *last_block = dp + ((Size & 0x1f) 342 ? (Size & 0x20) 343 : Size - 0x20); 372 344 373 345 if (Format != CF_OEMTEXT) … … 393 365 if (regs.x.ax != 0) 394 366 { 395 unsigned char null_char = '\0';396 unsigned long xbuf_beg = xbuf_addr;397 398 /* If last_clipboard_text is NULL, we don't want to slow down399 the next loop by an additional test. */400 register unsigned char *lcdp =401 last_clipboard_text == NULL ? &null_char : last_clipboard_text;402 403 367 /* Copy data from low memory, remove CR 404 368 characters before LF if needed. */ … … 408 372 register unsigned char c = _farnspeekb (xbuf_addr++); 409 373 410 if (*lcdp == c)411 lcdp++;412 413 374 if ((*dp++ = c) == '\r' && !Raw && _farnspeekb (xbuf_addr) == '\n') 414 375 { … … 416 377 *dp++ = '\n'; 417 378 xbuf_addr++; 418 if (*lcdp == '\n') 419 lcdp++; 379 last_block--; /* adjust the beginning of the last 32 bytes */ 420 380 } 421 381 /* Windows reportedly rounds up the size of clipboard data 422 (passed in SIZE) to a multiple of 32 , and removes trailing423 spaces from each line without updating SIZE. We therefore424 b ail out when we see the first null character. */425 else if (c == '\0' )382 (passed in SIZE) to a multiple of 32. We therefore bail 383 out when we see the first null character in the last 32-byte 384 block. */ 385 else if (c == '\0' && dp > last_block) 426 386 break; 427 387 } 428 429 /* If the text in clipboard is identical to what we put there430 last time set_clipboard_data was called, pretend there's no431 data in the clipboard. This is so we don't pass our own text432 from the clipboard (which might be troublesome if the killed433 text includes null characters). */434 if (last_clipboard_text &&435 xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text))436 dp = (unsigned char *)Data + 1;437 388 } 438 389 … … 539 490 encode_coding (&coding, src, dst, nbytes, bufsize); 540 491 no_crlf_conversion = 1; 541 nbytes = coding.produced;542 src = dst;543 492 } 544 493 branches/GNU/src/w32.c
r1651 r1679 640 640 641 641 void 642 init_environment ( char ** argv)642 init_environment () 643 643 { 644 644 int len; … … 759 759 { 760 760 char *p; 761 staticchar modname[MAX_PATH];761 char modname[MAX_PATH]; 762 762 763 763 if (!GetModuleFileName (NULL, modname, MAX_PATH)) … … 768 768 769 769 SetCurrentDirectory (modname); 770 771 /* Ensure argv[0] has the full path to Emacs. */772 *p = '\\';773 argv[0] = modname;774 770 } 775 771 branches/GNU/src/w32console.c
r1663 r1679 77 77 #endif 78 78 79 /* Determine whether to make frame dimensions match the screen buffer,80 or the current window size. The former is desirable when running81 over telnet, while the latter is more useful when working directly at82 the console with a large scroll-back buffer. */83 int w32_use_full_screen_buffer;84 85 79 86 80 /* Setting this as the ctrl handler prevents emacs from being killed when … … 130 124 COORD dest; 131 125 int n, r; 132 CONSOLE_SCREEN_BUFFER_INFO info;133 134 GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info);135 126 136 127 hl_mode (0); 137 128 138 /* Remember that the screen buffer might be wider than the window. */ 139 n = FRAME_HEIGHT (f) * info.dwSize.X; 129 n = FRAME_HEIGHT (f) * FRAME_WIDTH (f); 140 130 dest.X = dest.Y = 0; 141 131 … … 344 334 register char *ptr; 345 335 GLYPH glyph; 336 WORD *attrs; 346 337 char *chars; 347 338 int i; … … 350 341 return; 351 342 343 attrs = alloca (len * sizeof (*attrs)); 352 344 chars = alloca (len * sizeof (*chars)); 353 if ( chars == NULL)345 if (attrs == NULL || chars == NULL) 354 346 { 355 347 printf ("alloca failed in write_glyphs\n"); … … 388 380 len = ptr-chars; 389 381 390 /* Set the attribute for these characters. */ 391 if (!FillConsoleOutputAttribute (cur_screen, char_attr, len, cursor_coords, &i)) 382 /* Fill in the attributes for these characters. */ 383 for (i = 0; i < len; i++) 384 attrs[i] = char_attr; 385 386 /* Write the attributes. */ 387 if (!WriteConsoleOutputAttribute (cur_screen, attrs, len, cursor_coords, &i)) 392 388 { 393 389 printf ("Failed writing console attributes: %d\n", GetLastError ()); … … 570 566 #endif 571 567 572 /* Respect setting of LINES and COLUMNS environment variables. */573 {574 char * lines = getenv("LINES");575 char * columns = getenv("COLUMNS");576 577 if (lines != NULL && columns != NULL)578 {579 SMALL_RECT new_win_dims;580 COORD new_size;581 582 new_size.X = atoi (columns);583 new_size.Y = atoi (lines);584 585 GetConsoleScreenBufferInfo (cur_screen, &info);586 587 /* Shrink the window first, so the buffer dimensions can be588 reduced if necessary. */589 new_win_dims.Top = 0;590 new_win_dims.Left = 0;591 new_win_dims.Bottom = min (new_size.Y, info.dwSize.Y) - 1;592 new_win_dims.Right = min (new_size.X, info.dwSize.X) - 1;593 SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims);594 595 SetConsoleScreenBufferSize (cur_screen, new_size);596 597 /* Set the window size to match the buffer dimension. */598 new_win_dims.Top = 0;599 new_win_dims.Left = 0;600 new_win_dims.Bottom = new_size.Y - 1;601 new_win_dims.Right = new_size.X - 1;602 SetConsoleWindowInfo (cur_screen, TRUE, &new_win_dims);603 }604 }605 606 568 GetConsoleScreenBufferInfo (cur_screen, &info); 607 569 … … 611 573 char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); 612 574 613 if (w32_use_full_screen_buffer) 614 { 615 FRAME_HEIGHT (selected_frame) = info.dwSize.Y; /* lines per page */ 616 SET_FRAME_WIDTH (selected_frame, info.dwSize.X); /* characters per line */ 617 } 618 else 619 { 620 /* Lines per page. Use buffer coords instead of buffer size. */ 621 FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom - 622 info.srWindow.Top; 623 /* Characters per line. Use buffer coords instead of buffer size. */ 624 SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right - 625 info.srWindow.Left); 626 } 575 /* Lines per page. Use buffer coords instead of buffer size. */ 576 FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom - 577 info.srWindow.Top; 578 /* Characters per line. Use buffer coords instead of buffer size. */ 579 SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right - 580 info.srWindow.Left); 627 581 } 628 582 … … 673 627 syms_of_ntterm () 674 628 { 675 DEFVAR_BOOL ("w32-use-full-screen-buffer",676 &w32_use_full_screen_buffer,677 "Non-nil means make terminal frames use the full screen buffer dimensions.\n\678 This is desirable when running Emacs over telnet, and is the default.\n\679 A value of nil means use the current console window dimensions; this\n\680 may be preferrable when working directly at the console with a large\n\681 scroll-back buffer.");682 w32_use_full_screen_buffer = 1;683 684 629 defsubr (&Sset_screen_color); 685 630 defsubr (&Sset_cursor_size); branches/GNU/src/w32fns.c
r1651 r1679 38 38 #include "keyboard.h" 39 39 #include "blockinput.h" 40 #include " epaths.h"40 #include "paths.h" 41 41 #include "w32heap.h" 42 42 #include "termhooks.h" … … 64 64 Lisp_Object Vw32_alt_is_meta; 65 65 66 /* If non-zero, the windows virtual key code for an alternative quit key. */67 Lisp_Object Vw32_quit_key;68 69 66 /* Non nil if left window key events are passed on to Windows (this only 70 67 affects whether "tapping" the key opens the Start menu). */ … … 139 136 Lisp_Object Vx_pixel_size_width_font_regexp; 140 137 141 /* Alist of bdf fonts and the files that define them. */142 Lisp_Object Vw32_bdf_filename_alist;143 144 Lisp_Object Vw32_system_coding_system;145 146 138 /* A flag to control how to display unibyte 8-bit character. */ 147 139 int unibyte_display_via_language_environment; 148 149 /* A flag to control whether fonts are matched strictly or not. */150 int w32_strict_fontnames;151 140 152 141 /* Evaluate this expression to rebuild the section of syms_of_w32fns … … 537 526 /* Remove reference to bitmap with id number ID. */ 538 527 539 void 528 int 540 529 x_destroy_bitmap (f, id) 541 530 FRAME_PTR f; … … 697 686 int icon_left_no_change = 0, icon_top_no_change = 0; 698 687 699 struct gcpro gcpro1, gcpro2;700 701 688 i = 0; 702 689 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) … … 719 706 } 720 707 721 /* TAIL and ALIST are not used again below here. */722 alist = tail = Qnil;723 724 GCPRO2 (*parms, *values);725 gcpro1.nvars = i;726 gcpro2.nvars = i;727 728 /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,729 because their values appear in VALUES and strings are not valid. */730 708 top = left = Qunbound; 731 709 icon_left = icon_top = Qunbound; … … 891 869 x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top)); 892 870 } 893 894 UNGCPRO;895 871 } 896 872 … … 1973 1949 } 1974 1950 1975 /* Set the border-color of frame F to pixel value PIX.1976 Note that this does not fully take effect if done before1977 F has an window. */1978 void1979 x_set_border_pixel (f, pix)1980 struct frame *f;1981 int pix;1982 {1983 f->output_data.w32->border_pixel = pix;1984 1985 if (FRAME_W32_WINDOW (f) != 0 && f->output_data.w32->border_width > 0)1986 {1987 if (FRAME_VISIBLE_P (f))1988 redraw_frame (f);1989 }1990 }1991 1992 1951 /* Set the border-color of frame F to value described by ARG. 1993 1952 ARG can be a string naming a color. … … 2010 1969 2011 1970 x_set_border_pixel (f, pix); 1971 } 1972 1973 /* Set the border-color of frame F to pixel value PIX. 1974 Note that this does not fully take effect if done before 1975 F has an window. */ 1976 1977 x_set_border_pixel (f, pix) 1978 struct frame *f; 1979 int pix; 1980 { 1981 f->output_data.w32->border_pixel = pix; 1982 1983 if (FRAME_W32_WINDOW (f) != 0 && f->output_data.w32->border_width > 0) 1984 { 1985 if (FRAME_VISIBLE_P (f)) 1986 redraw_frame (f); 1987 } 2012 1988 } 2013 1989 … … 3628 3604 if (isalpha (c) && wmsg.dwModifiers == ctrl_modifier) 3629 3605 c = make_ctrl_char (c) & 0377; 3630 if (c == quit_char 3631 || (wmsg.dwModifiers == 0 && 3632 XFASTINT (Vw32_quit_key) && wParam == XFASTINT (Vw32_quit_key))) 3606 if (c == quit_char) 3633 3607 { 3634 3608 Vquit_flag = Qt; … … 3680 3654 W32Msg wmsg; 3681 3655 int windows_translate; 3682 int key;3683 3656 3684 3657 /* Note that it is okay to call x_window_to_frame, even though we are … … 3782 3755 { 3783 3756 dpyinfo->faked_key = 0; 3784 /* Make sure TranslateMessage sees them though (as long as 3785 they don't produce WM_CHAR messages). This ensures that 3786 indicator lights are toggled promptly on Windows 9x, for 3787 example. */ 3788 if (lispy_function_keys[wParam] != 0) 3789 { 3790 windows_translate = 1; 3791 goto translate; 3792 } 3793 return 0; 3757 /* Make sure TranslateMessage sees them though. */ 3758 windows_translate = 1; 3759 goto translate; 3794 3760 } 3795 3761 … … 3812 3778 { 3813 3779 if (NUMBERP (Vw32_phantom_key_code)) 3814 key= XUINT (Vw32_phantom_key_code) & 255;3780 wParam = XUINT (Vw32_phantom_key_code) & 255; 3815 3781 else 3816 key= VK_SPACE;3817 dpyinfo->faked_key = key;3818 keybd_event ( key, (BYTE) MapVirtualKey (key, 0), 0, 0);3782 wParam = VK_SPACE; 3783 dpyinfo->faked_key = wParam; 3784 keybd_event (wParam, (BYTE) MapVirtualKey (wParam, 0), 0, 0); 3819 3785 } 3820 3786 } 3821 3787 if (!NILP (Vw32_lwindow_modifier)) 3822 3788 return 0; 3789 windows_translate = 1; 3823 3790 break; 3824 3791 case VK_RWIN: … … 3828 3795 { 3829 3796 if (NUMBERP (Vw32_phantom_key_code)) 3830 key= XUINT (Vw32_phantom_key_code) & 255;3797 wParam = XUINT (Vw32_phantom_key_code) & 255; 3831 3798 else 3832 key= VK_SPACE;3833 dpyinfo->faked_key = key;3834 keybd_event ( key, (BYTE) MapVirtualKey (key, 0), 0, 0);3799 wParam = VK_SPACE; 3800 dpyinfo->faked_key = wParam; 3801 keybd_event (wParam, (BYTE) MapVirtualKey (wParam, 0), 0, 0); 3835 3802 } 3836 3803 } 3837 3804 if (!NILP (Vw32_rwindow_modifier)) 3838 3805 return 0; 3806 windows_translate = 1; 3839 3807 break; 3840 case VK_APPS:3808 case VK_APPS: 3841 3809 if (!NILP (Vw32_apps_modifier)) 3842 3810 return 0; 3811 windows_translate = 1; 3843 3812 break; 3844 3813 case VK_MENU: … … 4435 4404 goto dflt; 4436 4405 4437 case WM_GETMINMAXINFO:4438 /* Hack to correct bug that allows Emacs frames to be resized4439 below the Minimum Tracking Size. */4440 ((LPMINMAXINFO) lParam)->ptMinTrackSize.y++;4441 return 0;4442 4443 4406 case WM_EMACS_CREATESCROLLBAR: 4444 4407 return (LRESULT) w32_createscrollbar ((struct frame *) wParam, … … 4780 4743 font = x_new_fontset (f, XSTRING (tem)->data); 4781 4744 else 4782 font = x_new_font (f, XSTRING (font)->data);4745 font = x_new_font (f, XSTRING (font)->data); 4783 4746 } 4784 4747 /* Try out a font which we hope has bold and italic variations. */ … … 4956 4919 4957 4920 4958 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, 4959 int size, char* filename);4960 4921 /* Load font named FONTNAME of size SIZE for frame F, and return a 4922 pointer to the structure font_info while allocating it dynamically. 4923 If loading fails, return NULL. */ 4961 4924 struct font_info * 4962 w32_load_ system_font (f,fontname,size)4925 w32_load_font (f,fontname,size) 4963 4926 struct frame *f; 4964 4927 char * fontname; … … 4967 4930 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 4968 4931 Lisp_Object font_names; 4932 4933 #if 0 /* x_load_font attempts to get a list of fonts - presumably to 4934 allow a fuzzier fontname to be specified. w32_list_fonts 4935 appears to be a bit too fuzzy for this purpose. */ 4969 4936 4970 4937 /* Get a list of all the fonts that match this name. Once we … … 4977 4944 Lisp_Object tail; 4978 4945 int i; 4946 4979 4947 #if 0 /* This code has nasty side effects that cause Emacs to crash. */ 4980 4948 … … 4989 4957 return (dpyinfo->font_table + i); 4990 4958 #endif 4959 4991 4960 fontname = (char *) XSTRING (XCONS (font_names)->car)->data; 4992 4961 } 4993 else if (w32_strict_fontnames) 4994 { 4995 /* If EnumFontFamiliesEx was available, we got a full list of 4996 fonts back so stop now to avoid the possibility of loading a 4997 random font. If we had to fall back to EnumFontFamilies, the 4998 list is incomplete, so continue whether the font we want was 4999 listed or not. */ 5000 HMODULE gdi32 = GetModuleHandle ("gdi32.dll"); 5001 FARPROC enum_font_families_ex 5002 = GetProcAddress (gdi32, "EnumFontFamiliesExA"); 5003 if (enum_font_families_ex) 5004 return NULL; 5005 } 4962 else 4963 return NULL; 4964 #endif 5006 4965 5007 4966 /* Load the font and add it to the table. */ 5008 4967 { 5009 char *full_name , *encoding;4968 char *full_name; 5010 4969 XFontStruct *font; 5011 4970 struct font_info *fontp; … … 5026 4985 font = (XFontStruct *) xmalloc (sizeof (XFontStruct)); 5027 4986 5028 /* Set bdf to NULL to indicate that this is a Windows font. */ 5029 font->bdf = NULL; 4987 if (!font) return (NULL); 5030 4988 5031 4989 BLOCK_INPUT; … … 5108 5066 which is never used by any charset. If mapping can't be 5109 5067 decided, set FONT_ENCODING_NOT_DECIDED. */ 5110 5111 /* SJIS fonts need to be set to type 4, all others seem to work as5112 type FONT_ENCODING_NOT_DECIDED. */5113 encoding = strrchr (fontp->name, '-');5114 if (encoding && stricmp (encoding+1, "sjis") == 0)5115 fontp->encoding[1] = 4;5116 else5117 5068 fontp->encoding[1] = FONT_ENCODING_NOT_DECIDED; 5118 5069 … … 5121 5072 fontp->baseline_offset = 0; 5122 5073 fontp->relative_compose = 0; 5123 fontp->default_ascent = 0;5074 fontp->default_ascent = FONT_BASE (font); 5124 5075 5125 5076 UNBLOCK_INPUT; … … 5129 5080 } 5130 5081 } 5131 5132 /* Load font named FONTNAME of size SIZE for frame F, and return a5133 pointer to the structure font_info while allocating it dynamically.5134 If loading fails, return NULL. */5135 struct font_info *5136 w32_load_font (f,fontname,size)5137 struct frame *f;5138 char * fontname;5139 int size;5140 {5141 Lisp_Object bdf_fonts;5142 struct font_info *retval = NULL;5143 5144 bdf_fonts = w32_list_bdf_fonts (build_string (fontname));5145 5146 while (!retval && CONSP (bdf_fonts))5147 {5148 char *bdf_name, *bdf_file;5149 Lisp_Object bdf_pair;5150 5151 bdf_name = XSTRING (XCONS (bdf_fonts)->car)->data;5152 bdf_pair = Fassoc (XCONS (bdf_fonts)->car, Vw32_bdf_filename_alist);5153 bdf_file = XSTRING (XCONS (bdf_pair)->cdr)->data;5154 5155 retval = w32_load_bdf_font (f, bdf_name, size, bdf_file);5156 5157 bdf_fonts = XCONS (bdf_fonts)->cdr;5158 }5159 5160 if (retval)5161 return retval;5162 5163 return w32_load_system_font(f, fontname, size);5164 }5165 5166 5082 5167 5083 void … … 5172 5088 if (font) 5173 5089 { 5174 if (font->bdf) w32_free_bdf_font (font->bdf);5175 5176 5090 if (font->hfont) DeleteObject(font->hfont); 5177 5091 xfree (font); … … 5299 5213 if (stricmp (lpcs,"ansi") == 0) return ANSI_CHARSET; 5300 5214 else if (stricmp (lpcs,"iso8859-1") == 0) return ANSI_CHARSET; 5301 else if (stricmp (lpcs, " ms-symbol") == 0)return SYMBOL_CHARSET;5215 else if (stricmp (lpcs, "symbol") == 0) return SYMBOL_CHARSET; 5302 5216 else if (stricmp (lpcs, "jis") == 0) return SHIFTJIS_CHARSET; 5303 else if (stricmp (lpcs, "ksc5601 .1987") == 0)return HANGEUL_CHARSET;5217 else if (stricmp (lpcs, "ksc5601") == 0) return HANGEUL_CHARSET; 5304 5218 else if (stricmp (lpcs, "gb2312") == 0) return GB2312_CHARSET; 5305 5219 else if (stricmp (lpcs, "big5") == 0) return CHINESEBIG5_CHARSET; 5306 else if (stricmp (lpcs, " ms-oem") == 0)return OEM_CHARSET;5220 else if (stricmp (lpcs, "oem") == 0) return OEM_CHARSET; 5307 5221 5308 5222 #ifdef EASTEUROPE_CHARSET … … 5320 5234 else if (stricmp (lpcs, "tis620") == 0) return THAI_CHARSET; 5321 5235 else if (stricmp (lpcs, "mac") == 0) return MAC_CHARSET; 5322 else if (stricmp (lpcs, "ksc5601.1992") == 0) return JOHAB_CHARSET;5323 /* For backwards compatibility with previous 20.4 pretests. */5324 else if (stricmp (lpcs, "ksc5601") == 0) return HANGEUL_CHARSET;5325 else if (stricmp (lpcs, "johab") == 0) return JOHAB_CHARSET;5326 5236 #endif 5327 5237 … … 5346 5256 case ANSI_CHARSET: return "iso8859-1"; 5347 5257 case DEFAULT_CHARSET: return "ascii-*"; 5348 case SYMBOL_CHARSET: return " ms-symbol";5258 case SYMBOL_CHARSET: return "*-symbol"; 5349 5259 case SHIFTJIS_CHARSET: return "jisx0208-sjis"; 5350 case HANGEUL_CHARSET: return "ksc5601 .1987-*";5260 case HANGEUL_CHARSET: return "ksc5601-*"; 5351 5261 case GB2312_CHARSET: return "gb2312-*"; 5352 5262 case CHINESEBIG5_CHARSET: return "big5-*"; 5353 case OEM_CHARSET: return " ms-oem";5263 case OEM_CHARSET: return "*-oem"; 5354 5264 5355 5265 /* More recent versions of Windows (95 and NT4.0) define more … … 5359 5269 case TURKISH_CHARSET: return "iso8859-9"; 5360 5270 case BALTIC_CHARSET: return "iso8859-4"; 5361 5362 /* W95 with international support but not IE4 often has the 5363 KOI8-R codepage but not ISO8859-5. */ 5364 case RUSSIAN_CHARSET: 5365 if (!IsValidCodePage(28595) && IsValidCodePage(20886)) 5366 return "koi8-r"; 5367 else 5368 return "iso8859-5"; 5271 case RUSSIAN_CHARSET: return "koi8-r"; 5369 5272 case ARABIC_CHARSET: return "iso8859-6"; 5370 5273 case GREEK_CHARSET: return "iso8859-7"; … … 5372 5275 case VIETNAMESE_CHARSET: return "viscii1.1-*"; 5373 5276 case THAI_CHARSET: return "tis620-*"; 5374 case MAC_CHARSET: return "mac-*"; 5375 case JOHAB_CHARSET: return "ksc5601.1992-*"; 5277 case MAC_CHARSET: return "*-mac"; 5278 /* Johab is Korean, but Hangeul is the standard - what is this? */ 5279 case JOHAB_CHARSET: return "*-johab"; 5376 5280 5377 5281 #endif … … 5392 5296 int len; 5393 5297 { 5394 char *fontname;5298 char fontname[50]; 5395 5299 char height_pixels[8]; 5396 5300 char height_dpi[8]; 5397 5301 char width_pixels[8]; 5398 5302 char *fontname_dash; 5399 int display_resy = one_w32_display_info.height_in;5400 int display_resx = one_w32_display_info.width_in;5401 int bufsz;5402 struct coding_system coding;5403 5303 5404 5304 if (!lpxstr) abort (); … … 5407 5307 return FALSE; 5408 5308 5409 setup_coding_system (Fcheck_coding_system (Vw32_system_coding_system), 5410 &coding); 5411 coding.mode |= CODING_MODE_LAST_BLOCK; 5412 bufsz = decoding_buffer_size (&coding, LF_FACESIZE); 5413 5414 fontname = alloca(sizeof(*fontname) * bufsz); 5415 decode_coding (&coding, lplogfont->lfFaceName, fontname, 5416 strlen(lplogfont->lfFaceName), bufsz - 1); 5417 *(fontname + coding.produced) = '\0'; 5309 strncpy (fontname, lplogfont->lfFaceName, 50); 5310 fontname[49] = '\0'; /* Just in case */ 5418 5311 5419 5312 /* Replace dashes with underscores so the dashes are not 5420 misinterpreted .*/5313 misinterpreted */ 5421 5314 fontname_dash = fontname; 5422 5315 while (fontname_dash = strchr (fontname_dash, '-')) … … 5427 5320 sprintf (height_pixels, "%u", abs (lplogfont->lfHeight)); 5428 5321 sprintf (height_dpi, "%u", 5429 abs (lplogfont->lfHeight) * 720 / display_resy);5322 (abs (lplogfont->lfHeight) * 720) / one_w32_display_info.height_in); 5430 5323 } 5431 5324 else … … 5440 5333 5441 5334 _snprintf (lpxstr, len - 1, 5442 "-*-%s-%s-%c-*-*-%s-%s- %d-%d-%c-%s-%s",5335 "-*-%s-%s-%c-*-*-%s-%s-*-*-%c-%s-%s", 5443 5336 /* foundry */ 5444 5337 fontname, /* family */ … … 5449 5342 height_pixels, /* pixel size */ 5450 5343 height_dpi, /* point size */ 5451 display_resx,/* resx */5452 display_resy,/* resy */5344 /* resx */ 5345 /* resy */ 5453 5346 ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) 5454 5347 ? 'p' : 'c', /* spacing */ … … 5467 5360 LOGFONT * lplogfont; 5468 5361 { 5469 struct coding_system coding;5470 5471 5362 if (!lplogfont) return (FALSE); 5472 5363 5473 5364 memset (lplogfont, 0, sizeof (*lplogfont)); 5474 5365 … … 5500 5391 if (*lpxstr == '-') 5501 5392 { 5502 int fields, tem; 5503 char name[50], weight[20], slant, pitch, pixels[10], height[10], 5504 width[10], resy[10], remainder[20]; 5393 int fields; 5394 char name[50], weight[20], slant, pitch, pixels[10], height[10], width[10], remainder[20]; 5505 5395 char * encoding; 5506 int dpi = one_w32_display_info.height_in;5507 5396 5508 5397 fields = sscanf (lpxstr, 5509 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%9[^-]-%c-%9[^-]-%19s", 5510 name, weight, &slant, pixels, height, resy, &pitch, width, remainder); 5398 "-%*[^-]-%49[^-]-%19[^-]-%c-%*[^-]-%*[^-]-%9[^-]-%9[^-]-%*[^-]-%*[^-]-%c-%9[^-]-%19s", 5399 name, weight, &slant, pixels, height, &pitch, width, remainder); 5400 5511 5401 if (fields == EOF) return (FALSE); 5512 5402 5513 5403 if (fields > 0 && name[0] != '*') 5514 5404 { 5515 int bufsize; 5516 unsigned char *buf; 5517 5518 setup_coding_system 5519 (Fcheck_coding_system (Vw32_system_coding_system), &coding); 5520 bufsize = encoding_buffer_size (&coding, strlen (name)); 5521 buf = (unsigned char *) alloca (bufsize); 5522 coding.mode |= CODING_MODE_LAST_BLOCK; 5523 encode_coding (&coding, name, buf, strlen (name), bufsize); 5524 if (coding.produced >= LF_FACESIZE) 5525 coding.produced = LF_FACESIZE - 1; 5526 buf[coding.produced] = 0; 5527 strcpy (lplogfont->lfFaceName, buf); 5405 strncpy (lplogfont->lfFaceName,name, LF_FACESIZE); 5406 lplogfont->lfFaceName[LF_FACESIZE-1] = 0; 5528 5407 } 5529 5408 else … … 5547 5426 5548 5427 fields--; 5428 5429 if (fields > 0 && lplogfont->lfHeight == 0 && height[0] != '*') 5430 lplogfont->lfHeight = (atoi (height) 5431 * one_w32_display_info.height_in) / 720; 5432 5549 5433 fields--; 5550 if (fields > 0 && resy[0] != '*') 5551 { 5552 tem = atoi (pixels); 5553 if (tem > 0) dpi = tem; 5554 } 5555 5556 if (fields > -1 && lplogfont->lfHeight == 0 && height[0] != '*') 5557 lplogfont->lfHeight = atoi (height) * dpi / 720; 5558 5559 if (fields > 0) 5434 5560 5435 lplogfont->lfPitchAndFamily = 5561 5436 (fields > 0 && pitch == 'p') ? VARIABLE_PITCH : FIXED_PITCH; … … 5627 5502 char * lpszfont2; 5628 5503 { 5629 char * s1 = lpszfont1, *e1 , *w1;5630 char * s2 = lpszfont2, *e2 , *w2;5504 char * s1 = lpszfont1, *e1; 5505 char * s2 = lpszfont2, *e2; 5631 5506 5632 5507 if (s1 == NULL || s2 == NULL) return (FALSE); … … 5637 5512 while (1) 5638 5513 { 5639 int len1, len2 , len3=0;5514 int len1, len2; 5640 5515 5641 5516 e1 = strchr (s1, '-'); 5642 5517 e2 = strchr (s2, '-'); 5643 w1 = strchr (s1, '*'); 5644 w2 = strchr (s2, '*'); 5645 5646 if (e1 == NULL) 5647 len1 = strlen (s1); 5648 else 5518 5519 if (e1 == NULL || e2 == NULL) return (TRUE); 5520 5649 5521 len1 = e1 - s1; 5650 if (e2 == NULL)5651 len2 = strlen (s1);5652 else5653 5522 len2 = e2 - s2; 5654 5523 5655 if (w1 && w1 < e1) 5656 len3 = w1 - s1; 5657 if (w2 && w2 < e2 && ( len3 == 0 || (w2 - s2) < len3)) 5658 len3 = w2 - s2; 5659 5660 /* Whole field is not a wildcard, and ...*/ 5661 if (*s1 != '*' && *s2 != '*' && *s1 != '-' && *s2 != '-' 5662 /* Lengths are different and there are no wildcards, or ... */ 5663 && ((len1 != len2 && len3 == 0) || 5664 /* strings don't match up until first wildcard or end. */ 5665 strnicmp (s1, s2, len3 > 0 ? len3 : len1) != 0)) 5524 if (*s1 != '*' && *s2 != '*' 5525 && (len1 != len2 || strnicmp (s1, s2, len1) != 0)) 5666 5526 return (FALSE); 5667 5668 if (e1 == NULL || e2 == NULL)5669 return (TRUE);5670 5527 5671 5528 s1 = e1 + 1; … … 5673 5530 } 5674 5531 } 5675 5676 /* Callback functions, and a structure holding info they need, for5677 listing system fonts on W32. We need one set of functions to do the5678 job properly, but these don't work on NT 3.51 and earlier, so we5679 have a second set which don't handle character sets properly to5680 fall back on.5681 5682 In both cases, there are two passes made. The first pass gets one5683 font from each family, the second pass lists all the fonts from5684 each family. */5685 5532 5686 5533 typedef struct enumfont_t … … 5691 5538 XFontStruct *size_ref; 5692 5539 Lisp_Object *pattern; 5540 Lisp_Object *head; 5693 5541 Lisp_Object *tail; 5694 5542 } enumfont_t; … … 5721 5569 lplf->elfLogFont.lfWidth = lpef->logfont.lfWidth; 5722 5570 } 5723 /* Make sure the height used here is the same as everywhere5724 else (ie character height, not cell height). */5725 else if (lplf->elfLogFont.lfHeight > 0)5726 lplf->elfLogFont.lfHeight = lptm->tmInternalLeading - lptm->tmHeight;5727 5571 5728 5572 /* The MaxCharWidth is not valid at this stage for scalable fonts. */ … … 5730 5574 width = make_number (lptm->tmMaxCharWidth); 5731 5575 5732 if (!w32_to_x_font (&(lplf->elfLogFont), buf, 100)) 5733 return (0); 5734 5735 if (NILP (*(lpef->pattern)) 5736 || w32_font_match (buf, XSTRING (*(lpef->pattern))->data)) 5576 if (!w32_to_x_font (lplf, buf, 100)) return (0); 5577 5578 if (NILP (*(lpef->pattern)) || w32_font_match (buf, XSTRING (*(lpef->pattern))->data)) 5737 5579 { 5738 5580 *lpef->tail = Fcons (Fcons (build_string (buf), width), Qnil); … … 5759 5601 5760 5602 5761 int CALLBACK5762 enum_fontex_cb2 (lplf, lptm, font_type, lpef)5763 ENUMLOGFONTEX * lplf;5764 NEWTEXTMETRICEX * lptm;5765 int font_type;5766 enumfont_t * lpef;5767 {5768 /* We are not interested in the extra info we get back from the 'Ex5769 version - only the fact that we get character set variations5770 enumerated seperately. */5771 return enum_font_cb2 ((ENUMLOGFONT *) lplf, (NEWTEXTMETRIC *) lptm,5772 font_type, lpef);5773 }5774 5775 int CALLBACK5776 enum_fontex_cb1 (lplf, lptm, font_type, lpef)5777 ENUMLOGFONTEX * lplf;5778 NEWTEXTMETRICEX * lptm;5779 int font_type;5780 enumfont_t * lpef;5781 {5782 HMODULE gdi32 = GetModuleHandle ("gdi32.dll");5783 FARPROC enum_font_families_ex5784 = GetProcAddress ( gdi32, "EnumFontFamiliesExA");5785 /* We don't really expect EnumFontFamiliesEx to disappear once we5786 get here, so don't bother handling it gracefully. */5787 if (enum_font_families_ex == NULL)5788 error ("gdi32.dll has disappeared!");5789 return enum_font_families_ex (lpef->hdc,5790 &lplf->elfLogFont,5791 (FONTENUMPROC) enum_fontex_cb2,5792 (LPARAM) lpef, 0);5793 }5794 5795 5603 /* Interface to fontset handler. (adapted from mw32font.c in Meadow 5796 5604 and xterm.c in Emacs 20.3) */ 5797 5798 Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names)5799 {5800 char *fontname, *ptnstr;5801 Lisp_Object list, tem, newlist = Qnil;5802 int n_fonts;5803 5804 list = Vw32_b
