diff -Nur xemacs-21.4.13.orig/configure.in xemacs-21.4.13/configure.in --- xemacs-21.4.13.orig/configure.in 2003-03-21 12:37:49.000000000 +0900 +++ xemacs-21.4.13/configure.in 2003-06-03 23:35:59.000000000 +0900 @@ -2988,6 +2988,11 @@ [need_event_unixoid=yes; AC_DEFINE(HAVE_MSG_SELECT)]) with_file_coding=yes XE_ADD_OBJS(console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o glyphs-msw.o gui-msw.o) + if test "$with_mule" = "yes" ; then + AC_DEFINE(HAVE_IME) + XE_APPEND(-limm32, libs_system) + XE_ADD_OBJS(input-method-msw.o) + fi fi fi diff -Nur xemacs-21.4.13.orig/lisp/dumped-lisp.el xemacs-21.4.13/lisp/dumped-lisp.el --- xemacs-21.4.13.orig/lisp/dumped-lisp.el 2001-04-13 03:21:17.000000000 +0900 +++ xemacs-21.4.13/lisp/dumped-lisp.el 2003-06-03 23:35:59.000000000 +0900 @@ -214,6 +214,7 @@ (when-feature gtk "widgets-gtk") ;; preload the mswindows code. + (when-feature (and mule mswindows) "mule-msw") (when-feature mswindows "msw-glyphs") (when-feature mswindows "msw-faces") (when-feature mswindows "msw-mouse") diff -Nur xemacs-21.4.13.orig/lisp/faces.el xemacs-21.4.13/lisp/faces.el --- xemacs-21.4.13.orig/lisp/faces.el 2002-08-20 20:34:37.000000000 +0900 +++ xemacs-21.4.13/lisp/faces.el 2003-06-03 23:35:59.000000000 +0900 @@ -1062,7 +1062,9 @@ '(x) locale tags)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-make-font-bold - '(mswindows) locale tags)) + '(mswindows) locale tags) + (frob-face-property face 'font 'mswindows-make-font-bold + '(msprinter) locale tags)) ) '(([default] . [bold]) ([bold] . t) @@ -1092,7 +1094,9 @@ '(x) locale tags)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-make-font-italic - '(mswindows) locale tags)) + '(mswindows) locale tags) + (frob-face-property face 'font 'mswindows-make-font-italic + '(msprinter) locale tags)) ) '(([default] . [italic]) ([bold] . [bold-italic]) @@ -1123,7 +1127,9 @@ '(x) locale tags)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-make-font-bold-italic - '(mswindows) locale tags)) + '(mswindows) locale tags) + (frob-face-property face 'font 'mswindows-make-font-bold-italic + '(msprinter) locale tags)) ) '(([default] . [italic]) ([bold] . [bold-italic]) @@ -1153,7 +1159,9 @@ '(x) locale tags)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-make-font-unbold - '(mswindows) locale tags)) + '(mswindows) locale tags) + (frob-face-property face 'font 'mswindows-make-font-unbold + '(msprinter) locale tags)) ) '(([default] . t) ([bold] . [default]) @@ -1183,7 +1191,9 @@ '(x) locale tags)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-make-font-unitalic - '(mswindows) locale tags)) + '(mswindows) locale tags) + (frob-face-property face 'font 'mswindows-make-font-unitalic + '(msprinter) locale tags)) ) '(([default] . t) ([bold] . t) @@ -1223,7 +1233,9 @@ '(x) locale)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-find-smaller-font - '(mswindows) locale))) + '(mswindows) locale) + (frob-face-property face 'font 'mswindows-find-smaller-font + '(msprinter) locale))) (defun make-face-larger (face &optional locale) "Make the font of FACE be larger, if possible. @@ -1235,7 +1247,9 @@ '(x) locale)) (when (featurep 'mswindows) (frob-face-property face 'font 'mswindows-find-larger-font - '(mswindows) locale))) + '(mswindows) locale) + (frob-face-property face 'font 'mswindows-find-larger-font + '(msprinter) locale))) (defun invert-face (face &optional locale) "Swap the foreground and background colors of the face." diff -Nur xemacs-21.4.13.orig/lisp/msw-font-menu.el xemacs-21.4.13/lisp/msw-font-menu.el --- xemacs-21.4.13.orig/lisp/msw-font-menu.el 2002-08-20 20:34:54.000000000 +0900 +++ xemacs-21.4.13/lisp/msw-font-menu.el 2003-06-03 23:35:59.000000000 +0900 @@ -63,9 +63,7 @@ when they are selected for the first time. If you add fonts to your system, or if you change your font path, you can call this to re-initialize the menus." (unless mswindows-font-regexp-ascii - (setq mswindows-font-regexp-ascii (if (featurep 'mule) - (charset-registry 'ascii) - "Western"))) + (setq mswindows-font-regexp-ascii "Western")) (setq mswindows-font-menu-registry-encoding (if (featurep 'mule) "" "Western")) (let ((case-fold-search t) family size weight entry diff -Nur xemacs-21.4.13.orig/lisp/mule/mule-msw.el xemacs-21.4.13/lisp/mule/mule-msw.el --- xemacs-21.4.13.orig/lisp/mule/mule-msw.el 1970-01-01 09:00:00.000000000 +0900 +++ xemacs-21.4.13/lisp/mule/mule-msw.el 2003-06-03 23:35:59.000000000 +0900 @@ -0,0 +1,250 @@ +;;; mule-msw.el --- Mule support stuff for MS Windows +;; Copyright (C) 2000 IKEYAMA Tomonori + +;; This file is part of XEmacs. +;; +;; XEmacs 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 2, or (at your option) +;; any later version. +;; +;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Synched up with: Not in FSF. + +;;; Commentary: + +;;; Code: + +;; Charsets to Windows Codepage mapping. +(let ((l '((ascii . 1252) + (latin-iso8859-2 . 1250) + (cyrillic-iso8859-5 . 1251) + (latin-iso8859-1 . 1252) + (greek-iso8859-7 . 1253) + (latin-iso8859-9 . 1254) + (hebrew-iso8859-8 . 1255) + ;; (arabic-iso8859-6 . 1256) + (latin-iso8859-4 . 1257) + ;; (vietnamese-viscii-lower . 1258) + ;; (vietnamese-viscii-upper . 1258) + ;; (thai-tis620 . 874) + (latin-jisx0201 . 932) + (katakana-jisx0201 . 932) + (japanese-jisx0208-1978 . 932) + (japanese-jisx0208 . 932) + ;; (japanese-jisx0212 . 932) + (chinese-gb2312 . 936) + (korean-ksc5601 . 949) + (chinese-big5-1 . 950) + (chinese-big5-2 . 950)))) + (while l + (let ((charset (car (car l))) + (codepage (cdr (car l)))) + (mswindows-set-charset-codepage charset codepage) + (setq l (cdr l))))) + +;; Charset to font encoder mapping. + +;; Japanese JISX0208 +(let ((ccl-program + (ccl-compile + '(0 + ((r1 = (r1 en-sjis r2)) + (r2 = r7)))))) + (mswindows-set-charset-ccl-program 'japanese-jisx0208 ccl-program) + (mswindows-set-charset-ccl-program 'japanese-jisx0208-1978 ccl-program)) + +;; Chinese GB2312 and Korean KSC5601 +(let ((ccl-program + (ccl-compile + '(0 + (r1 |= ?\x80) + (r2 |= ?\x80))))) + (mswindows-set-charset-ccl-program 'chinese-gb2312 ccl-program) + (mswindows-set-charset-ccl-program 'korean-ksc5601 ccl-program)) + +;; Chinese BIG5 +(mswindows-set-charset-ccl-program 'chinese-big5-1 ccl-encode-big5-font) +(mswindows-set-charset-ccl-program 'chinese-big5-2 ccl-encode-big5-font) + +;; Here are Windows Codepage decoding tables from the codepage.el in +;; FSF Emacs. The codepage.el doesn't work on XEmacs because our CCL +;; dosen't have 'translate-character command. This is available only +;; for font encoder at the moment. + +;; start importing from codepage.el + +;; Support for the Windows 12xx series of codepages that MS has +;; butchered from the ISO-8859 specs. This does not add support for +;; the extended characters that MS has added in the 128 - 159 coding +;; range, only translates those characters that can be expressed in +;; the corresponding iso-8859 codepage. + +;; Codepage Mapping: +;; +;; Windows-1250: ISO-8859-2 (Central Europe) - differs in some positions +;; Windows-1251: ISO-8859-5 (Cyrillic) - differs wildly +;; Windows-1252: ISO-8859-1 (West Europe) - exact match +;; Windows-1253: ISO-8859-7 (Greek) - differs in some positions +;; Windows-1254: ISO-8859-9 (Turkish) - exact match +;; Windows-1255: ISO-8859-8 (Hebrew) - exact match +;; Windows-1256: ISO-8859-6 (Arabic) - half match +;; Windows-1257: ISO-8859-4 (Baltic) - differs, future Latin-7 +;; Windows-1258: VISCII (Vietnamese) - Completely different + +(defvar cp1250-decode-table + [ + 160 165 162 163 164 188 140 167 168 138 170 141 143 173 142 175 + 176 185 178 179 180 190 156 161 184 154 186 157 159 189 158 191 + 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 ] + "ISO-8859-2 to Windows-1250 (Central Europe) codepage decoding table") +(setplist 'cp1250-decode-table + '(charset latin-iso8859-2 language "Latin-2" offset 160)) + +(defvar cp1251-decode-table + [ + 160 168 128 129 170 189 178 175 163 138 140 142 141 173 161 143 + 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 + 185 184 144 131 186 190 179 191 188 154 156 158 157 167 162 159 ] + "ISO-8859-5 to Windows-1251 (Cyrillic) codepage decoding table") +(setplist 'cp1251-decode-table + '(charset cyrillic-iso8859-5 language "Cyrillic-ISO" offset 160)) + +;; cp1253 is missing nbsp so we cannot quite translate perfectly. It +;; also has two micro/mu characters which would require more complex +;; processing to accomodate. +(defvar cp1253-decode-table + [ + nil 145 146 163 nil nil 166 167 168 169 nil 171 172 173 nil 151 + 176 177 178 179 180 161 162 183 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 + 208 209 nil 211 212 213 214 215 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 nil ] + "ISO-8859-7 to Windows-1253 (Greek) codepage decoding table") +(setplist 'cp1253-decode-table + '(charset greek-iso8859-7 language "Greek" offset 160)) + +;; Since Latin-7 is not yet official, and Emacs does not support it, +;; provide translation between Windows-1257 and Latin-4 the best we +;; can. +(defvar cp1257-decode-table + [ + 160 192 nil 170 164 nil 207 167 nil 208 199 204 nil 173 222 nil + 176 224 nil 186 nil nil 239 nil nil 240 231 236 nil nil 254 nil + 194 nil nil nil 196 197 175 193 200 201 198 nil 203 nil nil 206 + nil 210 212 205 nil 213 214 215 168 216 nil nil 220 nil 219 223 + 226 nil nil nil 228 229 191 225 232 233 230 nil 235 nil nil 238 + nil 242 244 237 nil 245 246 247 184 248 nil nil 252 nil 251 nil ] + "ISO-8859-4 to Windows-1257 (Baltic) codepage decoding table") +(setplist 'cp1257-decode-table + '(charset latin-iso8859-4 language "Latin-4" offset 160)) + +;; end of import from codepage.el + +;; Make font encoders from the decoding tables. + +;; Translating all of mappings to CCL 'if' statements. This way is +;; very nasty. Is there better way to make a font encoder for +;; Windows-125x codepages ? +(let ((l '(cp1250-decode-table + cp1251-decode-table + cp1253-decode-table + cp1257-decode-table))) + (while l + (let ((decoder (car l)) + (i 0) + offset charset table len + font-encoder ccl-program) + (setq offset (get decoder 'offset) + charset (get decoder 'charset) + table (symbol-value decoder) + len (length table)) + (while (< i len) + (let ((from (+ i offset)) + (to (aref table i))) + (if (not to) + ;; map to '~' + (setq to ?~)) + (if (not (eq from to)) + (setq font-encoder (cons `(if (r1 == ,from) (r1 = ,to)) + font-encoder))) + (setq i (1+ i)))) + (setq ccl-program (ccl-compile `(0 ,font-encoder))) + (mswindows-set-charset-ccl-program charset ccl-program) + (setq l (cdr l))))) + +;; Codepage to language and coding system mappings. +;; To complete this list, we need more coding systems adapted for +;; Windows codepages. +(defvar mswindows-codepage-info-alist + '( + ;; (1250 (language . "Latin-2") + ;; (coding-system . windows-1250)) + (1251 (language . "Cyrillic-Win") + (coding-system . windows-1251)) + (1252 (language . "Latin-1") + (coding-system . iso-8859-1)) + ;; (1253 (language . "Greek") + ;; (coding-system . windows-1253)) + (1254 (language . "Latin-5") + (coding-system . iso-8859-9)) + (1255 (language . "Hebrew") + (coding-system . iso-8859-8)) + ;; (1256 (language . "Arabic") + ;; (coding-system . windows-1256)) + ;; (1257 (language . "Baltic") + ;; (coding-system . windows-1257)) + ;; (1258 (language . "Vietnamese") + ;; (coding-system . windows-1258)) + ;; (874 (language . "Thai") + ;; (coding-system . windows-874)) + (932 (language . "Japanese") + (coding-system . shift_jis)) + ;; (936 (language . "Chinese-GB") + ;; (coding-system . gb2312)) + ;; (949 (language . "Korean") + ;; (coding-system . ksc5601)) + (950 (language . "Chinese-BIG5") + (coding-system . big5)))) + +(defun mswindows-set-codepage-envirionment (codepage) + "Set language environment and native coding system for the CODEPAGE." + (let ((slot (cdr (assq codepage mswindows-codepage-info-alist))) + language coding-system) + ;; language + (setq language (cdr (assq 'language slot))) + (if language + (set-language-environment language)) + ;; coding system + (setq coding-system (cdr (assq 'coding-system slot))) + (when coding-system + (setq coding-system (coding-system-eol-crlf coding-system)) + (prefer-coding-system coding-system) + ;; Snatch 'file-name from file-name-coding-system for setting + ;; the coding system depend on the current codepage. + (dontusethis-set-symbol-value-handler 'file-name-coding-system + 'set-value nil) + (define-coding-system-alias 'file-name coding-system)))) + +(defun mswindows-setup-for-system-codepage () + "Setup environment fot the current system's codepage." + (mswindows-set-codepage-envirionment (mswindows-system-codepage))) + +;; Should be called after init-mule. +(add-hook 'before-init-hook 'mswindows-setup-for-system-codepage t) diff -Nur xemacs-21.4.13.orig/lisp/select.el xemacs-21.4.13/lisp/select.el --- xemacs-21.4.13.orig/lisp/select.el 2002-08-20 20:35:04.000000000 +0900 +++ xemacs-21.4.13/lisp/select.el 2003-06-03 23:35:59.000000000 +0900 @@ -682,14 +682,17 @@ ;;; CF_xxx conversions (defun select-convert-from-cf-text (selection type value) - (replace-in-string (if (string-match "\0" value) - (substring value 0 (match-beginning 0)) - value) - "\\(\r\n\\|\n\r\\)" "\n" t)) + (let ((value (decode-coding-string value (coding-system-base 'file-name)))) + (replace-in-string (if (string-match "\0" value) + (substring value 0 (match-beginning 0)) + value) + "\\(\r\n\\|\n\r\\)" "\n" t))) (defun select-convert-to-cf-text (selection type value) (let ((text (select-convert-to-text selection type value))) - (concat (replace-in-string text "\n" "\r\n" t) "\0"))) + (encode-coding-string + (concat (replace-in-string text "\n" "\r\n" t) "\0") + (coding-system-base 'file-name)))) ;;; Appenders (defun select-append-to-text (selection type value1 value2) diff -Nur xemacs-21.4.13.orig/nt/config.h xemacs-21.4.13/nt/config.h --- xemacs-21.4.13.orig/nt/config.h 2001-04-13 03:22:59.000000000 +0900 +++ xemacs-21.4.13/nt/config.h 2003-06-03 23:35:59.000000000 +0900 @@ -576,6 +576,16 @@ #define ENCAPSULATE_STAT #define ENCAPSULATE_FSTAT +#ifdef MULE +# define ENCAPSULATE_CHDIR +# define ENCAPSULATE_RMDIR +# define ENCAPSULATE_ACCESS +# define ENCAPSULATE_CHMOD +# define ENCAPSULATE_CREAT +# define ENCAPSULATE_UNLINK +# define ENCAPSULATE_EXECVP +#endif /* MULE */ + #if defined (HAVE_SOCKS) && !defined (DO_NOT_SOCKSIFY) #define accept Raccept #define bind Rbind diff -Nur xemacs-21.4.13.orig/nt/xemacs.mak xemacs-21.4.13/nt/xemacs.mak --- xemacs-21.4.13.orig/nt/xemacs.mak 2003-01-03 18:59:17.000000000 +0900 +++ xemacs-21.4.13/nt/xemacs.mak 2003-06-03 23:35:59.000000000 +0900 @@ -433,7 +433,7 @@ !endif !if $(HAVE_MULE) -MULE_DEFINES=-DMULE +MULE_DEFINES=-DMULE -DHAVE_IME !endif !if $(DEBUG_XEMACS) @@ -795,8 +795,11 @@ $(SRC)\mule-charset.c \ $(SRC)\mule-ccl.c ! if $(HAVE_X_WINDOWS) - DOC_SRC8=$(DOC_SRC8) $(SRC)\input-method-xlib.c +DOC_SRC8=$(DOC_SRC8) $(SRC)\input-method-xlib.c ! endif +!if $(HAVE_MS_WINDOWS) +DOC_SRC8=$(DOC_SRC8) $(SRC)\input-method-msw.c +!endif !endif !if $(DEBUG_XEMACS) @@ -845,8 +848,9 @@ TEMACS_BROWSE=$(TEMACS_DIR)\temacs.bsc TEMACS_SRC=$(SRC) TEMACS_LIBS=$(LASTFILE) $(LWLIB) $(X_LIBS) $(MSW_LIBS) \ - oldnames.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib \ - shell32.lib wsock32.lib winmm.lib winspool.lib ole32.lib uuid.lib $(LIBC_LIB) + oldnames.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib \ + advapi32.lib shell32.lib wsock32.lib winmm.lib winspool.lib \ + ole32.lib uuid.lib imm32.lib $(LIBC_LIB) TEMACS_LFLAGS=-nologo $(LIBRARIES) $(DEBUG_FLAGS) -base:0x1000000\ -stack:0x800000 $(TEMACS_ENTRYPOINT) -subsystem:windows\ -pdb:$(TEMACS_DIR)\temacs.pdb -map:$(TEMACS_DIR)\temacs.map \ @@ -914,6 +918,10 @@ TEMACS_MULE_OBJS=\ $(TEMACS_MULE_OBJS) $(OUTDIR)\input-method-xlib.obj ! endif +! if $(HAVE_MS_WINDOWS) +TEMACS_MULE_OBJS=\ + $(TEMACS_MULE_OBJS) $(OUTDIR)\input-method-msw.obj +! endif !endif !if $(DEBUG_XEMACS) @@ -1621,6 +1629,11 @@ $(XEMACS_BATCH) -l autoload -f batch-update-one-directory $(LISP) -f batch-byte-compile-one-file $(LISP)\auto-autoloads.el -l cus-dep -f Custom-make-one-dependency $(LISP) -f batch-byte-compile-one-file $(LISP)\custom-load.el $(DEL) $(LISP)\auto-autoloads.el~ $(DEL) $(LISP)\custom-load.el~ +!if $(HAVE_MULE) + $(XEMACS_BATCH) -l autoload -f batch-update-one-directory $(LISP)\mule -f batch-byte-compile-one-file $(LISP)\mule\auto-autoloads.el -l cus-dep -f Custom-make-one-dependency $(LISP)\mule -f batch-byte-compile-one-file $(LISP)\mule\custom-load.el + $(DEL) $(LISP)\mule\auto-autoloads.el~ + $(DEL) $(LISP)\mule\custom-load.el~ +!endif # DO NOT DELETE THIS LINE -- make depend depends on it. diff -Nur xemacs-21.4.13.orig/src/chartab.c xemacs-21.4.13/src/chartab.c --- xemacs-21.4.13.orig/src/chartab.c 2001-04-13 03:23:27.000000000 +0900 +++ xemacs-21.4.13/src/chartab.c 2003-06-03 23:35:59.000000000 +0900 @@ -1710,8 +1710,6 @@ struct buffer *buf = decode_buffer (buffer, 0); category_table = check_category_table (category_table, Qnil); buf->category_table = category_table; - /* Indicate that this buffer now has a specified category table. */ - buf->local_var_flags |= XINT (buffer_local_flags.category_table); return category_table; } diff -Nur xemacs-21.4.13.orig/src/config.h.in xemacs-21.4.13/src/config.h.in --- xemacs-21.4.13.orig/src/config.h.in 2003-03-21 12:36:27.000000000 +0900 +++ xemacs-21.4.13/src/config.h.in 2003-06-03 23:35:59.000000000 +0900 @@ -584,6 +584,9 @@ #undef HAVE_WNN #undef WNN6 +/* MS-Windows IME support */ +#undef HAVE_IME + /* Enable special GNU Make features in the Makefiles. */ #undef USE_GNU_MAKE @@ -772,9 +775,11 @@ #if defined (MULE) || defined (DEBUG_ENCAPSULATION) # define ENCAPSULATE_CHDIR # define ENCAPSULATE_MKDIR -# define ENCAPSULATE_OPENDIR -# define ENCAPSULATE_CLOSEDIR -# define ENCAPSULATE_READDIR +# ifndef WIN32_NATIVE +# define ENCAPSULATE_OPENDIR +# define ENCAPSULATE_CLOSEDIR +# define ENCAPSULATE_READDIR +# endif # define ENCAPSULATE_RMDIR /* file-information calls */ @@ -784,16 +789,20 @@ #endif # define ENCAPSULATE_ACCESS # define ENCAPSULATE_LSTAT -# define ENCAPSULATE_READLINK +# ifndef WIN32_NATIVE +# define ENCAPSULATE_READLINK +# endif # define ENCAPSULATE_STAT /* file-manipulation calls */ # define ENCAPSULATE_CHMOD # define ENCAPSULATE_CREAT -# define ENCAPSULATE_LINK +# ifndef WIN32_NATIVE +# define ENCAPSULATE_LINK +# define ENCAPSULATE_SYMLINK +# endif # define ENCAPSULATE_RENAME -# define ENCAPSULATE_SYMLINK # define ENCAPSULATE_UNLINK # define ENCAPSULATE_EXECVP #endif /* defined (MULE) || defined (DEBUG_ENCAPSULATION) */ diff -Nur xemacs-21.4.13.orig/src/console-msw.c xemacs-21.4.13/src/console-msw.c --- xemacs-21.4.13.orig/src/console-msw.c 2001-04-13 03:23:29.000000000 +0900 +++ xemacs-21.4.13/src/console-msw.c 2003-06-03 23:35:59.000000000 +0900 @@ -34,6 +34,11 @@ #include "events.h" #include "opaque.h" +#ifdef MULE +#include "mule-charset.h" +#include "elhash.h" +#endif + DEFINE_CONSOLE_TYPE (mswindows); DEFINE_CONSOLE_TYPE (msprinter); @@ -72,6 +77,10 @@ /* Lisp_Object Qretry; */ /* Lisp_Object Qyes; */ +#ifdef MULE +static Lisp_Object Qcharset_codepage_hash_table; +static Lisp_Object Qcharset_ccl_program_hash_table; +#endif /************************************************************************/ /* mswindows console methods */ @@ -601,6 +610,86 @@ { return msprinter_canonicalize_console_connection (connection, errb); } +#ifdef MULE +/************************************************************************/ +/* Mule functions */ +/************************************************************************/ + +DEFUN ("mswindows-charset-codepage", + Fmswindows_charset_codepage, 1, 1, 0, /* +Return the codepage for the CHARSET +*/ + (charset)) +{ + charset = Fget_charset (charset); + return Fgethash (charset, Qcharset_codepage_hash_table, Qnil); +} + +DEFUN ("mswindows-set-charset-codepage", + Fmswindows_set_charset_codepage, 2, 2, 0, /* +Set the CODEPAGE for the CHARSET +*/ + (charset, codepage)) +{ + charset = Fget_charset (charset); + CHECK_INT (codepage); + Fputhash (charset, codepage, Qcharset_codepage_hash_table); + return Qnil; +} + +DEFUN ("mswindows-charset-ccl-program", + Fmswindows_charset_ccl_program, 1, 1, 0, /* +Return the ccl program for the CHARSET +*/ + (charset)) +{ + charset = Fget_charset (charset); + return Fgethash (charset, Qcharset_ccl_program_hash_table, Qnil); +} + +DEFUN ("mswindows-set-charset-ccl-program", + Fmswindows_set_charset_ccl_program, 2, 2, 0, /* +Set the CCL-PROGRAM for the CHARSET +*/ + (charset, ccl_program)) +{ + charset = Fget_charset (charset); + CHECK_VECTOR (ccl_program); + Fputhash (charset, ccl_program, Qcharset_ccl_program_hash_table); + return Qnil; +} + +Lisp_Object +mswindows_get_codepage_charset (int codepage) +{ + Lisp_Object charset_tail; + Lisp_Object charset = Qunbound; + + LIST_LOOP (charset_tail, Fcharset_list ()) + { + Lisp_Object charset_codepage; + + charset_codepage = Fmswindows_charset_codepage (XCAR (charset_tail)); + if (INTP (charset_codepage) && + codepage == XINT (charset_codepage)) + { + charset = Fget_charset (XCAR (charset_tail)); + break; + } + } + return charset; +} + +DEFUN ("mswindows-system-codepage", + Fmswindows_system_codepage, 0, 0, 0, /* +Return the current codepage for the system +*/ + ()) +{ + return make_int (GetACP ()); +} + +#endif /* MULE */ /************************************************************************/ @@ -648,6 +737,22 @@ /* defsymbol (&Qyes, "yes"); */ DEFSUBR (Fmswindows_message_box); + +#ifdef MULE + DEFSUBR (Fmswindows_charset_codepage); + DEFSUBR (Fmswindows_set_charset_codepage); + Qcharset_codepage_hash_table = + make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); + staticpro (&Qcharset_codepage_hash_table); + + DEFSUBR (Fmswindows_charset_ccl_program); + DEFSUBR (Fmswindows_set_charset_ccl_program); + Qcharset_ccl_program_hash_table = + make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); + staticpro (&Qcharset_ccl_program_hash_table); + + DEFSUBR (Fmswindows_system_codepage); +#endif } void diff -Nur xemacs-21.4.13.orig/src/console-msw.h xemacs-21.4.13/src/console-msw.h --- xemacs-21.4.13.orig/src/console-msw.h 2002-08-20 20:36:43.000000000 +0900 +++ xemacs-21.4.13/src/console-msw.h 2003-06-03 23:35:59.000000000 +0900 @@ -205,6 +205,12 @@ FRAME_{HEIGHT,WIDTH} do not work for pixel geometry! */ int charheight, charwidth; +#ifdef HAVE_IME + int cursor_x; + int cursor_y; + face_index cursor_findex; +#endif + /* Misc flags */ int button2_need_lbutton : 1; int button2_need_rbutton : 1; @@ -220,6 +226,11 @@ XEMACS_RECT_WH* target_rect; }; +#ifdef MULE +EXFUN (Fmswindows_charset_codepage, 1); +EXFUN (Fmswindows_charset_ccl_program, 1); +#endif /* MULE */ + #define FRAME_MSWINDOWS_DATA(f) FRAME_TYPE_DATA (f, mswindows) #define FRAME_MSWINDOWS_HANDLE(f) (FRAME_MSWINDOWS_DATA (f)->hwnd) @@ -241,6 +252,11 @@ #define FRAME_MSWINDOWS_CHARHEIGHT(f) (FRAME_MSWINDOWS_DATA (f)->charheight) #define FRAME_MSWINDOWS_TARGET_RECT(f) (FRAME_MSWINDOWS_DATA (f)->target_rect) #define FRAME_MSWINDOWS_POPUP(f) (FRAME_MSWINDOWS_DATA (f)->popup) +#ifdef HAVE_IME +# define FRAME_MSWINDOWS_CURSOR_X(f) (FRAME_MSWINDOWS_DATA (f)->cursor_x) +# define FRAME_MSWINDOWS_CURSOR_Y(f) (FRAME_MSWINDOWS_DATA (f)->cursor_y) +# define FRAME_MSWINDOWS_CURSOR_FINDEX(f) (FRAME_MSWINDOWS_DATA (f)->cursor_findex) +#endif /* Frame check and validation macros */ #define FRAME_MSWINDOWS_P(frm) CONSOLE_TYPESYM_MSWINDOWS_P (FRAME_TYPE (frm)) @@ -387,6 +403,13 @@ Lisp_Object msprinter_default_printer (void); +#ifdef MULE +Lisp_Object mswindows_get_codepage_charset (int codepage); +# ifdef HAVE_IME +void mswindows_start_ime_compositon (struct frame *f); +# endif /* HAVE_IME */ +#endif /* MULE */ + struct mswindows_dialog_id { struct lcrecord_header header; diff -Nur xemacs-21.4.13.orig/src/console.h xemacs-21.4.13/src/console.h --- xemacs-21.4.13.orig/src/console.h 2002-11-01 00:07:32.000000000 +0900 +++ xemacs-21.4.13/src/console.h 2003-06-03 23:35:59.000000000 +0900 @@ -281,6 +281,10 @@ Lisp_Object (*locate_pixmap_file_method) (Lisp_Object file_method); int (*colorize_image_instance_method) (Lisp_Object image_instance, Lisp_Object fg, Lisp_Object bg); + void (*widget_query_string_geometry_method) (Lisp_Object string, + Lisp_Object face, + int* width, int* height, + Lisp_Object domain); Lisp_Object image_conversion_list; #ifdef HAVE_TOOLBARS diff -Nur xemacs-21.4.13.orig/src/device-msw.c xemacs-21.4.13/src/device-msw.c --- xemacs-21.4.13.orig/src/device-msw.c 2002-08-20 20:36:45.000000000 +0900 +++ xemacs-21.4.13/src/device-msw.c 2003-06-03 23:35:59.000000000 +0900 @@ -379,6 +379,8 @@ static int msprinter_init_device_internal (struct device *d, char* printer_name) { + HDC hdc; + DEVICE_MSPRINTER_NAME(d) = xstrdup (printer_name); if (!OpenPrinter (printer_name, &DEVICE_MSPRINTER_HPRINTER (d), NULL)) @@ -386,14 +388,14 @@ DEVICE_MSPRINTER_HPRINTER (d) = NULL; return 0; } - DEVICE_MSPRINTER_HDC (d) = CreateDC ("WINSPOOL", printer_name, NULL, NULL); if (DEVICE_MSPRINTER_HDC (d) == NULL) return 0; - DEVICE_MSPRINTER_HCDC(d) = - CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d)); + hdc = CreateCompatibleDC (DEVICE_MSPRINTER_HDC (d)); + DEVICE_MSPRINTER_HCDC(d) = hdc; + DEVICE_MSPRINTER_FONTLIST (d) = mswindows_enumerate_fonts (hdc); DEVICE_CLASS (d) = (GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), BITSPIXEL) * GetDeviceCaps (DEVICE_MSPRINTER_HDC (d), PLANES) @@ -458,11 +460,6 @@ DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1; DEVICE_MSPRINTER_DEVMODE(d) = Qnil; - /* We do not use printer fon list as we do with the display - device. Rather, we allow GDI to pick the closest match to the - display font. */ - DEVICE_MSPRINTER_FONTLIST (d) = Qnil; - CHECK_STRING (DEVICE_CONNECTION (d)); TO_EXTERNAL_FORMAT (LISP_STRING, DEVICE_CONNECTION (d), diff -Nur xemacs-21.4.13.orig/src/dialog-msw.c xemacs-21.4.13/src/dialog-msw.c --- xemacs-21.4.13.orig/src/dialog-msw.c 2002-08-20 20:36:47.000000000 +0900 +++ xemacs-21.4.13/src/dialog-msw.c 2003-06-03 23:35:59.000000000 +0900 @@ -273,7 +273,12 @@ static unsigned int button_width (Lisp_Object text) { - unsigned int width = X_DLU_PER_CHAR * XSTRING_CHAR_LENGTH (text); + Extbyte *text_ext; + unsigned int width; + + LISP_STRING_TO_EXTERNAL (text, text_ext, Qnative); + width = X_DLU_PER_CHAR * strlen (text_ext); + return max (X_MIN_BUTTON, width); } @@ -661,7 +666,7 @@ const WORD button_class_id = 0x0080; /* Create and stuff in DLGTEMPLATE header */ - dlg_tem.style = (DS_CENTER | DS_MODALFRAME | DS_SETFONT + dlg_tem.style = (DS_CENTER | DS_MODALFRAME | WS_CAPTION | WS_POPUP | WS_VISIBLE); dlg_tem.dwExtendedStyle = 0; dlg_tem.cdit = Dynarr_length (dialog_items) + 1; @@ -682,9 +687,6 @@ else push_lisp_string_as_unicode (template, title); - /* We want standard dialog font */ - Dynarr_add_many (template, L"\x08MS Shell Dlg", 28); - /* Next add text control. */ item_tem.style = WS_CHILD | WS_VISIBLE | SS_LEFT | SS_NOPREFIX; item_tem.dwExtendedStyle = 0; diff -Nur xemacs-21.4.13.orig/src/dumper.c xemacs-21.4.13/src/dumper.c --- xemacs-21.4.13.orig/src/dumper.c 2003-03-20 12:53:37.000000000 +0900 +++ xemacs-21.4.13/src/dumper.c 2003-06-03 23:35:59.000000000 +0900 @@ -32,7 +32,8 @@ #include "sysdep.h" #ifdef WIN32_NATIVE -#include "nt.h" +#define DONT_ENCAPSULATE +#include "syswindows.h" #else #ifdef HAVE_MMAP #include diff -Nur xemacs-21.4.13.orig/src/editfns.c xemacs-21.4.13/src/editfns.c --- xemacs-21.4.13.orig/src/editfns.c 2002-08-20 20:36:52.000000000 +0900 +++ xemacs-21.4.13/src/editfns.c 2003-06-03 23:35:59.000000000 +0900 @@ -1366,7 +1366,7 @@ sprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, am%60); s = buf; } - return list2 (make_int (offset), build_string (s)); + return list2 (make_int (offset), build_ext_string (s, Qnative)); } else return list2 (Qnil, Qnil); diff -Nur xemacs-21.4.13.orig/src/event-msw.c xemacs-21.4.13/src/event-msw.c --- xemacs-21.4.13.orig/src/event-msw.c 2002-11-01 00:07:41.000000000 +0900 +++ xemacs-21.4.13/src/event-msw.c 2003-06-03 23:35:59.000000000 +0900 @@ -1674,20 +1674,23 @@ if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)) { - DWORD len = DdeGetData (hdata, NULL, 0, 0); - LPBYTE cmd = (LPBYTE) alloca (len+1); - char *end; - char *filename; + Extcount len = DdeGetData (hdata, NULL, 0, 0); + Extbyte *cmd_ext = (Extbyte *) alloca (len); + Bufbyte *cmd; + Bufbyte *end; + Bufbyte *filename; struct gcpro gcpro1, gcpro2; Lisp_Object l_dndlist = Qnil; Lisp_Object emacs_event = Fmake_event (Qnil, Qnil); Lisp_Object frmcons, devcons, concons; Lisp_Event *event = XEVENT (emacs_event); - DdeGetData (hdata, cmd, len, 0); - cmd[len] = '\0'; + DdeGetData (hdata, cmd_ext, len, 0); DdeFreeDataHandle (hdata); + TO_INTERNAL_FORMAT (DATA, (cmd_ext, len), + C_STRING_ALLOCA, cmd, Qfile_name); + /* Check syntax & that it's an [Open("foo")] command, which we * treat like a file drop */ /* #### Ought to be generalised and accept some other commands */ @@ -2135,6 +2138,9 @@ break; case WM_KEYUP: + /* Key event within IME. */ + if (wParam == VK_PROCESSKEY) + break; case WM_SYSKEYUP: /* See Win95 comment under WM_KEYDOWN */ @@ -2174,6 +2180,21 @@ break; case WM_KEYDOWN: + if (wParam == VK_PROCESSKEY) + { + /* Key event within IME. Just call TranslateMessage(). */ + POINT pnt = { LOWORD (GetMessagePos()), HIWORD (GetMessagePos()) }; + MSG msg; + + msg.hwnd = hwnd; + msg.message = message_; + msg.wParam = wParam; + msg.lParam = lParam; + msg.time = GetMessageTime(); + msg.pt = pnt; + TranslateMessage (&msg); + break; + } case WM_SYSKEYDOWN: /* In some locales the right-hand Alt key is labelled AltGr. This key @@ -2279,6 +2300,10 @@ keymap_trans[VK_RMENU] = 0; keymap_trans[VK_MENU] = 0; } + + /* Clear KANA lock. */ + keymap_trans[VK_KANA] = 0; + SetKeyboardState (keymap_trans); /* Maybe generate some WM_[SYS]CHARs in the queue */ @@ -3071,11 +3096,8 @@ #ifdef HAVE_DRAGNDROP case WM_DROPFILES: /* implementation ripped-off from event-Xt.c */ { - UINT filecount, i, len; + UINT filecount, i; POINT point; - char* filename; - char* fname; - Lisp_Object l_dndlist = Qnil, l_item = Qnil; struct gcpro gcpro1, gcpro2, gcpro3; @@ -3098,20 +3120,23 @@ event->event.misc.function = Qdragdrop_drop_dispatch; filecount = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0); - for (i=0; i/ part and * because they may contain reserved characters. But that's OK - * they just need to be good enough to keep dragdrop.el happy. */ - fname = (char *)xmalloc (len+1); - DragQueryFile ((HANDLE) wParam, i, fname, len+1); + DragQueryFile ((HANDLE) wParam, i, fname_ext, len + 1); /* May be a shell link aka "shortcut" - replace fname if so */ #if !(defined(CYGWIN) || defined(MINGW)) /* cygwin doesn't define this COM stuff */ - if (!stricmp (fname + strlen (fname) - 4, ".LNK")) + if (!stricmp (fname_ext + strlen (fname_ext) - 4, ".LNK")) { IShellLink* psl; @@ -3123,19 +3148,19 @@ if (psl->lpVtbl->QueryInterface (psl, &IID_IPersistFile, &ppf) == S_OK) { - OLECHAR wsz[PATH_MAX]; + WCHAR wsz[MAX_PATH]; WIN32_FIND_DATA wfd; - LPSTR resolved = (char *) xmalloc (PATH_MAX+1); + Extbyte *resolved = (Extbyte *) xmalloc (MAX_PATH + 1); - MultiByteToWideChar (CP_ACP,0, fname, -1, wsz, PATH_MAX); + MultiByteToWideChar (CP_ACP, 0, fname_ext, -1, wsz, MAX_PATH); if ((ppf->lpVtbl->Load (ppf, wsz, STGM_READ) == S_OK) && (psl->lpVtbl->GetPath (psl, resolved, PATH_MAX, &wfd, 0)==S_OK)) { - xfree (fname); - fname = resolved; - len = strlen (fname); + xfree (fname_ext); + fname_ext = resolved; + len = strlen (fname_ext); } ppf->lpVtbl->Release (ppf); @@ -3146,16 +3171,20 @@ } #endif + EXTERNAL_TO_C_STRING_MALLOC (fname_ext, fname_int, Qfile_name); + len = strlen (fname_int); #ifdef CYGWIN - filename = xmalloc (cygwin_win32_to_posix_path_list_buf_size (fname) + 5); - strcpy (filename, "file:"); - cygwin_win32_to_posix_path_list (fname, filename+5); + filename = (Bufbyte *) xmalloc + (cygwin32_win32_to_posix_path_list_buf_size (fname_int) + 5); + strcpy (filename, "file:"); + cygwin32_win32_to_posix_path_list (fname_int, filename + 5); #else - filename = (char *)xmalloc (len+6); - strcat (strcpy (filename, "file:"), fname); - dostounix_filename (filename+5); + filename = (Bufbyte *) xmalloc (len + 6); + strcat (strcpy (filename, "file:"), fname_int); + dostounix_filename (filename + 5); #endif - xfree (fname); + xfree (fname_ext); + xfree (fname_int); l_item = make_string (filename, strlen (filename)); l_dndlist = Fcons (l_item, l_dndlist); xfree (filename); @@ -3168,6 +3197,44 @@ } break; #endif +#ifdef HAVE_IME + case WM_IME_STARTCOMPOSITION: + mswindows_start_ime_compositon (XFRAME (mswindows_find_frame (hwnd))); + goto defproc; + case WM_IME_COMPOSITION: + if (lParam & GCS_RESULTSTR) + { + HIMC imc = ImmGetContext (hwnd); + Extbyte *result; + Extcount len; + Bufbyte *resultint, *endptr; + Bytecount lenint; + + if (!imc) + break; + + len = ImmGetCompositionString (imc, GCS_RESULTSTR, NULL, 0); + result = alloca_array (Extbyte, len); + ImmGetCompositionString (imc, GCS_RESULTSTR, result, len); + ImmReleaseContext (hwnd, imc); + TO_INTERNAL_FORMAT (DATA, (result, len), + ALLOCA, (resultint, lenint), + Qmswindows_tstr); + + endptr = resultint + lenint; + + while (resultint < endptr) + { + Emchar ch = charptr_emchar (resultint); + if (ch == ' ') + mswindows_enqueue_keypress_event (hwnd, QKspace, 0); + else + mswindows_enqueue_keypress_event (hwnd, make_char (ch), 0); + INC_CHARPTR (resultint); + } + } + goto defproc; +#endif /* HAVE_IME */ defproc: default: diff -Nur xemacs-21.4.13.orig/src/event-stream.c xemacs-21.4.13/src/event-stream.c --- xemacs-21.4.13.orig/src/event-stream.c 2003-01-03 18:59:45.000000000 +0900 +++ xemacs-21.4.13/src/event-stream.c 2003-06-03 23:35:59.000000000 +0900 @@ -216,10 +216,10 @@ Lisp_Object Vretry_undefined_key_binding_unshifted; Lisp_Object Qretry_undefined_key_binding_unshifted; -#ifdef HAVE_XIM +#ifdef MULE /* If composed input is undefined, use self-insert-char */ Lisp_Object Vcomposed_character_default_binding; -#endif /* HAVE_XIM */ +#endif /* MULE */ /* Console that corresponds to our controlling terminal */ Lisp_Object Vcontrolling_terminal; @@ -3292,7 +3292,7 @@ Vhelp_char)) return Vprefix_help_command; -#ifdef HAVE_XIM +#ifdef MULE /* If keysym is a non-ASCII char, bind it to self-insert-char by default. */ if (XEVENT_TYPE (builder->most_current_event) == key_press_event && !NILP (Vcomposed_character_default_binding)) @@ -3301,7 +3301,7 @@ if (CHARP (keysym) && !CHAR_ASCII_P (XCHAR (keysym))) return Vcomposed_character_default_binding; } -#endif /* HAVE_XIM */ +#endif /* MULE */ /* If we read extra events attempting to match a function key but end up failing, then we release those events back to the command loop @@ -4822,7 +4822,8 @@ */ ); Vmodifier_keys_sticky_time = make_int (500); -#ifdef HAVE_XIM +#ifdef MULE + DEFVAR_LISP ("composed-character-default-binding", &Vcomposed_character_default_binding /* The default keybinding to use for key events from composed input. @@ -4831,7 +4832,7 @@ XEmacs sees these as single character keypress events. */ ); Vcomposed_character_default_binding = Qself_insert_command; -#endif /* HAVE_XIM */ +#endif /* MULE */ Vcontrolling_terminal = Qnil; staticpro (&Vcontrolling_terminal); diff -Nur xemacs-21.4.13.orig/src/faces.c xemacs-21.4.13/src/faces.c --- xemacs-21.4.13.orig/src/faces.c 2001-04-13 03:23:43.000000000 +0900 +++ xemacs-21.4.13/src/faces.c 2003-06-03 23:36:00.000000000 +0900 @@ -1109,12 +1109,13 @@ ensure_face_cachel_complete (struct face_cachel *cachel, Lisp_Object domain, unsigned char *charsets) { - int i; + Bufbyte i; for (i = 0; i < NUM_LEADING_BYTES; i++) if (charsets[i]) { - Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE); + Bufbyte lb = MIN_LEADING_BYTE + i; + Lisp_Object charset = CHARSET_BY_LEADING_BYTE (lb); assert (CHARSETP (charset)); ensure_face_cachel_contains_charset (cachel, domain, charset); } @@ -1125,7 +1126,7 @@ unsigned char *charsets, struct font_metric_info *fm) { - int i; + Bufbyte i; fm->width = 1; fm->height = fm->ascent = 1; @@ -1136,7 +1137,8 @@ { if (charsets[i]) { - Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE); + Bufbyte lb = MIN_LEADING_BYTE + i; + Lisp_Object charset = CHARSET_BY_LEADING_BYTE (lb); Lisp_Object font_instance = FACE_CACHEL_FONT (cachel, charset); Lisp_Font_Instance *fi = XFONT_INSTANCE (font_instance); @@ -1970,48 +1972,50 @@ Lisp_Object inst_list = Qnil; #if defined(HAVE_X_WINDOWS) || defined(HAVE_GTK) - /* This is kind of ugly because stephen wanted this to be CPP - ** identical to the old version, at least for the initial - ** checkin - ** - ** WMP March 9, 2001 - */ - - /* The same gory list from x-faces.el. - (#### Perhaps we should remove the stuff from x-faces.el - and only depend on this stuff here? That should work.) - */ - const char *fonts[] = { - "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", - "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", - "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*", - "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*", - "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*", - "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*", - "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*", - "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*", - "-*-*-medium-r-*-*-*-120-*-*-m-*-*-*", - "-*-*-medium-r-*-*-*-120-*-*-c-*-*-*", - "-*-*-*-r-*-*-*-120-*-*-m-*-*-*", - "-*-*-*-r-*-*-*-120-*-*-c-*-*-*", - "-*-*-*-r-*-*-*-120-*-*-*-*-*-*", - "-*-*-*-*-*-*-*-120-*-*-*-*-*-*", - "*" - }; - const char **fontptr; + /* This is kind of ugly because stephen wanted this to be CPP + ** identical to the old version, at least for the initial + ** checkin + ** + ** WMP March 9, 2001 + */ + + /* The same gory list from x-faces.el. + (#### Perhaps we should remove the stuff from x-faces.el + and only depend on this stuff here? That should work.) + */ + const char *fonts[] = + { + "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", + "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", + "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*", + "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*", + "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*", + "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*", + "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*", + "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*", + "-*-*-medium-r-*-*-*-120-*-*-m-*-*-*", + "-*-*-medium-r-*-*-*-120-*-*-c-*-*-*", + "-*-*-*-r-*-*-*-120-*-*-m-*-*-*", + "-*-*-*-r-*-*-*-120-*-*-c-*-*-*", + "-*-*-*-r-*-*-*-120-*-*-*-*-*-*", + "-*-*-*-*-*-*-*-120-*-*-*-*-*-*", + "*" + }; + const char **fontptr; #ifdef HAVE_X_WINDOWS - for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--) - inst_list = Fcons (Fcons (list1 (Qx), build_string (*fontptr)), - inst_list); + for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--) + inst_list = Fcons (Fcons (list1 (Qx), build_string (*fontptr)), + inst_list); #endif /* HAVE_X_WINDOWS */ #ifdef HAVE_GTK - for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--) - inst_list = Fcons (Fcons (list1 (Qgtk), build_string (*fontptr)), - inst_list); + for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--) + inst_list = Fcons (Fcons (list1 (Qgtk), build_string (*fontptr)), + inst_list); #endif /* HAVE_GTK */ + } #endif /* HAVE_X_WINDOWS || HAVE_GTK */ @@ -2020,18 +2024,29 @@ inst_list); #endif /* HAVE_TTY */ #ifdef HAVE_MS_WINDOWS - /* Fixedsys does not exist for printers */ - inst_list = Fcons (Fcons (list1 (Qmsprinter), - build_string ("Courier:Regular:10::Western")), inst_list); - inst_list = Fcons (Fcons (list1 (Qmsprinter), - build_string ("Courier New:Regular:10::Western")), inst_list); - - inst_list = Fcons (Fcons (list1 (Qmswindows), - build_string ("Fixedsys:Regular:9::Western")), inst_list); - inst_list = Fcons (Fcons (list1 (Qmswindows), - build_string ("Courier:Regular:10::Western")), inst_list); - inst_list = Fcons (Fcons (list1 (Qmswindows), - build_string ("Courier New:Regular:10::Western")), inst_list); + { + const char *fonts[] = + { + "Courier New:Regular:10::Western", + "Courier:Regular:10::Western", + "Courier New:Regular:10::", + "Courier:Regular:10::", + ":Regular:10::" + }; + const char **fontptr; + + for (fontptr = fonts + countof (fonts) - 1; fontptr >= fonts; fontptr--) + { + /* display device */ + inst_list = Fcons (Fcons (list1 (Qmswindows), + build_string (*fontptr)), + inst_list); + /* printer device */ + inst_list = Fcons (Fcons (list1 (Qmsprinter), + build_string (*fontptr)), + inst_list); + } + } #endif /* HAVE_MS_WINDOWS */ set_specifier_fallback (Fget (Vdefault_face, Qfont, Qnil), inst_list); } diff -Nur xemacs-21.4.13.orig/src/file-coding.c xemacs-21.4.13/src/file-coding.c --- xemacs-21.4.13.orig/src/file-coding.c 2002-11-01 00:07:50.000000000 +0900 +++ xemacs-21.4.13/src/file-coding.c 2003-06-03 23:36:00.000000000 +0900 @@ -300,6 +300,7 @@ { XD_LISP_OBJECT, offsetof (Lisp_Coding_System, eol_lf) }, { XD_LISP_OBJECT, offsetof (Lisp_Coding_System, eol_crlf) }, { XD_LISP_OBJECT, offsetof (Lisp_Coding_System, eol_cr) }, + { XD_LISP_OBJECT, offsetof (Lisp_Coding_System, subsidiary_parent) }, #ifdef MULE { XD_LISP_OBJECT_ARRAY, offsetof (Lisp_Coding_System, iso2022.initial_charset), 4 }, { XD_STRUCT_PTR, offsetof (Lisp_Coding_System, iso2022.input_conv), 1, &ccsd_description }, @@ -327,6 +328,7 @@ mark_object (CODING_SYSTEM_EOL_LF (codesys)); mark_object (CODING_SYSTEM_EOL_CRLF (codesys)); mark_object (CODING_SYSTEM_EOL_CR (codesys)); + mark_object (CODING_SYSTEM_SUBSIDIARY_PARENT (codesys)); switch (CODING_SYSTEM_TYPE (codesys)) { @@ -474,6 +476,7 @@ codesys_name_sym = intern (codesys_name); \ sub_codesys_obj = Fcopy_coding_system (codesys_obj, codesys_name_sym); \ XCODING_SYSTEM_EOL_TYPE (sub_codesys_obj) = Type; \ + XCODING_SYSTEM_SUBSIDIARY_PARENT (sub_codesys_obj) = codesys_obj; \ if (mlen != -1) \ XCODING_SYSTEM_MNEMONIC(sub_codesys_obj) = \ build_string (codesys_mnemonic); \ @@ -612,6 +615,7 @@ CODING_SYSTEM_EOL_CRLF (codesys) = Qnil; CODING_SYSTEM_EOL_CR (codesys) = Qnil; CODING_SYSTEM_EOL_LF (codesys) = Qnil; + CODING_SYSTEM_SUBSIDIARY_PARENT (codesys) = Qnil; CODING_SYSTEM_TYPE (codesys) = type; CODING_SYSTEM_MNEMONIC (codesys) = Qnil; #ifdef MULE @@ -1731,12 +1735,13 @@ static Lisp_Object coding_system_from_mask (int mask) { + Lisp_Object retval = Qnil; + if (mask == ~0) { /* If the file was entirely or basically ASCII, use the default value of `buffer-file-coding-system'. */ - Lisp_Object retval = - XBUFFER (Vbuffer_defaults)->buffer_file_coding_system; + retval = XBUFFER (Vbuffer_defaults)->buffer_file_coding_system; if (!NILP (retval)) { retval = Ffind_coding_system (retval); @@ -1748,9 +1753,6 @@ XBUFFER (Vbuffer_defaults)->buffer_file_coding_system = Qnil; } } - if (NILP (retval)) - retval = Fget_coding_system (Qraw_text); - return retval; } else { @@ -1769,10 +1771,17 @@ break; } if (cat >= 0) - return fcd->coding_category_system[cat]; - else - return Fget_coding_system (Qraw_text); + retval = fcd->coding_category_system[cat]; } + + if (NILP (retval)) + return Fget_coding_system (Qraw_text); + + /* If it is a subsidiary coding system, return its parent. */ + if (NILP (XCODING_SYSTEM_SUBSIDIARY_PARENT (retval))) + return retval; + else + return XCODING_SYSTEM_SUBSIDIARY_PARENT (retval); } /* Given a seekable read stream and potential coding system and EOL type @@ -2446,11 +2455,29 @@ decode_coding_utf8 (decoding, src, dst, n); break; case CODESYS_CCL: - str->ccl.last_block = str->flags & CODING_STATE_END; - /* When applying ccl program to stream, MUST NOT set NULL - pointer to src. */ - ccl_driver (&str->ccl, (src ? (unsigned char *)src : (unsigned char*)""), - dst, n, 0, CCL_MODE_DECODING); + { + unsigned_char_dynarr *ccl_dst = Dynarr_new (unsigned_char); + int i; + + str->ccl.last_block = str->flags & CODING_STATE_END; + /* When applying ccl program to stream, MUST NOT set NULL + pointer to src. */ + ccl_driver (&str->ccl, (src ? (unsigned char *) src : (unsigned char *) ""), + ccl_dst, n, 0, CCL_MODE_DECODING); + + /* CCL decoding doesn't handle EOL type. Do it here. */ + for (i = 0; i < Dynarr_length (ccl_dst); i++) + { + unsigned char c = Dynarr_at (ccl_dst, i); + + DECODE_HANDLE_EOL_TYPE (str->eol_type, c, str->flags, dst); + Dynarr_add (dst, c); + label_continue_loop:; + } + + Dynarr_free (ccl_dst); + DECODE_HANDLE_END_OF_CONVERSION (str->flags, str->ch, dst); + } break; case CODESYS_ISO2022: decode_coding_iso2022 (decoding, src, dst, n); @@ -2732,6 +2759,21 @@ } case CODESYS_CCL: setup_ccl_program (&str->ccl, CODING_SYSTEM_CCL_ENCODE (str->codesys)); + /* Setup EOL type in the CCL structure. */ + switch (CODING_SYSTEM_EOL_TYPE (str->codesys)) + { + case EOL_CRLF: + str->ccl.eol_type = CCL_CODING_EOL_CRLF; + break; + case EOL_CR: + str->ccl.eol_type = CCL_CODING_EOL_CR; + break; + case EOL_LF: + case EOL_AUTODETECT: + str->ccl.eol_type = CCL_CODING_EOL_LF; + break; + default: abort (); + } break; default: break; diff -Nur xemacs-21.4.13.orig/src/file-coding.h xemacs-21.4.13/src/file-coding.h --- xemacs-21.4.13.orig/src/file-coding.h 2001-04-13 03:23:44.000000000 +0900 +++ xemacs-21.4.13/src/file-coding.h 2003-06-03 23:36:00.000000000 +0900 @@ -106,6 +106,7 @@ Lisp_Object eol_lf; Lisp_Object eol_crlf; Lisp_Object eol_cr; + Lisp_Object subsidiary_parent; #ifdef MULE struct { @@ -160,6 +161,8 @@ #define CODING_SYSTEM_EOL_LF(codesys) ((codesys)->eol_lf) #define CODING_SYSTEM_EOL_CRLF(codesys) ((codesys)->eol_crlf) #define CODING_SYSTEM_EOL_CR(codesys) ((codesys)->eol_cr) +#define CODING_SYSTEM_SUBSIDIARY_PARENT(codesys) \ + ((codesys)->subsidiary_parent) #ifdef MULE #define CODING_SYSTEM_ISO2022_INITIAL_CHARSET(codesys, g) \ @@ -202,6 +205,8 @@ CODING_SYSTEM_EOL_CRLF (XCODING_SYSTEM (codesys)) #define XCODING_SYSTEM_EOL_CR(codesys) \ CODING_SYSTEM_EOL_CR (XCODING_SYSTEM (codesys)) +#define XCODING_SYSTEM_SUBSIDIARY_PARENT(codesys) \ + CODING_SYSTEM_SUBSIDIARY_PARENT (XCODING_SYSTEM (codesys)) #ifdef MULE #define XCODING_SYSTEM_ISO2022_INITIAL_CHARSET(codesys, g) \ diff -Nur xemacs-21.4.13.orig/src/fns.c xemacs-21.4.13/src/fns.c --- xemacs-21.4.13.orig/src/fns.c 2002-08-20 20:37:15.000000000 +0900 +++ xemacs-21.4.13/src/fns.c 2003-06-03 23:36:00.000000000 +0900 @@ -707,7 +707,7 @@ realloc()ing in order to make the char fit properly. O(N^2) yuckage. */ val = Qnil; - string_result = (Bufbyte *) alloca (total_length * MAX_EMCHAR_LEN); + string_result = (Bufbyte *) xmalloc (total_length * MAX_EMCHAR_LEN); string_result_ptr = string_result; break; default: @@ -813,6 +813,7 @@ if (target_type == c_string) { val = make_string (string_result, string_result_ptr - string_result); + xfree (string_result); for (argnum = 0; argnum < nargs; argnum++) { if (STRINGP (args_mse[argnum].string)) diff -Nur xemacs-21.4.13.orig/src/frame-msw.c xemacs-21.4.13/src/frame-msw.c --- xemacs-21.4.13.orig/src/frame-msw.c 2003-03-20 12:53:37.000000000 +0900 +++ xemacs-21.4.13/src/frame-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -525,8 +525,11 @@ unsigned int new_checksum = hash_string (title, strlen (title)); if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f)) { + char *title_ext; + FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum; - SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title); + C_STRING_TO_EXTERNAL (title, title_ext, Qnative); + SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title_ext); } } @@ -906,9 +909,17 @@ /* Start print job */ di.cbSize = sizeof (di); - di.lpszDocName = (STRINGP(f->name) - ? (char*) XSTRING_DATA(f->name) - : "XEmacs print document"); + + { + Extbyte *doc_name; + + if (STRINGP(f->name)) + LISP_STRING_TO_EXTERNAL (f->name, doc_name, Qnative); + else + doc_name = "XEmacs print document"; + + di.lpszDocName = (doc_name); + } di.lpszOutput = NULL; di.lpszDatatype = NULL; di.fwType = 0; diff -Nur xemacs-21.4.13.orig/src/glyphs-msw.c xemacs-21.4.13/src/glyphs-msw.c --- xemacs-21.4.13.orig/src/glyphs-msw.c 2002-11-01 00:08:09.000000000 +0900 +++ xemacs-21.4.13/src/glyphs-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -2162,14 +2162,36 @@ /************************************************************************/ static HFONT -mswindows_widget_hfont (Lisp_Image_Instance *p, +mswindows_widget_hfont (Lisp_Object face, Lisp_Object domain) { - Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p); int under = FACE_UNDERLINE_P (face, domain); int strike = FACE_STRIKETHRU_P (face, domain); - Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p), - face, domain); + Lisp_Object font; + struct face_cachel frame_cachel; + struct face_cachel *cachel; + Lisp_Object charset; + + reset_face_cachel (&frame_cachel); + update_face_cachel_data (&frame_cachel, domain, face); + cachel = &frame_cachel; + +#ifdef MULE + charset = mswindows_get_codepage_charset (GetACP ()); +#else + charset = Vcharset_ascii; +#endif + + if (!CHARSETP (charset)) + charset = Vcharset_ascii; + + font = FACE_CACHEL_FONT (cachel, charset); + + if (!FONT_INSTANCEP (font)) + font = ensure_face_cachel_contains_charset (cachel, domain, charset); + + if (EQ (font, Vthe_null_font_instance)) + font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); } @@ -2326,8 +2348,8 @@ /* set the widget font from the widget face */ SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), WM_SETFONT, - (WPARAM) mswindows_widget_hfont - (p, IMAGE_INSTANCE_FRAME (p)), + (WPARAM) mswindows_widget_hfont + (IMAGE_INSTANCE_WIDGET_FACE (p), IMAGE_INSTANCE_FRAME (p)), MAKELPARAM (TRUE, 0)); } /* Possibly update the dimensions. */ @@ -2603,7 +2625,8 @@ /* set the widget font from the widget face */ if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) SendMessage (wnd, WM_SETFONT, - (WPARAM) mswindows_widget_hfont (ii, domain), + (WPARAM) mswindows_widget_hfont + (IMAGE_INSTANCE_WIDGET_FACE (ii), domain), MAKELPARAM (TRUE, 0)); } @@ -3214,6 +3237,27 @@ } } +static void +mswindows_widget_query_string_geometry (Lisp_Object string, Lisp_Object face, + int* width, int* height, + Lisp_Object domain) +{ + HDC hdc = FRAME_MSWINDOWS_DC (DOMAIN_XFRAME (domain)); + Extbyte *str; + SIZE size; + + if (height) + query_string_geometry (string, face, 0, height, 0, domain); + + if (width) + { + SelectObject (hdc, mswindows_widget_hfont (face, domain)); + LISP_STRING_TO_EXTERNAL (string, str, Qnative); + GetTextExtentPoint32 (hdc, str, strlen (str), &size); + *width = size.cx; + } +} + #endif /* HAVE_WIDGETS */ @@ -3244,6 +3288,7 @@ CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); CONSOLE_HAS_METHOD (mswindows, widget_border_width); + CONSOLE_HAS_METHOD (mswindows, widget_query_string_geometry); /* image methods - printer */ CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); diff -Nur xemacs-21.4.13.orig/src/glyphs-widget.c xemacs-21.4.13/src/glyphs-widget.c --- xemacs-21.4.13.orig/src/glyphs-widget.c 2002-11-07 15:04:44.000000000 +0900 +++ xemacs-21.4.13/src/glyphs-widget.c 2003-06-03 23:36:00.000000000 +0900 @@ -252,6 +252,21 @@ } } +static void +widget_query_string_geometry (Lisp_Object string, Lisp_Object face, + int *width, int *height, int *descent, + Lisp_Object domain) +{ + struct device *d = DOMAIN_XDEVICE (domain); + + if (HAS_DEVMETH_P (d, widget_query_string_geometry)) + DEVMETH (d, widget_query_string_geometry, + (string, face, width, height, domain)); + else + query_string_geometry (string, face, width, height, 0, domain); + +} + /* Determine the border with of the widget. */ static int widget_border_width (Lisp_Object domain) @@ -281,8 +296,8 @@ logical_unit_height (Lisp_Object text, Lisp_Object face, Lisp_Object domain) { int charheight = 0; - query_string_geometry (text, face, - 0, &charheight, 0, domain); + widget_query_string_geometry (text, face, + 0, &charheight, 0, domain); /* For the returned value to be useful it needs to be big enough to accomodate the largest single-height widget. This is currently the edit-field. */ @@ -554,9 +569,9 @@ /* Then if we are allowed to resize the widget, make the size the same as the text dimensions. */ - query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - &w, &h, 0, domain); + widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + &w, &h, 0, domain); /* Adjust the size for borders. */ if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii)) *width = w + 2 * widget_instance_border_width (ii); @@ -807,9 +822,9 @@ int charheight; if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) { - query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - 0, &charheight, 0, domain); + widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + 0, &charheight, 0, domain); } else { @@ -870,9 +885,9 @@ { Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); int w, h; - query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - &w, &h, 0, domain); + widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + &w, &h, 0, domain); /* Adjust the size for borders. */ if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii)) { @@ -896,9 +911,9 @@ { Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); int w, h; - query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - &w, &h, 0, domain); + widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + &w, &h, 0, domain); /* Adjust the size for borders. */ if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii)) *width = w + 4 * widget_instance_border_width (ii); @@ -919,9 +934,9 @@ if (*width) { /* #### what should this be. reconsider when X has tree views. */ - query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), - IMAGE_INSTANCE_WIDGET_FACE (ii), - width, 0, 0, domain); + widget_query_string_geometry (IMAGE_INSTANCE_WIDGET_TEXT (ii), + IMAGE_INSTANCE_WIDGET_FACE (ii), + width, 0, 0, domain); } if (*height) { @@ -949,9 +964,9 @@ { int h, w; - query_string_geometry (XGUI_ITEM (XCAR (rest))->name, - IMAGE_INSTANCE_WIDGET_FACE (ii), - &w, &h, 0, domain); + widget_query_string_geometry (XGUI_ITEM (XCAR (rest))->name, + IMAGE_INSTANCE_WIDGET_FACE (ii), + &w, &h, 0, domain); tw += 5 * widget_instance_border_width (ii); /* some bias */ tw += w; th = max (th, h + 2 * widget_instance_border_width (ii)); diff -Nur xemacs-21.4.13.orig/src/input-method-msw.c xemacs-21.4.13/src/input-method-msw.c --- xemacs-21.4.13.orig/src/input-method-msw.c 1970-01-01 09:00:00.000000000 +0900 +++ xemacs-21.4.13/src/input-method-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -0,0 +1,88 @@ +/* MS Windows IME (Input Method Editor) support. + Copyright (C) 2000 IKEYAMA Tomonori + +This file is part of XEmacs. + +XEmacs 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 2, or (at your option) any +later version. + +XEmacs 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 XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#include +#include "lisp.h" + +#include "console-msw.h" +#include "objects-msw.h" + +#include "faces.h" +#include "frame.h" +#include "window.h" + +/* Set a composition window palace and font */ +void +mswindows_start_ime_compositon (struct frame *f) +{ + COMPOSITIONFORM form; + HWND hwnd = FRAME_MSWINDOWS_HANDLE(f); + HIMC himc = ImmGetContext (hwnd); + + /* Set a position of composition window. */ + xzero (form); + form.dwStyle = CFS_POINT; + form.ptCurrentPos.x = FRAME_MSWINDOWS_CURSOR_X (f); + form.ptCurrentPos.y = FRAME_MSWINDOWS_CURSOR_Y (f); + ImmSetCompositionWindow (himc, &form); + + /* Set composition window font same as current face one. */ + { + LOGFONT old_logfont; + CHARSETINFO info; + Lisp_Object charset; + + /* Get Mule charset from current ime font charset. */ + ImmGetCompositionFont (himc, &old_logfont); + TranslateCharsetInfo ((DWORD *)old_logfont.lfCharSet, &info, + TCI_SRCCHARSET); + charset = mswindows_get_codepage_charset (info.ciACP); + + if (CHARSETP (charset)) + { + Lisp_Object window = FRAME_SELECTED_WINDOW (f); + struct window *w = XWINDOW (window); + face_index findex = FRAME_MSWINDOWS_CURSOR_FINDEX (f); + struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex); + Lisp_Object face_font = FACE_CACHEL_FONT (cachel, charset); + + if (!FONT_INSTANCEP (face_font)) + face_font = + ensure_face_cachel_contains_charset (cachel, window, charset); + + if (!EQ (face_font, Vthe_null_font_instance)) + { + LOGFONT new_logfont; + + /* Get LOGFONT from the face font */ + if (GetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT + (XFONT_INSTANCE (face_font), + cachel->underline, cachel->strikethru), + sizeof (LOGFONT), (void*)&new_logfont)) + ImmSetCompositionFont (himc, &new_logfont); + } + } + } + ImmReleaseContext (hwnd, himc); + return; +} + diff -Nur xemacs-21.4.13.orig/src/menubar-msw.c xemacs-21.4.13/src/menubar-msw.c --- xemacs-21.4.13.orig/src/menubar-msw.c 2002-11-01 00:08:25.000000000 +0900 +++ xemacs-21.4.13/src/menubar-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -224,15 +224,16 @@ /* We construct the name in a static buffer. That's fine, because menu items longer than 128 chars are probably programming errors, and better be caught than displayed! */ - - static char buf[MAX_MENUITEM_LENGTH+2]; + + Bufbyte buf[MAX_MENUITEM_LENGTH+2]; + Extbyte *ext; + static char retval[MAX_MENUITEM_LENGTH+2]; /* Left flush part of the string */ ll = gui_item_display_flush_left (gui_item, buf, MAX_MENUITEM_LENGTH); - ll = mswindows_translate_menu_or_dialog_item ((Bufbyte *) buf, ll, - MAX_MENUITEM_LENGTH, accel, - XGUI_ITEM (gui_item)->name); + ll = mswindows_translate_menu_or_dialog_item + (buf, ll, MAX_MENUITEM_LENGTH, accel, XGUI_ITEM (gui_item)->name); /* Right flush part, unless we're at the top-level where it's not allowed */ if (!bar_p) @@ -246,7 +247,10 @@ buf [ll] = '\t'; } - return buf; + C_STRING_TO_EXTERNAL (buf, ext, Qnative); + strcpy (retval, ext); + + return retval; } /* diff -Nur xemacs-21.4.13.orig/src/mule-charset.h xemacs-21.4.13/src/mule-charset.h --- xemacs-21.4.13.orig/src/mule-charset.h 2001-04-13 03:24:03.000000000 +0900 +++ xemacs-21.4.13/src/mule-charset.h 2003-06-03 23:36:00.000000000 +0900 @@ -780,6 +780,7 @@ EXFUN (Ffind_charset, 1); EXFUN (Fget_charset, 1); +EXFUN (Fcharset_list, 0); extern Lisp_Object Vcharset_chinese_big5_1; extern Lisp_Object Vcharset_chinese_big5_2; diff -Nur xemacs-21.4.13.orig/src/objects-msw.c xemacs-21.4.13/src/objects-msw.c --- xemacs-21.4.13.orig/src/objects-msw.c 2001-04-13 03:24:09.000000000 +0900 +++ xemacs-21.4.13/src/objects-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -756,25 +756,24 @@ * matched against the names reported by win32 by match_font() */ static const fontmap_t charset_map[] = { - {"Western" , ANSI_CHARSET}, - {"Symbol" , SYMBOL_CHARSET}, - {"Shift JIS" , SHIFTJIS_CHARSET}, /* #### Name to be verified */ - {"GB2312" , GB2312_CHARSET}, /* #### Name to be verified */ - {"Hanguel" , HANGEUL_CHARSET}, - {"Chinese Big 5" , CHINESEBIG5_CHARSET}, /* #### Name to be verified */ -#if (WINVER >= 0x0400) - {"Johab" , JOHAB_CHARSET}, /* #### Name to be verified */ - {"Hebrew" , HEBREW_CHARSET}, /* #### Name to be verified */ - {"Arabic" , ARABIC_CHARSET}, /* #### Name to be verified */ - {"Greek" , GREEK_CHARSET}, - {"Turkish" , TURKISH_CHARSET}, - {"Vietnamese" , VIETNAMESE_CHARSET}, /* #### Name to be verified */ - {"Thai" , THAI_CHARSET}, /* #### Name to be verified */ + {"Western" , ANSI_CHARSET}, /* Latin 1 */ {"Central European" , EASTEUROPE_CHARSET}, {"Cyrillic" , RUSSIAN_CHARSET}, - {"Mac" , MAC_CHARSET}, + {"Greek" , GREEK_CHARSET}, + {"Turkish" , TURKISH_CHARSET}, + {"Hebrew" , HEBREW_CHARSET}, + {"Arabic" , ARABIC_CHARSET}, {"Baltic" , BALTIC_CHARSET}, -#endif + {"Viet Nam" , VIETNAMESE_CHARSET}, + {"Thai" , THAI_CHARSET}, + {"Japanese" , SHIFTJIS_CHARSET}, + {"Korean" , HANGEUL_CHARSET}, + {"Simplified Chinese" , GB2312_CHARSET}, + {"Traditional Chinese", CHINESEBIG5_CHARSET}, + + {"Symbol" , SYMBOL_CHARSET}, + {"Mac" , MAC_CHARSET}, + {"Korean Johab" , JOHAB_CHARSET}, {"OEM/DOS" , OEM_CHARSET} }; @@ -979,7 +978,11 @@ * weights unspecified. This means that we have to weed out duplicates of * those fonts that do get enumerated with different weights. */ - if (FontType == 0 /*vector*/ || FontType == TRUETYPE_FONTTYPE) + if (*lpelfe->elfLogFont.lfFaceName == '@') + /* This is a font for writting vertically. We ignore it. */ + return 1; + + if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) /* Scalable, so leave pointsize blank */ sprintf (fontname, "%s::::", lpelfe->elfLogFont.lfFaceName); else @@ -1002,11 +1005,11 @@ break; } if (i==countof (charset_map)) - strcpy (fontname, charset_map[0].name); + return 1; /* Add the font name to the list if not already there */ - fontname_lispstr = build_string (fontname); - if (NILP (memq_no_quit (fontname_lispstr, font_enum->list))) + fontname_lispstr = build_ext_string (fontname, Qbinary); + if (NILP (Fmember (fontname_lispstr, font_enum->list))) font_enum->list = Fcons (fontname_lispstr, font_enum->list); return 1; @@ -1042,7 +1045,11 @@ * weights unspecified. This means that we have to weed out duplicates of * those fonts that do get enumerated with different weights. */ - if (FontType == 0 /*vector*/ || FontType == TRUETYPE_FONTTYPE) + if (*lpelfe->elfLogFont.lfFaceName == '@') + /* This is a font for writting vertically. We ignore it. */ + return 1; + + if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) /* Scalable, so leave pointsize blank */ sprintf (fontname, "%s::::", lpelfe->elfLogFont.lfFaceName); else @@ -1065,11 +1072,11 @@ break; } if (i==countof (charset_map)) - strcpy (fontname, charset_map[0].name); + return 1; /* Add the font name to the list if not already there */ - fontname_lispstr = build_string (fontname); - if (NILP (memq_no_quit (fontname_lispstr, font_enum->list))) + fontname_lispstr = build_ext_string (fontname, Qbinary); + if (NILP (Fmember (fontname_lispstr, font_enum->list))) font_enum->list = Fcons (fontname_lispstr, font_enum->list); return 1; @@ -1174,9 +1181,7 @@ const char *extname; COLORREF color; - TO_EXTERNAL_FORMAT (LISP_STRING, name, - C_STRING_ALLOCA, extname, - Qctext); + LISP_STRING_TO_EXTERNAL (name, extname, Qnative); color = mswindows_string_to_color(extname); if (color != -1) { @@ -1245,9 +1250,7 @@ { const char *extname; - TO_EXTERNAL_FORMAT (LISP_STRING, color, - C_STRING_ALLOCA, extname, - Qctext); + LISP_STRING_TO_EXTERNAL (color, extname, Qnative); return (mswindows_string_to_color(extname)!=-1); } @@ -1275,8 +1278,7 @@ HFONT hfont, hfont2; TEXTMETRIC metrics; - extname = XSTRING_DATA (name); - + LISP_STRING_TO_EXTERNAL (name, extname, Qnative); /* * mswindows fonts look like: * fontname[:[weight ][style][:pointsize[:effects]]][:charset] @@ -1488,7 +1490,9 @@ sprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects, charset); LIST_LOOP (fonttail, device_font_list) { - if (match_font (XSTRING_DATA (XCAR (fonttail)), truename, NULL)) + Extbyte *extfonttail; + LISP_STRING_TO_EXTERNAL (XCAR (fonttail), extfonttail, Qbinary); + if (match_font (extfonttail, truename, NULL)) break; } if (NILP (fonttail)) @@ -1594,17 +1598,27 @@ static Lisp_Object mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device) { - Lisp_Object fonttail, result = Qnil; - char *extpattern; - - TO_EXTERNAL_FORMAT (LISP_STRING, pattern, - C_STRING_ALLOCA, extpattern, - Qctext); + struct device *d = XDEVICE (device); + Lisp_Object font_list, fonttail, result = Qnil; + Extbyte *extpattern; + + if (DEVICE_MSWINDOWS_P (d)) + font_list = DEVICE_MSWINDOWS_FONTLIST (d); + else if (DEVICE_MSPRINTER_P (d)) + font_list = DEVICE_MSPRINTER_FONTLIST (d); + else + abort (); - LIST_LOOP (fonttail, DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device))) + LISP_STRING_TO_EXTERNAL (pattern, extpattern, Qnative); + LIST_LOOP (fonttail, font_list) { - if (match_font (XSTRING_DATA (XCAR (fonttail)), extpattern, NULL)) - result = Fcons (XCAR (fonttail), result); + Extbyte *extfonttail; + Extbyte fontname[MSW_FONTSIZE]; + + LISP_STRING_TO_EXTERNAL (XCAR (fonttail), extfonttail, Qbinary); + if (match_font (extfonttail, extpattern, fontname)) + result = Fcons (build_ext_string (fontname, Qnative), + result); } return Fnreverse (result); @@ -1625,9 +1639,12 @@ { int nsep=0; char *name = (char *) XSTRING_DATA (f->name); - char* ptr = name; - char* extname = (char*) alloca (strlen (name) + 19); - strcpy (extname, name); + char *ptr = name; + char *extname = (char *) alloca (strlen (name) + 19); + Extbyte *convertion_name; + + LISP_STRING_TO_EXTERNAL (f->name, convertion_name, Qnative); + strcpy (extname, convertion_name); while ((ptr = strchr (ptr, ':')) != 0) { @@ -1662,11 +1679,54 @@ const Bufbyte *nonreloc, Lisp_Object reloc, Bytecount offset, Bytecount length) { - /* #### Implement me */ + Lisp_Object charset_codepage; + int font_codepage; + if (UNBOUNDP (charset)) return 1; - return 1; + /* Get codepage from the font spec */ + { + const Bufbyte *the_nonreloc = nonreloc; + int i, ms_charset; + char *c, *ms_charset_name; + CHARSETINFO info; + + if (!the_nonreloc) + LISP_STRING_TO_EXTERNAL (reloc, the_nonreloc, Qnative); + if ((c = strchr (the_nonreloc, ':')) && + (c = strchr (c + 1, ':')) && + (c = strchr (c + 1, ':')) && + (c = strchr (c + 1, ':'))) + ms_charset_name = c + 1; + else + return 0; + + for (i = 0; i < countof (charset_map); i++) + if (stricmp (ms_charset_name, charset_map[i].name) == 0) + { + ms_charset = charset_map[i].value; + break; + } + if (i == countof (charset_map)) + return 0; + + /* For border-glyph use */ + if (ms_charset == SYMBOL_CHARSET) + ms_charset = ANSI_CHARSET; + + if (!TranslateCharsetInfo ((DWORD *)ms_charset, &info, TCI_SRCCHARSET)) + return 0; + + font_codepage = info.ciACP; + } + + /* Get codepage for the charset */ + charset_codepage = Fmswindows_charset_codepage (charset); + if (!INTP (charset_codepage)) + return 0; + + return font_codepage == XINT (charset_codepage); } /* find a font spec that matches font spec FONT and also matches @@ -1675,8 +1735,16 @@ mswindows_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset) { - /* #### Implement me */ - return build_string ("Courier New:Regular:10"); + Lisp_Object fontlist, fonttail; + + fontlist = mswindows_list_fonts (font, device); + LIST_LOOP (fonttail, fontlist) + { + if (mswindows_font_spec_matches_charset + (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) + return XCAR (fonttail); + } + return Qnil; } #endif /* MULE */ diff -Nur xemacs-21.4.13.orig/src/process-nt.c xemacs-21.4.13/src/process-nt.c --- xemacs-21.4.13.orig/src/process-nt.c 2002-08-20 20:37:45.000000000 +0900 +++ xemacs-21.4.13/src/process-nt.c 2003-06-03 23:36:00.000000000 +0900 @@ -728,20 +728,24 @@ /* SHGetFileInfo tends to return ERROR_FILE_NOT_FOUND on most errors. This leads to bogus error message. */ DWORD image_type; - char *p = strrchr ((char *)XSTRING_DATA (program), '.'); + Extbyte *program_name, *p; + + LISP_STRING_TO_EXTERNAL (program, program_name, Qnative); + p = strrchr (program_name, '.'); + if (p != NULL && (stricmp (p, ".exe") == 0 || stricmp (p, ".com") == 0 || stricmp (p, ".bat") == 0 || stricmp (p, ".cmd") == 0)) { - image_type = xSHGetFileInfoA ((char *)XSTRING_DATA (program), 0,NULL, + image_type = xSHGetFileInfoA (program_name, 0, NULL, 0, SHGFI_EXETYPE); } else { char progname[MAX_PATH]; - sprintf (progname, "%s.exe", (char *)XSTRING_DATA (program)); + sprintf (progname, "%s.exe", program_name); image_type = xSHGetFileInfoA (progname, 0, NULL, 0, SHGFI_EXETYPE); } if (image_type == 0) @@ -925,6 +929,7 @@ PROCESS_INFORMATION pi; DWORD err; DWORD flags; + Extbyte *ext_cur_dir; xzero (si); si.dwFlags = STARTF_USESHOWWINDOW; @@ -949,8 +954,10 @@ ensure_console_window_exists (); + LISP_STRING_TO_EXTERNAL (cur_dir, ext_cur_dir, Qnative); + err = (CreateProcess (NULL, command_line, NULL, NULL, TRUE, flags, - proc_env, (char *) XSTRING_DATA (cur_dir), &si, &pi) + proc_env, ext_cur_dir, &si, &pi) ? 0 : GetLastError ()); if (do_io) diff -Nur xemacs-21.4.13.orig/src/realpath.c xemacs-21.4.13/src/realpath.c --- xemacs-21.4.13.orig/src/realpath.c 2002-11-01 00:08:31.000000000 +0900 +++ xemacs-21.4.13/src/realpath.c 2003-06-03 23:36:00.000000000 +0900 @@ -70,7 +70,12 @@ #endif /* WIN32_NATIVE */ #if defined (WIN32_NATIVE) || defined (CYGWIN) +#define DONT_ENCAPSULATE #include "syswindows.h" +#ifdef MULE +#include +#define strpbrk(S1, S2) _mbspbrk(S1, S2) +#endif /* Emulate readlink on win32 - finds real name (i.e. correct case) of a file. UNC servers and shares are lower-cased. Directories must be given without trailing '/'. One day, this could read Win2K's diff -Nur xemacs-21.4.13.orig/src/redisplay-msw.c xemacs-21.4.13/src/redisplay-msw.c --- xemacs-21.4.13.orig/src/redisplay-msw.c 2002-08-20 20:37:55.000000000 +0900 +++ xemacs-21.4.13/src/redisplay-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -74,6 +74,7 @@ Lisp_Object charset; unsigned char *ptr; int len; + int byte_len; int dimension; } textual_run; @@ -125,6 +126,7 @@ if (runs_so_far) { run_storage[runs_so_far - 1].len = + run_storage[runs_so_far - 1].byte_len = text_storage - run_storage[runs_so_far - 1].ptr; if (run_storage[runs_so_far - 1].dimension == 2) run_storage[runs_so_far - 1].len >>= 1; @@ -133,7 +135,7 @@ prev_charset = charset; #ifdef MULE { - Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset); + Lisp_Object ccl_prog = Fmswindows_charset_ccl_program (charset); if ((!NILP (ccl_prog)) && (setup_ccl_program (&char_converter, ccl_prog) >= 0)) need_ccl_conversion = 1; @@ -157,7 +159,6 @@ char_converter.reg[0] = XCHARSET_ID (charset); char_converter.reg[1] = byte1; char_converter.reg[2] = byte2; - char_converter.ic = 0; /* start at beginning each time */ ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING); byte1 = char_converter.reg[1]; byte2 = char_converter.reg[2]; @@ -171,6 +172,7 @@ if (runs_so_far) { run_storage[runs_so_far - 1].len = + run_storage[runs_so_far - 1].byte_len = text_storage - run_storage[runs_so_far - 1].ptr; if (run_storage[runs_so_far - 1].dimension == 2) run_storage[runs_so_far - 1].len >>= 1; @@ -185,19 +187,14 @@ textual_run *run) { Lisp_Object font_inst = FACE_CACHEL_FONT (cachel, run->charset); - Lisp_Font_Instance *fi = XFONT_INSTANCE (font_inst); SIZE size; - if (!fi->proportional_p || !hdc) - return (fi->width * run->len); - else - { - assert(run->dimension == 1); /* #### FIXME! */ - mswindows_set_dc_font (hdc, font_inst, - cachel->underline, cachel->strikethru); - GetTextExtentPoint32 (hdc, run->ptr, run->len, &size); - return(size.cx); - } + /* Don't trust FONT_INSTANCE_WIDTH. Asian fonts have both of one and + two column characters. */ + mswindows_set_dc_font (hdc, font_inst, + cachel->underline, cachel->strikethru); + GetTextExtentPoint32 (hdc, run->ptr, run->byte_len, &size); + return size.cx; } /* @@ -338,13 +335,13 @@ { struct frame *f = XFRAME (w->frame); struct device *d = XDEVICE (f->device); - struct face_cachel *cachel=0; Lisp_Object font = Qnil; int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); HDC hdc = get_frame_dc (f, 1); unsigned int local_face_index=0; - char *p_char = NULL; - int n_char = 0; + unsigned char text_storage[2]; + textual_run run; + int nruns = 0; RECT rect = { xpos, DISPLAY_LINE_YPOS (dl), xpos + width, @@ -359,19 +356,16 @@ redisplay_unmap_subwindows_maybe (f, xpos, DISPLAY_LINE_YPOS (dl), width, DISPLAY_LINE_HEIGHT (dl)); + xzero (run); + if (real_char_p) { /* Use the font from the underlying character */ - cachel = WINDOW_FACE_CACHEL (w, findex); - - /* #### MULE: Need to know the charset! */ - font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); - } - - if ((focus || bar_p) && real_char_p) - { - p_char = (char*) &ch; - n_char = 1; + struct face_cachel *font_cachel = WINDOW_FACE_CACHEL (w, findex); + nruns = separate_textual_runs (text_storage, &run, &ch, 1); + font = FACE_CACHEL_FONT (font_cachel, run.charset); + mswindows_set_dc_font (hdc, font, + font_cachel->underline, font_cachel->strikethru); } if (!image_p) @@ -386,11 +380,8 @@ findex : local_face_index)); mswindows_update_dc (hdc, color_cachel->foreground, color_cachel->background, Qnil); - if (real_char_p) - mswindows_set_dc_font (hdc, font, - cachel->underline, cachel->strikethru); - - ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL); + ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, + run.ptr, run.byte_len, NULL); } if (!cursor_p) @@ -398,32 +389,51 @@ if (focus && bar_p) { + struct face_cachel *cursor_cachel; rect.right = rect.left + (EQ (bar, Qt) ? 1 : min (2, width)); local_face_index = get_builtin_face_cache_index (w, Vtext_cursor_face); - cachel = WINDOW_FACE_CACHEL (w, local_face_index); - mswindows_update_dc (hdc, Qnil, cachel->background, Qnil); + cursor_cachel = WINDOW_FACE_CACHEL (w, local_face_index); + mswindows_update_dc (hdc, Qnil, cursor_cachel->background, Qnil); ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL); } else if (!focus) { + struct face_cachel *cursor_cachel; + /* Now have real character drawn in its own color. We deflate the rectangle so character cell will be bounded by the previously drawn cursor shape */ InflateRect (&rect, -1, -1); - - if (real_char_p) - { - p_char = (char*) &ch; - n_char = 1; - } - local_face_index = get_builtin_face_cache_index (w, Vdefault_face); - cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : local_face_index)); + cursor_cachel = + WINDOW_FACE_CACHEL (w, (real_char_p ? findex : local_face_index)); mswindows_update_dc (hdc, - cachel->foreground, cachel->background, Qnil); + cursor_cachel->foreground, + cursor_cachel->background, Qnil); ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED, - &rect, p_char, n_char, NULL); + &rect, run.ptr, run.byte_len, NULL); + } +#ifdef HAVE_IME + if (DEVICE_MSWINDOWS_P (d) && + (FRAME_MSWINDOWS_CURSOR_X (f) != xpos + || FRAME_MSWINDOWS_CURSOR_Y (f) != DISPLAY_LINE_YPOS (dl) + || FRAME_MSWINDOWS_CURSOR_FINDEX (f) != findex)) + { + HWND hwnd = FRAME_MSWINDOWS_HANDLE(f); + HIMC himc = ImmGetContext (hwnd); + + FRAME_MSWINDOWS_CURSOR_X (f) = xpos; + FRAME_MSWINDOWS_CURSOR_Y (f) = DISPLAY_LINE_YPOS (dl); + FRAME_MSWINDOWS_CURSOR_FINDEX (f) = findex; + + /* If the composition windows is active, reset position of the + compositon window. */ + if (ImmGetCompositionString (himc, GCS_COMPSTR, NULL, 0)) + mswindows_start_ime_compositon (f); + + ImmReleaseContext (hwnd, himc); } +#endif /* HAVE_IME */ } @@ -560,10 +570,9 @@ } } - assert (runs[i].dimension == 1); /* #### FIXME: Broken when Mule? */ ExtTextOut (hdc, xpos, dl->ypos, NILP(bg_pmap) ? ETO_CLIPPED | ETO_OPAQUE : ETO_CLIPPED, - &rect, (char *) runs[i].ptr, runs[i].len, NULL); + &rect, (char *) runs[i].ptr, runs[i].byte_len, NULL); xpos += this_width; } @@ -1089,8 +1098,8 @@ { if (Dynarr_length (buf)) { - mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, width, - findex, 0, 0, 0, 0); + mswindows_output_string (w, dl, buf, xpos, 0, start_pixpos, + width, findex, 0, 0, 0, 0); xpos = rb->xpos; width = 0; } diff -Nur xemacs-21.4.13.orig/src/redisplay.c xemacs-21.4.13/src/redisplay.c --- xemacs-21.4.13.orig/src/redisplay.c 2002-11-01 00:08:34.000000000 +0900 +++ xemacs-21.4.13/src/redisplay.c 2003-06-03 23:36:00.000000000 +0900 @@ -993,9 +993,14 @@ data->font_is_bogus = 0; fi = XFONT_INSTANCE (font_instance); - if (!fi->proportional_p) - /* sweetness and light. */ - data->last_char_width = fi->width; + if (!fi->proportional_p || data->font_is_bogus) + { + Emchar ch = data->font_is_bogus ? '~' : data->ch; + + data->last_char_width = + redisplay_text_width_emchar_string (XWINDOW (data->window), + data->findex, &ch, 1); + } else data->last_char_width = -1; @@ -1011,12 +1016,10 @@ width = data->last_char_width; if (width < 0) - { - /* bummer. Proportional fonts. */ - width = redisplay_text_width_emchar_string (XWINDOW (data->window), - data->findex, - &data->ch, 1); - } + /* Proportional fonts. */ + width = redisplay_text_width_emchar_string (XWINDOW (data->window), + data->findex, + &data->ch, 1); } if (data->max_pixpos != -1 && (data->pixpos + width > data->max_pixpos)) diff -Nur xemacs-21.4.13.orig/src/s/mingw32.h xemacs-21.4.13/src/s/mingw32.h --- xemacs-21.4.13.orig/src/s/mingw32.h 2001-07-25 16:45:43.000000000 +0900 +++ xemacs-21.4.13/src/s/mingw32.h 2003-06-03 23:36:00.000000000 +0900 @@ -106,6 +106,8 @@ is not ':', #define this to be the appropriate character constant. */ #define SEPCHAR ';' +#define HAVE_SETITIMER + /* ============================================================ */ /* Here, add any special hacks needed @@ -190,7 +192,6 @@ gid_t getegid (void); /* Stuff that gets set wrongly or otherwise */ -#define HAVE_SETITIMER #define HAVE_GETTIMEOFDAY #define HAVE_SELECT /* systime.h includes winsock.h which defines timeval */ diff -Nur xemacs-21.4.13.orig/src/select-msw.c xemacs-21.4.13/src/select-msw.c --- xemacs-21.4.13.orig/src/select-msw.c 2001-04-13 03:24:18.000000000 +0900 +++ xemacs-21.4.13/src/select-msw.c 2003-06-03 23:36:00.000000000 +0900 @@ -275,7 +275,8 @@ if (OPAQUEP (data)) src = XOPAQUE_DATA (data); else - src = XSTRING_DATA (data); + TO_EXTERNAL_FORMAT (LISP_STRING, data, MALLOC, (src, size), + Qbinary); dst = GlobalLock (hValue); @@ -289,6 +290,9 @@ memcpy (dst, src, size); + if (!OPAQUEP (data)) + xfree (src); + GlobalUnlock (hValue); /* Empty the clipboard if we're replacing everything */ diff -Nur xemacs-21.4.13.orig/src/syntax.c xemacs-21.4.13/src/syntax.c --- xemacs-21.4.13.orig/src/syntax.c 2003-01-15 21:18:02.000000000 +0900 +++ xemacs-21.4.13/src/syntax.c 2003-06-03 23:36:00.000000000 +0900 @@ -233,8 +233,6 @@ syntax_table = check_syntax_table (syntax_table, Qnil); buf->syntax_table = syntax_table; buf->mirror_syntax_table = XCHAR_TABLE (syntax_table)->mirror_table; - /* Indicate that this buffer now has a specified syntax table. */ - buf->local_var_flags |= XINT (buffer_local_flags.syntax_table); return syntax_table; } diff -Nur xemacs-21.4.13.orig/src/sysdep.c xemacs-21.4.13/src/sysdep.c --- xemacs-21.4.13.orig/src/sysdep.c 2002-08-20 20:38:14.000000000 +0900 +++ xemacs-21.4.13/src/sysdep.c 2003-06-03 23:36:00.000000000 +0900 @@ -3107,10 +3107,10 @@ int xemacs_stat (const char *path, struct stat *buf) { - PATHNAME_CONVERT_OUT (path); #ifdef WIN32_NATIVE return mswindows_stat (path, buf); #else + PATHNAME_CONVERT_OUT (path); return stat (path, buf); #endif } diff -Nur xemacs-21.4.13.orig/src/syswindows.h xemacs-21.4.13/src/syswindows.h --- xemacs-21.4.13.orig/src/syswindows.h 2002-08-20 20:38:17.000000000 +0900 +++ xemacs-21.4.13/src/syswindows.h 2003-06-03 23:36:00.000000000 +0900 @@ -184,6 +184,49 @@ #define LOCALE_RETURN_NUMBER 0x20000000 #endif +/* imm.h defines. */ +#if defined (HAVE_IME) && (defined (CYGWIN) || defined (MINGW)) +/* Current w32api's winuser.h has IME message constants and they + conflict with imm.h. So #undef them before include imm.h. */ +#ifdef WM_IME_STARTCOMPOSITION +#undef WM_IME_STARTCOMPOSITION +#endif +#ifdef WM_IME_ENDCOMPOSITION +#undef WM_IME_ENDCOMPOSITION +#endif +#ifdef WM_IME_COMPOSITION +#undef WM_IME_COMPOSITION +#endif +#ifdef WM_IME_KEYLAST +#undef WM_IME_KEYLAST +#endif +#ifdef WM_IME_SETCONTEXT +#undef WM_IME_SETCONTEXT +#endif +#ifdef WM_IME_NOTIFY +#undef WM_IME_NOTIFY +#endif +#ifdef WM_IME_CONTROL +#undef WM_IME_CONTROL +#endif +#ifdef WM_IME_COMPOSITIONFULL +#undef WM_IME_COMPOSITIONFULL +#endif +#ifdef WM_IME_SELECT +#undef WM_IME_SELECT +#endif +#ifdef WM_IME_CHAR +#undef WM_IME_CHAR +#endif +#ifdef WM_IME_KEYDOWN +#undef WM_IME_KEYDOWN +#endif +#ifdef WM_IME_KEYUP +#undef WM_IME_KEYUP +#endif +#include +#endif + /***************************************************************/ /* Definitions for Mule under MS Windows */ @@ -308,4 +351,28 @@ extern DWORD (WINAPI *xSHGetFileInfoW) (LPCWSTR, DWORD, SHFILEINFOW FAR *, UINT, UINT); +/* Encapsulated system calls for file name code conversion. */ +#ifdef MULE +HANDLE sys_FindFirstFile (LPCSTR lpFileName, + LPWIN32_FIND_DATA lpFindFileData); +BOOL sys_FindNextFile (HANDLE hFindFile, + LPWIN32_FIND_DATA lpFindFileData); +HANDLE sys_CreateFile (LPCTSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDistribution, + DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + +#ifndef DONT_ENCAPSULATE +# undef FindFirstFile +# define FindFirstFile sys_FindFirstFile +# undef FindNextFile +# define FindNextFile sys_FindNextFile +# undef CreateFile +# define CreateFile sys_CreateFile +#endif /* !DONT_ENCAPSULATENT */ +#endif /* MULE */ + #endif /* INCLUDED_syswindows_h_ */ diff -Nur xemacs-21.4.13.orig/src/unexnt.c xemacs-21.4.13/src/unexnt.c --- xemacs-21.4.13.orig/src/unexnt.c 2001-04-13 03:24:28.000000000 +0900 +++ xemacs-21.4.13/src/unexnt.c 2003-06-03 23:36:00.000000000 +0900 @@ -58,6 +58,7 @@ #include #include "lisp.h" +#define DONT_ENCAPSULATE #include "syswindows.h" #include "nt.h" diff -Nur xemacs-21.4.13.orig/src/win32.c xemacs-21.4.13/src/win32.c --- xemacs-21.4.13.orig/src/win32.c 2002-08-20 20:38:24.000000000 +0900 +++ xemacs-21.4.13/src/win32.c 2003-06-03 23:36:00.000000000 +0900 @@ -25,6 +25,7 @@ #include "syssignal.h" #include "systime.h" +#define DONT_ENCAPSULATE #include "syswindows.h" typedef BOOL (WINAPI *pfSwitchToThread_t) (VOID); @@ -65,6 +66,59 @@ (LPCWSTR, DWORD, SHFILEINFOW FAR *, UINT, UINT); pfSHGetFileInfoW_t xSHGetFileInfoW; +/* Encapsulated system calls for file name code conversion. */ +#ifdef MULE +HANDLE +sys_FindFirstFile (LPCSTR lpFileName, + LPWIN32_FIND_DATA lpFindFileData) +{ + HANDLE ret_val; + Bufbyte *fname_int; + Extbyte *fname_ext; + + C_STRING_TO_EXTERNAL (lpFileName, fname_ext, Qfile_name); + ret_val = FindFirstFile (fname_ext, lpFindFileData); + if (ret_val != INVALID_HANDLE_VALUE) + { + EXTERNAL_TO_C_STRING (lpFindFileData->cFileName, fname_int, Qfile_name); + strcpy (lpFindFileData->cFileName, fname_int); + } + return ret_val; +} + +BOOL +sys_FindNextFile (HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData) +{ + BOOL ret_val; + Bufbyte *fname; + + ret_val = FindNextFile (hFindFile, lpFindFileData); + if (ret_val) + { + EXTERNAL_TO_C_STRING (lpFindFileData->cFileName, fname, Qfile_name); + strcpy (lpFindFileData->cFileName, fname); + } + return ret_val; +} + +HANDLE +sys_CreateFile (LPCTSTR lpFileName, + DWORD dwDesiredAccess, + DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDistribution, + DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile) +{ + Extbyte *fname; + + C_STRING_TO_EXTERNAL (lpFileName, fname, Qfile_name); + return CreateFile (fname, dwDesiredAccess, dwShareMode, + lpSecurityAttributes, dwCreationDistribution, + dwFlagsAndAttributes, hTemplateFile); +} +#endif /* MULE */ + Lisp_Object tstr_to_local_file_format (Extbyte *pathout) {