summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@dancol.org>2013-03-10 14:55:25 -0800
committerDaniel Colascione <dancol@dancol.org>2013-03-10 14:55:25 -0800
commit819e2da92a18d7af03ccd9cf0a2e5b940eb7b54f (patch)
tree99d41020f39fd757e30622c6437e99902785a371 /src
parentd2e24f924a37982172ec0708369570a0af315c7e (diff)
downloademacs-819e2da92a18d7af03ccd9cf0a2e5b940eb7b54f.tar.gz
2013-03-10 Daniel Colascione <dancol@dancol.org>
* w32term.h (GUISTR, GUI_ENCODE_FILE, GUI_ENCODE_SYSTEM, GUI_FN) (GUI_SDATA, guichar_t): Macros to abstract out differences between NTGUI_UNICODE and !NTGUI_UNICODE builds, some moved out of w32fns.c. * w32term.c (construct_drag_n_drop): Use the above macros to make drag-and-drop work for non-ASCII filenames in cygw32 builds. * w32fns.c (x_set_name, x_set_title): Use the above macros to properly display non-ASCII frame titles in cygw32 builds. * w32fns.c (Fw32_shell_execute): Use the above macros to properly call ShellExecute in cygw32 builds. * w32fn.c (Fx_file_dialog): Use the above macros to simplify the common file dialog code. * w32fns.c (Ffile_system_info): Remove from cygw32 builds, which can just use du like other systems. * coding.c (from_unicode_buffer): Declare. * coding.c (from_unicode_buffer): Implement.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog25
-rw-r--r--src/coding.c14
-rw-r--r--src/coding.h3
-rw-r--r--src/w32fns.c85
-rw-r--r--src/w32term.c13
-rw-r--r--src/w32term.h17
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 @@
+2013-03-10 Daniel Colascione <dancol@dancol.org>
+
+ * w32term.h (GUISTR, GUI_ENCODE_FILE, GUI_ENCODE_SYSTEM, GUI_FN)
+ (GUI_SDATA, guichar_t): Macros to abstract out differences between
+ NTGUI_UNICODE and !NTGUI_UNICODE builds, some moved out of
+ w32fns.c.
+
+ * w32term.c (construct_drag_n_drop): Use the above macros to make
+ drag-and-drop work for non-ASCII filenames in cygw32 builds.
+
+ * w32fns.c (x_set_name, x_set_title): Use the above macros to
+ properly display non-ASCII frame titles in cygw32 builds.
+
+ * w32fns.c (Fw32_shell_execute): Use the above macros to properly
+ call ShellExecute in cygw32 builds.
+
+ * w32fn.c (Fx_file_dialog): Use the above macros to simplify the
+ common file dialog code.
+
+ * w32fns.c (Ffile_system_info): Remove from cygw32 builds, which
+ can just use du like other systems.
+
+ * coding.c (from_unicode_buffer): Declare.
+ * coding.c (from_unicode_buffer): Implement.
+
2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca>
* 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)
#include <config.h>
#include <stdio.h>
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif /* HAVE_WCHAR_H */
+
#include "lisp.h"
#include "character.h"
#include "buffer.h"
@@ -8003,6 +8007,16 @@ from_unicode (Lisp_Object str)
return code_convert_string_norecord (str, Qutf_16le, 0);
}
+Lisp_Object
+from_unicode_buffer (const wchar_t* wstr)
+{
+ return from_unicode (
+ make_unibyte_string (
+ (char*) wstr,
+ /* we get one of the two final 0 bytes for free. */
+ 1 + sizeof (wchar_t) * wcslen (wstr)));
+}
+
wchar_t *
to_unicode (Lisp_Object str, Lisp_Object *buf)
{
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);
failure modes. STR itself is not modified. */
extern Lisp_Object from_unicode (Lisp_Object str);
+/* Convert WSTR to an Emacs string. */
+extern Lisp_Object from_unicode_buffer (const wchar_t* wstr);
+
#endif /* WINDOWSNT || CYGWIN */
/* 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)
if (FRAME_W32_WINDOW (f))
{
- if (STRING_MULTIBYTE (name))
- name = ENCODE_SYSTEM (name);
-
block_input ();
- SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
+ GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
+ GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
unblock_input ();
}
}
@@ -1767,11 +1765,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
if (FRAME_W32_WINDOW (f))
{
- if (STRING_MULTIBYTE (name))
- name = ENCODE_SYSTEM (name);
-
block_input ();
- SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
+ GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
+ GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
unblock_input ();
}
}
@@ -6006,14 +6002,6 @@ Value is t if tooltip was open, nil otherwise. */)
#define FILE_NAME_COMBO_BOX cmb13
#define FILE_NAME_LIST lst1
-#ifdef NTGUI_UNICODE
-#define GUISTR(x) (L ## x)
-typedef wchar_t guichar_t;
-#else /* !NTGUI_UNICODE */
-#define GUISTR(x) x
-typedef char guichar_t;
-#endif /* NTGUI_UNICODE */
-
/* Callback for altering the behavior of the Open File dialog.
Makes the Filename text field contain "Current Directory" and be
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. */)
block_input ();
file_details->lpfnHook = file_dialog_callback;
-#ifdef NTGUI_UNICODE
- file_opened = GetOpenFileNameW (file_details);
-#else /* !NTGUI_UNICODE */
- file_opened = GetOpenFileNameA (file_details);
-#endif /* NTGUI_UNICODE */
+ file_opened = GUI_FN (GetOpenFileName) (file_details);
unblock_input ();
unbind_to (count, Qnil);
}
@@ -6243,11 +6227,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
{
/* Get an Emacs string from the value Windows gave us. */
#ifdef NTGUI_UNICODE
- filename = from_unicode (
- make_unibyte_string (
- (char*) filename_buf,
- /* we get one of the two final 0 bytes for free. */
- 1 + sizeof (wchar_t) * wcslen (filename_buf)));
+ filename = from_unicode_buffer (filename_buf);
#else /* !NTGUI_UNICODE */
dostounix_filename (filename_buf, 0);
filename = DECODE_FILE (build_string (filename_buf));
@@ -6421,20 +6401,29 @@ an integer representing a ShowWindow flag:
CHECK_STRING (document);
/* Encode filename, current directory and parameters. */
- current_dir = ENCODE_FILE (BVAR (current_buffer, directory));
- document = ENCODE_FILE (document);
+ current_dir = BVAR (current_buffer, directory);
+
+#ifdef CYGWIN
+ current_dir = Fcygwin_convert_file_name_to_windows (current_dir, Qt);
+ if (STRINGP (document))
+ document = Fcygwin_convert_file_name_to_windows (document, Qt);
+#endif /* CYGWIN */
+
+ current_dir = GUI_ENCODE_FILE (current_dir);
+ if (STRINGP (document))
+ document = GUI_ENCODE_FILE (document);
if (STRINGP (parameters))
- parameters = ENCODE_SYSTEM (parameters);
-
- if ((int) ShellExecute (NULL,
- (STRINGP (operation) ?
- SDATA (operation) : NULL),
- SDATA (document),
- (STRINGP (parameters) ?
- SDATA (parameters) : NULL),
- SDATA (current_dir),
- (INTEGERP (show_flag) ?
- XINT (show_flag) : SW_SHOWDEFAULT))
+ parameters = GUI_ENCODE_SYSTEM (parameters);
+
+ if ((int) GUI_FN (ShellExecute) (NULL,
+ (STRINGP (operation) ?
+ GUI_SDATA (operation) : NULL),
+ GUI_SDATA (document),
+ (STRINGP (parameters) ?
+ GUI_SDATA (parameters) : NULL),
+ GUI_SDATA (current_dir),
+ (INTEGERP (show_flag) ?
+ XINT (show_flag) : SW_SHOWDEFAULT))
> 32)
return Qt;
errstr = w32_strerror (0);
@@ -6803,6 +6792,7 @@ The following %-sequences are provided:
}
+#ifdef WINDOWSNT
DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
doc: /* Return storage information about the file system FILENAME is on.
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. */)
return value;
}
+#endif /* WINDOWSNT */
+
DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
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. */);
defsubr (&Sw32_window_exists_p);
defsubr (&Sw32_battery_status);
+#ifdef WINDOWSNT
defsubr (&Sfile_system_info);
+#endif
+
defsubr (&Sdefault_printer_name);
defsubr (&Sset_message_beep);
@@ -7805,3 +7800,15 @@ emacs_abort (void)
}
}
}
+
+#ifdef NTGUI_UNICODE
+
+Lisp_Object
+ntgui_encode_system (Lisp_Object str)
+{
+ Lisp_Object encoded;
+ to_unicode (str, &encoded);
+ return encoded;
+}
+
+#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)
HDROP hdrop;
POINT p;
WORD num_files;
- char *name;
+ guichar_t *name;
int i, len;
result->kind = DRAG_N_DROP_EVENT;
@@ -3186,12 +3186,17 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
for (i = 0; i < num_files; i++)
{
- len = DragQueryFile (hdrop, i, NULL, 0);
+ len = GUI_FN (DragQueryFile) (hdrop, i, NULL, 0);
if (len <= 0)
continue;
- name = alloca (len + 1);
- DragQueryFile (hdrop, i, name, len + 1);
+
+ name = alloca ((len + 1) * sizeof (*name));
+ GUI_FN (DragQueryFile) (hdrop, i, name, len + 1);
+#ifdef NTGUI_UNICODE
+ files = Fcons (from_unicode_buffer (name), files);
+#else
files = Fcons (DECODE_FILE (build_string (name)), files);
+#endif /* NTGUI_UNICODE */
}
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*
w32_name_of_message (UINT msg);
#endif /* EMACSDEBUG */
+#ifdef NTGUI_UNICODE
+extern Lisp_Object ntgui_encode_system (Lisp_Object str);
+#define GUISTR(x) (L ## x)
+#define GUI_ENCODE_FILE GUI_ENCODE_SYSTEM
+#define GUI_ENCODE_SYSTEM(x) ntgui_encode_system (x)
+#define GUI_FN(fn) fn ## W
+typedef wchar_t guichar_t;
+#else /* !NTGUI_UNICODE */
+#define GUISTR(x) x
+#define GUI_ENCODE_FILE ENCODE_FILE
+#define GUI_ENCODE_SYSTEM ENCODE_SYSTEM
+#define GUI_FN(fn) fn
+typedef char guichar_t;
+#endif /* NTGUI_UNICODE */
+
+#define GUI_SDATA(x) ((guichar_t*) SDATA (x))
+
extern void syms_of_w32term (void);
extern void syms_of_w32menu (void);
extern void syms_of_w32fns (void);