diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 25 | ||||
| -rw-r--r-- | src/coding.c | 14 | ||||
| -rw-r--r-- | src/coding.h | 3 | ||||
| -rw-r--r-- | src/w32fns.c | 85 | ||||
| -rw-r--r-- | src/w32term.c | 13 | ||||
| -rw-r--r-- | src/w32term.h | 17 |
6 files changed, 114 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 117c08d1875..b553c96a1db 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,28 @@ | |||
| 1 | 2013-03-10 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * w32term.h (GUISTR, GUI_ENCODE_FILE, GUI_ENCODE_SYSTEM, GUI_FN) | ||
| 4 | (GUI_SDATA, guichar_t): Macros to abstract out differences between | ||
| 5 | NTGUI_UNICODE and !NTGUI_UNICODE builds, some moved out of | ||
| 6 | w32fns.c. | ||
| 7 | |||
| 8 | * w32term.c (construct_drag_n_drop): Use the above macros to make | ||
| 9 | drag-and-drop work for non-ASCII filenames in cygw32 builds. | ||
| 10 | |||
| 11 | * w32fns.c (x_set_name, x_set_title): Use the above macros to | ||
| 12 | properly display non-ASCII frame titles in cygw32 builds. | ||
| 13 | |||
| 14 | * w32fns.c (Fw32_shell_execute): Use the above macros to properly | ||
| 15 | call ShellExecute in cygw32 builds. | ||
| 16 | |||
| 17 | * w32fn.c (Fx_file_dialog): Use the above macros to simplify the | ||
| 18 | common file dialog code. | ||
| 19 | |||
| 20 | * w32fns.c (Ffile_system_info): Remove from cygw32 builds, which | ||
| 21 | can just use du like other systems. | ||
| 22 | |||
| 23 | * coding.c (from_unicode_buffer): Declare. | ||
| 24 | * coding.c (from_unicode_buffer): Implement. | ||
| 25 | |||
| 1 | 2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca> | 26 | 2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 27 | ||
| 3 | * lread.c: Minor cleanup. | 28 | * lread.c: Minor cleanup. |
diff --git a/src/coding.c b/src/coding.c index d6560a92b70..c18632f301b 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -286,6 +286,10 @@ encode_coding_XXX (struct coding_system *coding) | |||
| 286 | #include <config.h> | 286 | #include <config.h> |
| 287 | #include <stdio.h> | 287 | #include <stdio.h> |
| 288 | 288 | ||
| 289 | #ifdef HAVE_WCHAR_H | ||
| 290 | #include <wchar.h> | ||
| 291 | #endif /* HAVE_WCHAR_H */ | ||
| 292 | |||
| 289 | #include "lisp.h" | 293 | #include "lisp.h" |
| 290 | #include "character.h" | 294 | #include "character.h" |
| 291 | #include "buffer.h" | 295 | #include "buffer.h" |
| @@ -8003,6 +8007,16 @@ from_unicode (Lisp_Object str) | |||
| 8003 | return code_convert_string_norecord (str, Qutf_16le, 0); | 8007 | return code_convert_string_norecord (str, Qutf_16le, 0); |
| 8004 | } | 8008 | } |
| 8005 | 8009 | ||
| 8010 | Lisp_Object | ||
| 8011 | from_unicode_buffer (const wchar_t* wstr) | ||
| 8012 | { | ||
| 8013 | return from_unicode ( | ||
| 8014 | make_unibyte_string ( | ||
| 8015 | (char*) wstr, | ||
| 8016 | /* we get one of the two final 0 bytes for free. */ | ||
| 8017 | 1 + sizeof (wchar_t) * wcslen (wstr))); | ||
| 8018 | } | ||
| 8019 | |||
| 8006 | wchar_t * | 8020 | wchar_t * |
| 8007 | to_unicode (Lisp_Object str, Lisp_Object *buf) | 8021 | to_unicode (Lisp_Object str, Lisp_Object *buf) |
| 8008 | { | 8022 | { |
diff --git a/src/coding.h b/src/coding.h index 28a7d776b63..c13567c3d53 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -715,6 +715,9 @@ extern wchar_t *to_unicode (Lisp_Object str, Lisp_Object *buf); | |||
| 715 | failure modes. STR itself is not modified. */ | 715 | failure modes. STR itself is not modified. */ |
| 716 | extern Lisp_Object from_unicode (Lisp_Object str); | 716 | extern Lisp_Object from_unicode (Lisp_Object str); |
| 717 | 717 | ||
| 718 | /* Convert WSTR to an Emacs string. */ | ||
| 719 | extern Lisp_Object from_unicode_buffer (const wchar_t* wstr); | ||
| 720 | |||
| 718 | #endif /* WINDOWSNT || CYGWIN */ | 721 | #endif /* WINDOWSNT || CYGWIN */ |
| 719 | 722 | ||
| 720 | /* Macros for backward compatibility. */ | 723 | /* Macros for backward compatibility. */ |
diff --git a/src/w32fns.c b/src/w32fns.c index 56cc1f37d08..cef2009d7a1 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1721,11 +1721,9 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) | |||
| 1721 | 1721 | ||
| 1722 | if (FRAME_W32_WINDOW (f)) | 1722 | if (FRAME_W32_WINDOW (f)) |
| 1723 | { | 1723 | { |
| 1724 | if (STRING_MULTIBYTE (name)) | ||
| 1725 | name = ENCODE_SYSTEM (name); | ||
| 1726 | |||
| 1727 | block_input (); | 1724 | block_input (); |
| 1728 | SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); | 1725 | GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f), |
| 1726 | GUI_SDATA (GUI_ENCODE_SYSTEM (name))); | ||
| 1729 | unblock_input (); | 1727 | unblock_input (); |
| 1730 | } | 1728 | } |
| 1731 | } | 1729 | } |
| @@ -1767,11 +1765,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) | |||
| 1767 | 1765 | ||
| 1768 | if (FRAME_W32_WINDOW (f)) | 1766 | if (FRAME_W32_WINDOW (f)) |
| 1769 | { | 1767 | { |
| 1770 | if (STRING_MULTIBYTE (name)) | ||
| 1771 | name = ENCODE_SYSTEM (name); | ||
| 1772 | |||
| 1773 | block_input (); | 1768 | block_input (); |
| 1774 | SetWindowText (FRAME_W32_WINDOW (f), SDATA (name)); | 1769 | GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f), |
| 1770 | GUI_SDATA (GUI_ENCODE_SYSTEM (name))); | ||
| 1775 | unblock_input (); | 1771 | unblock_input (); |
| 1776 | } | 1772 | } |
| 1777 | } | 1773 | } |
| @@ -6006,14 +6002,6 @@ Value is t if tooltip was open, nil otherwise. */) | |||
| 6006 | #define FILE_NAME_COMBO_BOX cmb13 | 6002 | #define FILE_NAME_COMBO_BOX cmb13 |
| 6007 | #define FILE_NAME_LIST lst1 | 6003 | #define FILE_NAME_LIST lst1 |
| 6008 | 6004 | ||
| 6009 | #ifdef NTGUI_UNICODE | ||
| 6010 | #define GUISTR(x) (L ## x) | ||
| 6011 | typedef wchar_t guichar_t; | ||
| 6012 | #else /* !NTGUI_UNICODE */ | ||
| 6013 | #define GUISTR(x) x | ||
| 6014 | typedef char guichar_t; | ||
| 6015 | #endif /* NTGUI_UNICODE */ | ||
| 6016 | |||
| 6017 | /* Callback for altering the behavior of the Open File dialog. | 6005 | /* Callback for altering the behavior of the Open File dialog. |
| 6018 | Makes the Filename text field contain "Current Directory" and be | 6006 | Makes the Filename text field contain "Current Directory" and be |
| 6019 | read-only when "Directories" is selected in the filter. This | 6007 | read-only when "Directories" is selected in the filter. This |
| @@ -6230,11 +6218,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 6230 | block_input (); | 6218 | block_input (); |
| 6231 | file_details->lpfnHook = file_dialog_callback; | 6219 | file_details->lpfnHook = file_dialog_callback; |
| 6232 | 6220 | ||
| 6233 | #ifdef NTGUI_UNICODE | 6221 | file_opened = GUI_FN (GetOpenFileName) (file_details); |
| 6234 | file_opened = GetOpenFileNameW (file_details); | ||
| 6235 | #else /* !NTGUI_UNICODE */ | ||
| 6236 | file_opened = GetOpenFileNameA (file_details); | ||
| 6237 | #endif /* NTGUI_UNICODE */ | ||
| 6238 | unblock_input (); | 6222 | unblock_input (); |
| 6239 | unbind_to (count, Qnil); | 6223 | unbind_to (count, Qnil); |
| 6240 | } | 6224 | } |
| @@ -6243,11 +6227,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 6243 | { | 6227 | { |
| 6244 | /* Get an Emacs string from the value Windows gave us. */ | 6228 | /* Get an Emacs string from the value Windows gave us. */ |
| 6245 | #ifdef NTGUI_UNICODE | 6229 | #ifdef NTGUI_UNICODE |
| 6246 | filename = from_unicode ( | 6230 | filename = from_unicode_buffer (filename_buf); |
| 6247 | make_unibyte_string ( | ||
| 6248 | (char*) filename_buf, | ||
| 6249 | /* we get one of the two final 0 bytes for free. */ | ||
| 6250 | 1 + sizeof (wchar_t) * wcslen (filename_buf))); | ||
| 6251 | #else /* !NTGUI_UNICODE */ | 6231 | #else /* !NTGUI_UNICODE */ |
| 6252 | dostounix_filename (filename_buf, 0); | 6232 | dostounix_filename (filename_buf, 0); |
| 6253 | filename = DECODE_FILE (build_string (filename_buf)); | 6233 | filename = DECODE_FILE (build_string (filename_buf)); |
| @@ -6421,20 +6401,29 @@ an integer representing a ShowWindow flag: | |||
| 6421 | CHECK_STRING (document); | 6401 | CHECK_STRING (document); |
| 6422 | 6402 | ||
| 6423 | /* Encode filename, current directory and parameters. */ | 6403 | /* Encode filename, current directory and parameters. */ |
| 6424 | current_dir = ENCODE_FILE (BVAR (current_buffer, directory)); | 6404 | current_dir = BVAR (current_buffer, directory); |
| 6425 | document = ENCODE_FILE (document); | 6405 | |
| 6406 | #ifdef CYGWIN | ||
| 6407 | current_dir = Fcygwin_convert_file_name_to_windows (current_dir, Qt); | ||
| 6408 | if (STRINGP (document)) | ||
| 6409 | document = Fcygwin_convert_file_name_to_windows (document, Qt); | ||
| 6410 | #endif /* CYGWIN */ | ||
| 6411 | |||
| 6412 | current_dir = GUI_ENCODE_FILE (current_dir); | ||
| 6413 | if (STRINGP (document)) | ||
| 6414 | document = GUI_ENCODE_FILE (document); | ||
| 6426 | if (STRINGP (parameters)) | 6415 | if (STRINGP (parameters)) |
| 6427 | parameters = ENCODE_SYSTEM (parameters); | 6416 | parameters = GUI_ENCODE_SYSTEM (parameters); |
| 6428 | 6417 | ||
| 6429 | if ((int) ShellExecute (NULL, | 6418 | if ((int) GUI_FN (ShellExecute) (NULL, |
| 6430 | (STRINGP (operation) ? | 6419 | (STRINGP (operation) ? |
| 6431 | SDATA (operation) : NULL), | 6420 | GUI_SDATA (operation) : NULL), |
| 6432 | SDATA (document), | 6421 | GUI_SDATA (document), |
| 6433 | (STRINGP (parameters) ? | 6422 | (STRINGP (parameters) ? |
| 6434 | SDATA (parameters) : NULL), | 6423 | GUI_SDATA (parameters) : NULL), |
| 6435 | SDATA (current_dir), | 6424 | GUI_SDATA (current_dir), |
| 6436 | (INTEGERP (show_flag) ? | 6425 | (INTEGERP (show_flag) ? |
| 6437 | XINT (show_flag) : SW_SHOWDEFAULT)) | 6426 | XINT (show_flag) : SW_SHOWDEFAULT)) |
| 6438 | > 32) | 6427 | > 32) |
| 6439 | return Qt; | 6428 | return Qt; |
| 6440 | errstr = w32_strerror (0); | 6429 | errstr = w32_strerror (0); |
| @@ -6803,6 +6792,7 @@ The following %-sequences are provided: | |||
| 6803 | } | 6792 | } |
| 6804 | 6793 | ||
| 6805 | 6794 | ||
| 6795 | #ifdef WINDOWSNT | ||
| 6806 | DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0, | 6796 | DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0, |
| 6807 | doc: /* Return storage information about the file system FILENAME is on. | 6797 | doc: /* Return storage information about the file system FILENAME is on. |
| 6808 | Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total | 6798 | Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total |
| @@ -6898,6 +6888,8 @@ If the underlying system call fails, value is nil. */) | |||
| 6898 | 6888 | ||
| 6899 | return value; | 6889 | return value; |
| 6900 | } | 6890 | } |
| 6891 | #endif /* WINDOWSNT */ | ||
| 6892 | |||
| 6901 | 6893 | ||
| 6902 | DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, | 6894 | DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name, |
| 6903 | 0, 0, 0, doc: /* Return the name of Windows default printer device. */) | 6895 | 0, 0, 0, doc: /* Return the name of Windows default printer device. */) |
| @@ -7624,7 +7616,10 @@ only be necessary if the default setting causes problems. */); | |||
| 7624 | defsubr (&Sw32_window_exists_p); | 7616 | defsubr (&Sw32_window_exists_p); |
| 7625 | defsubr (&Sw32_battery_status); | 7617 | defsubr (&Sw32_battery_status); |
| 7626 | 7618 | ||
| 7619 | #ifdef WINDOWSNT | ||
| 7627 | defsubr (&Sfile_system_info); | 7620 | defsubr (&Sfile_system_info); |
| 7621 | #endif | ||
| 7622 | |||
| 7628 | defsubr (&Sdefault_printer_name); | 7623 | defsubr (&Sdefault_printer_name); |
| 7629 | defsubr (&Sset_message_beep); | 7624 | defsubr (&Sset_message_beep); |
| 7630 | 7625 | ||
| @@ -7805,3 +7800,15 @@ emacs_abort (void) | |||
| 7805 | } | 7800 | } |
| 7806 | } | 7801 | } |
| 7807 | } | 7802 | } |
| 7803 | |||
| 7804 | #ifdef NTGUI_UNICODE | ||
| 7805 | |||
| 7806 | Lisp_Object | ||
| 7807 | ntgui_encode_system (Lisp_Object str) | ||
| 7808 | { | ||
| 7809 | Lisp_Object encoded; | ||
| 7810 | to_unicode (str, &encoded); | ||
| 7811 | return encoded; | ||
| 7812 | } | ||
| 7813 | |||
| 7814 | #endif /* NTGUI_UNICODE */ | ||
diff --git a/src/w32term.c b/src/w32term.c index 170f33ecd67..6137d54c837 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -3161,7 +3161,7 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f) | |||
| 3161 | HDROP hdrop; | 3161 | HDROP hdrop; |
| 3162 | POINT p; | 3162 | POINT p; |
| 3163 | WORD num_files; | 3163 | WORD num_files; |
| 3164 | char *name; | 3164 | guichar_t *name; |
| 3165 | int i, len; | 3165 | int i, len; |
| 3166 | 3166 | ||
| 3167 | result->kind = DRAG_N_DROP_EVENT; | 3167 | result->kind = DRAG_N_DROP_EVENT; |
| @@ -3186,12 +3186,17 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f) | |||
| 3186 | 3186 | ||
| 3187 | for (i = 0; i < num_files; i++) | 3187 | for (i = 0; i < num_files; i++) |
| 3188 | { | 3188 | { |
| 3189 | len = DragQueryFile (hdrop, i, NULL, 0); | 3189 | len = GUI_FN (DragQueryFile) (hdrop, i, NULL, 0); |
| 3190 | if (len <= 0) | 3190 | if (len <= 0) |
| 3191 | continue; | 3191 | continue; |
| 3192 | name = alloca (len + 1); | 3192 | |
| 3193 | DragQueryFile (hdrop, i, name, len + 1); | 3193 | name = alloca ((len + 1) * sizeof (*name)); |
| 3194 | GUI_FN (DragQueryFile) (hdrop, i, name, len + 1); | ||
| 3195 | #ifdef NTGUI_UNICODE | ||
| 3196 | files = Fcons (from_unicode_buffer (name), files); | ||
| 3197 | #else | ||
| 3194 | files = Fcons (DECODE_FILE (build_string (name)), files); | 3198 | files = Fcons (DECODE_FILE (build_string (name)), files); |
| 3199 | #endif /* NTGUI_UNICODE */ | ||
| 3195 | } | 3200 | } |
| 3196 | 3201 | ||
| 3197 | DragFinish (hdrop); | 3202 | DragFinish (hdrop); |
diff --git a/src/w32term.h b/src/w32term.h index 7154d549f21..a31c5de193d 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -761,6 +761,23 @@ extern const char* | |||
| 761 | w32_name_of_message (UINT msg); | 761 | w32_name_of_message (UINT msg); |
| 762 | #endif /* EMACSDEBUG */ | 762 | #endif /* EMACSDEBUG */ |
| 763 | 763 | ||
| 764 | #ifdef NTGUI_UNICODE | ||
| 765 | extern Lisp_Object ntgui_encode_system (Lisp_Object str); | ||
| 766 | #define GUISTR(x) (L ## x) | ||
| 767 | #define GUI_ENCODE_FILE GUI_ENCODE_SYSTEM | ||
| 768 | #define GUI_ENCODE_SYSTEM(x) ntgui_encode_system (x) | ||
| 769 | #define GUI_FN(fn) fn ## W | ||
| 770 | typedef wchar_t guichar_t; | ||
| 771 | #else /* !NTGUI_UNICODE */ | ||
| 772 | #define GUISTR(x) x | ||
| 773 | #define GUI_ENCODE_FILE ENCODE_FILE | ||
| 774 | #define GUI_ENCODE_SYSTEM ENCODE_SYSTEM | ||
| 775 | #define GUI_FN(fn) fn | ||
| 776 | typedef char guichar_t; | ||
| 777 | #endif /* NTGUI_UNICODE */ | ||
| 778 | |||
| 779 | #define GUI_SDATA(x) ((guichar_t*) SDATA (x)) | ||
| 780 | |||
| 764 | extern void syms_of_w32term (void); | 781 | extern void syms_of_w32term (void); |
| 765 | extern void syms_of_w32menu (void); | 782 | extern void syms_of_w32menu (void); |
| 766 | extern void syms_of_w32fns (void); | 783 | extern void syms_of_w32fns (void); |