diff options
| author | Karoly Lorentey | 2005-04-18 13:40:23 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2005-04-18 13:40:23 +0000 |
| commit | 6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98 (patch) | |
| tree | a40a6371728d46bdfb26b7090612e0ca70e1c057 /src/mac.c | |
| parent | 91fd98fc1eff12aa5a46142efabababa7daf77bb (diff) | |
| parent | d4127a9a1111805640eaa06e9767a7a6f56351a5 (diff) | |
| download | emacs-6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98.tar.gz emacs-6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98.zip | |
Merged from miles@gnu.org--gnu-2005 (patch 60-65, 246-265)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-246
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-247
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-248
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-249
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-250
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-251
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-252
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-253
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-254
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-255
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-256
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-257
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-258
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-259
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-260
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-261
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-262
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-263
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-264
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-265
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-60
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-61
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-62
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-63
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-64
(mm-string-to-multibyte): Use Gnus trunk definition.
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-65
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-328
Diffstat (limited to 'src/mac.c')
| -rw-r--r-- | src/mac.c | 82 |
1 files changed, 77 insertions, 5 deletions
| @@ -31,6 +31,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 31 | #include "sysselect.h" | 31 | #include "sysselect.h" |
| 32 | #include "systime.h" | 32 | #include "systime.h" |
| 33 | #include "blockinput.h" | 33 | #include "blockinput.h" |
| 34 | #include "charset.h" | ||
| 35 | #include "coding.h" | ||
| 34 | 36 | ||
| 35 | #include "macterm.h" | 37 | #include "macterm.h" |
| 36 | 38 | ||
| @@ -49,6 +51,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 49 | #include <Events.h> | 51 | #include <Events.h> |
| 50 | #include <Processes.h> | 52 | #include <Processes.h> |
| 51 | #include <EPPC.h> | 53 | #include <EPPC.h> |
| 54 | #include <MacLocales.h> | ||
| 52 | #endif /* not HAVE_CARBON */ | 55 | #endif /* not HAVE_CARBON */ |
| 53 | 56 | ||
| 54 | #include <utime.h> | 57 | #include <utime.h> |
| @@ -67,6 +70,12 @@ Boston, MA 02111-1307, USA. */ | |||
| 67 | 70 | ||
| 68 | Lisp_Object QCLIPBOARD; | 71 | Lisp_Object QCLIPBOARD; |
| 69 | 72 | ||
| 73 | /* The system script code. */ | ||
| 74 | static int mac_system_script_code; | ||
| 75 | |||
| 76 | /* The system locale identifier string. */ | ||
| 77 | static Lisp_Object Vmac_system_locale; | ||
| 78 | |||
| 70 | /* An instance of the AppleScript component. */ | 79 | /* An instance of the AppleScript component. */ |
| 71 | static ComponentInstance as_scripting_component; | 80 | static ComponentInstance as_scripting_component; |
| 72 | /* The single script context used for all script executions. */ | 81 | /* The single script context used for all script executions. */ |
| @@ -258,7 +267,6 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen) | |||
| 258 | #if TARGET_API_MAC_CARBON | 267 | #if TARGET_API_MAC_CARBON |
| 259 | static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; | 268 | static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; |
| 260 | static Lisp_Object Qarray, Qdictionary; | 269 | static Lisp_Object Qarray, Qdictionary; |
| 261 | extern Lisp_Object Qutf_8; | ||
| 262 | #define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) | 270 | #define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) |
| 263 | 271 | ||
| 264 | struct cfdict_context | 272 | struct cfdict_context |
| @@ -267,7 +275,7 @@ struct cfdict_context | |||
| 267 | int with_tag, hash_bound; | 275 | int with_tag, hash_bound; |
| 268 | }; | 276 | }; |
| 269 | 277 | ||
| 270 | /* C string to CFString. */ | 278 | /* C string to CFString. */ |
| 271 | 279 | ||
| 272 | CFStringRef | 280 | CFStringRef |
| 273 | cfstring_create_with_utf8_cstring (c_str) | 281 | cfstring_create_with_utf8_cstring (c_str) |
| @@ -284,6 +292,37 @@ cfstring_create_with_utf8_cstring (c_str) | |||
| 284 | } | 292 | } |
| 285 | 293 | ||
| 286 | 294 | ||
| 295 | /* Lisp string to CFString. */ | ||
| 296 | |||
| 297 | CFStringRef | ||
| 298 | cfstring_create_with_string (s) | ||
| 299 | Lisp_Object s; | ||
| 300 | { | ||
| 301 | CFStringRef string = NULL; | ||
| 302 | |||
| 303 | if (STRING_MULTIBYTE (s)) | ||
| 304 | { | ||
| 305 | char *p, *end = SDATA (s) + SBYTES (s); | ||
| 306 | |||
| 307 | for (p = SDATA (s); p < end; p++) | ||
| 308 | if (!isascii (*p)) | ||
| 309 | { | ||
| 310 | s = ENCODE_UTF_8 (s); | ||
| 311 | break; | ||
| 312 | } | ||
| 313 | string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s), | ||
| 314 | kCFStringEncodingUTF8, false); | ||
| 315 | } | ||
| 316 | |||
| 317 | if (string == NULL) | ||
| 318 | /* Failed to interpret as UTF 8. Fall back on Mac Roman. */ | ||
| 319 | string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s), | ||
| 320 | kCFStringEncodingMacRoman, false); | ||
| 321 | |||
| 322 | return string; | ||
| 323 | } | ||
| 324 | |||
| 325 | |||
| 287 | /* From CFData to a lisp string. Always returns a unibyte string. */ | 326 | /* From CFData to a lisp string. Always returns a unibyte string. */ |
| 288 | 327 | ||
| 289 | Lisp_Object | 328 | Lisp_Object |
| @@ -3704,11 +3743,11 @@ otherwise. */) | |||
| 3704 | app_id = kCFPreferencesCurrentApplication; | 3743 | app_id = kCFPreferencesCurrentApplication; |
| 3705 | if (!NILP (application)) | 3744 | if (!NILP (application)) |
| 3706 | { | 3745 | { |
| 3707 | app_id = cfstring_create_with_utf8_cstring (SDATA (application)); | 3746 | app_id = cfstring_create_with_string (application); |
| 3708 | if (app_id == NULL) | 3747 | if (app_id == NULL) |
| 3709 | goto out; | 3748 | goto out; |
| 3710 | } | 3749 | } |
| 3711 | key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); | 3750 | key_str = cfstring_create_with_string (XCAR (key)); |
| 3712 | if (key_str == NULL) | 3751 | if (key_str == NULL) |
| 3713 | goto out; | 3752 | goto out; |
| 3714 | app_plist = CFPreferencesCopyAppValue (key_str, app_id); | 3753 | app_plist = CFPreferencesCopyAppValue (key_str, app_id); |
| @@ -3721,7 +3760,7 @@ otherwise. */) | |||
| 3721 | { | 3760 | { |
| 3722 | if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) | 3761 | if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) |
| 3723 | break; | 3762 | break; |
| 3724 | key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); | 3763 | key_str = cfstring_create_with_string (XCAR (key)); |
| 3725 | if (key_str == NULL) | 3764 | if (key_str == NULL) |
| 3726 | goto out; | 3765 | goto out; |
| 3727 | plist = CFDictionaryGetValue (plist, key_str); | 3766 | plist = CFDictionaryGetValue (plist, key_str); |
| @@ -4167,6 +4206,29 @@ init_mac_osx_environment () | |||
| 4167 | } | 4206 | } |
| 4168 | #endif /* MAC_OSX */ | 4207 | #endif /* MAC_OSX */ |
| 4169 | 4208 | ||
| 4209 | |||
| 4210 | static Lisp_Object | ||
| 4211 | mac_get_system_locale () | ||
| 4212 | { | ||
| 4213 | OSErr err; | ||
| 4214 | LangCode lang; | ||
| 4215 | RegionCode region; | ||
| 4216 | LocaleRef locale; | ||
| 4217 | Str255 str; | ||
| 4218 | |||
| 4219 | lang = GetScriptVariable (smSystemScript, smScriptLang); | ||
| 4220 | region = GetScriptManagerVariable (smRegionCode); | ||
| 4221 | err = LocaleRefFromLangOrRegionCode (lang, region, &locale); | ||
| 4222 | if (err == noErr) | ||
| 4223 | err = LocaleRefGetPartString (locale, kLocaleAllPartsMask, | ||
| 4224 | sizeof (str), str); | ||
| 4225 | if (err == noErr) | ||
| 4226 | return build_string (str); | ||
| 4227 | else | ||
| 4228 | return Qnil; | ||
| 4229 | } | ||
| 4230 | |||
| 4231 | |||
| 4170 | void | 4232 | void |
| 4171 | syms_of_mac () | 4233 | syms_of_mac () |
| 4172 | { | 4234 | { |
| @@ -4197,6 +4259,16 @@ syms_of_mac () | |||
| 4197 | defsubr (&Sdo_applescript); | 4259 | defsubr (&Sdo_applescript); |
| 4198 | defsubr (&Smac_file_name_to_posix); | 4260 | defsubr (&Smac_file_name_to_posix); |
| 4199 | defsubr (&Sposix_file_name_to_mac); | 4261 | defsubr (&Sposix_file_name_to_mac); |
| 4262 | |||
| 4263 | DEFVAR_INT ("mac-system-script-code", &mac_system_script_code, | ||
| 4264 | doc: /* The system script code. */); | ||
| 4265 | mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript); | ||
| 4266 | |||
| 4267 | DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale, | ||
| 4268 | doc: /* The system locale identifier string. | ||
| 4269 | This is not a POSIX locale ID, but an ICU locale ID. So encoding | ||
| 4270 | information is not included. */); | ||
| 4271 | Vmac_system_locale = mac_get_system_locale (); | ||
| 4200 | } | 4272 | } |
| 4201 | 4273 | ||
| 4202 | /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff | 4274 | /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff |