Mercurial > emacs
comparison lisp/term/mac-win.el @ 66107:bfc846e38bba
Apply 2005-10-09 change for term/x-win.el.
(x-get-selection, mac-select-convert-to-string): Convert from/to
UTF-16 clipboard data as in native byte order, no BOM.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Sun, 16 Oct 2005 02:21:16 +0000 |
parents | 592847746fca |
children | a9abf9b53bef db4e74787e6f 0ca0d9181b5e |
comparison
equal
deleted
inserted
replaced
66106:9b8e76617c8c | 66107:bfc846e38bba |
---|---|
52 ;; -fg *foreground | 52 ;; -fg *foreground |
53 ;; -fn *font | 53 ;; -fn *font |
54 ;; -font *font | 54 ;; -font *font |
55 ;; -foreground *foreground | 55 ;; -foreground *foreground |
56 ;; -geometry .geometry | 56 ;; -geometry .geometry |
57 ;; -i .iconType | |
58 ;; -itype .iconType | |
59 ;; -iconic .iconic | 57 ;; -iconic .iconic |
60 ;; -name .name | 58 ;; -name .name |
61 ;; -reverse *reverseVideo | 59 ;; -reverse *reverseVideo |
62 ;; -rv *reverseVideo | 60 ;; -rv *reverseVideo |
63 ;; -selectionTimeout .selectionTimeout | 61 ;; -selectionTimeout .selectionTimeout |
1196 (coding (or next-selection-coding-system | 1194 (coding (or next-selection-coding-system |
1197 selection-coding-system))) | 1195 selection-coding-system))) |
1198 (when (and (stringp data) | 1196 (when (and (stringp data) |
1199 (setq data-type (get-text-property 0 'foreign-selection data))) | 1197 (setq data-type (get-text-property 0 'foreign-selection data))) |
1200 (cond ((eq data-type 'public.utf16-plain-text) | 1198 (cond ((eq data-type 'public.utf16-plain-text) |
1201 (let ((encoded (and (fboundp 'mac-code-convert-string) | 1199 (if (fboundp 'mac-code-convert-string) |
1202 (mac-code-convert-string data | 1200 (let ((s (mac-code-convert-string data nil coding))) |
1203 'utf-16 coding)))) | 1201 (if s |
1204 (if encoded | 1202 (setq data (decode-coding-string s coding)) |
1205 (let ((coding-save last-coding-system-used)) | 1203 (setq data |
1206 (setq data (decode-coding-string encoded coding)) | 1204 ;; (decode-coding-string data 'utf-16) is |
1207 (setq last-coding-system-used coding-save)) | 1205 ;; not correct because |
1208 (setq data | 1206 ;; public.utf16-plain-text is defined as |
1209 (decode-coding-string data 'utf-16))))) | 1207 ;; native byte order, no BOM. |
1208 (decode-coding-string | |
1209 (mac-code-convert-string data nil 'utf-8) | |
1210 'utf-8)))) | |
1211 ;; No `mac-code-convert-string' means non-Carbon, which | |
1212 ;; implies big endian. | |
1213 (setq data (decode-coding-string data 'utf-16be)))) | |
1210 ((eq data-type 'com.apple.traditional-mac-plain-text) | 1214 ((eq data-type 'com.apple.traditional-mac-plain-text) |
1211 (setq data (decode-coding-string data coding))) | 1215 (setq data (decode-coding-string data coding))) |
1212 ((eq data-type 'public.file-url) | 1216 ((eq data-type 'public.file-url) |
1213 (setq data (decode-coding-string data 'utf-8)) | 1217 (setq data (decode-coding-string data 'utf-8)) |
1214 ;; Remove a trailing nul character. | 1218 ;; Remove a trailing nul character. |
1321 str | 1325 str |
1322 (let ((inhibit-read-only t)) | 1326 (let ((inhibit-read-only t)) |
1323 (remove-text-properties 0 (length str) '(composition nil) str) | 1327 (remove-text-properties 0 (length str) '(composition nil) str) |
1324 (cond | 1328 (cond |
1325 ((eq type 'public.utf16-plain-text) | 1329 ((eq type 'public.utf16-plain-text) |
1326 (let (s) | 1330 (if (fboundp 'mac-code-convert-string) |
1327 (when (and (fboundp 'mac-code-convert-string) | 1331 (let (s) |
1328 (memq coding (find-coding-systems-string str))) | 1332 (when (memq coding (find-coding-systems-string str)) |
1329 (setq coding (coding-system-change-eol-conversion coding 'mac)) | 1333 (setq coding |
1330 (setq s (mac-code-convert-string | 1334 (coding-system-change-eol-conversion coding 'mac)) |
1331 (encode-coding-string str coding) | 1335 (setq s (mac-code-convert-string |
1332 coding 'utf-16))) | 1336 (encode-coding-string str coding) |
1333 (setq str (or s (encode-coding-string str 'utf-16-mac))))) | 1337 coding nil))) |
1338 (setq str (or s | |
1339 ;; (encode-coding-string str | |
1340 ;; 'utf-16-mac) is not correct because | |
1341 ;; public.utf16-plain-text is defined | |
1342 ;; as native byte order, no BOM. | |
1343 (mac-code-convert-string | |
1344 (encode-coding-string str 'utf-8-mac) | |
1345 'utf-8 nil)))) | |
1346 ;; No `mac-code-convert-string' means non-Carbon, which | |
1347 ;; implies big endian. | |
1348 (setq str (encode-coding-string str 'utf-16be-mac)))) | |
1334 ((eq type 'com.apple.traditional-mac-plain-text) | 1349 ((eq type 'com.apple.traditional-mac-plain-text) |
1335 (let ((encodables (find-coding-systems-string str)) | 1350 (let ((encodables (find-coding-systems-string str)) |
1336 (rest mac-script-code-coding-systems)) | 1351 (rest mac-script-code-coding-systems)) |
1337 (unless (memq coding encodables) | 1352 (unless (memq coding encodables) |
1338 (while (and rest (not (memq (cdar rest) encodables))) | 1353 (while (and rest (not (memq (cdar rest) encodables))) |