diff options
| author | YAMAMOTO Mitsuharu | 2005-05-06 08:01:13 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-05-06 08:01:13 +0000 |
| commit | 2f13e358c8dd40eaccacdb75c75891ef60477d3d (patch) | |
| tree | 5e986161692e048f5da44048e723c59ba18fb0e7 | |
| parent | 31640842b6cd2970ced612a422fa785d2d718dc0 (diff) | |
| download | emacs-2f13e358c8dd40eaccacdb75c75891ef60477d3d.tar.gz emacs-2f13e358c8dd40eaccacdb75c75891ef60477d3d.zip | |
Don't define or bind scroll bar functions if
x-toolkit-scroll-bars is t.
(x-select-text, x-get-selection-value): Clear
x-last-selected-text-clipboard if x-select-enable-clipboard is
nil.
(PRIMARY): Put mac-scrap-name property.
(mac-select-convert-to-file-url): New function.
(public.file-url): New selection target type. Add to
selection-converter-alist.
(x-get-selection, x-selection-value): Handle it.
(x-cut-buffer-or-selection-value): New alias.
| -rw-r--r-- | lisp/term/mac-win.el | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el index 9519dadeed5..64623e76ce9 100644 --- a/lisp/term/mac-win.el +++ b/lisp/term/mac-win.el | |||
| @@ -1168,7 +1168,8 @@ This is in addition to the primary selection." | |||
| 1168 | (defun x-select-text (text &optional push) | 1168 | (defun x-select-text (text &optional push) |
| 1169 | (x-set-selection 'PRIMARY text) | 1169 | (x-set-selection 'PRIMARY text) |
| 1170 | (setq x-last-selected-text-primary text) | 1170 | (setq x-last-selected-text-primary text) |
| 1171 | (when x-select-enable-clipboard | 1171 | (if (not x-select-enable-clipboard) |
| 1172 | (setq x-last-selected-text-clipboard nil) | ||
| 1172 | (x-set-selection 'CLIPBOARD text) | 1173 | (x-set-selection 'CLIPBOARD text) |
| 1173 | (setq x-last-selected-text-clipboard text)) | 1174 | (setq x-last-selected-text-clipboard text)) |
| 1174 | ) | 1175 | ) |
| @@ -1203,20 +1204,26 @@ in `selection-converter-alist', which see." | |||
| 1203 | (setq data | 1204 | (setq data |
| 1204 | (decode-coding-string data 'utf-16))))) | 1205 | (decode-coding-string data 'utf-16))))) |
| 1205 | ((eq data-type 'com.apple.traditional-mac-plain-text) | 1206 | ((eq data-type 'com.apple.traditional-mac-plain-text) |
| 1206 | (setq data (decode-coding-string data coding)))) | 1207 | (setq data (decode-coding-string data coding))) |
| 1208 | ((eq data-type 'public.file-url) | ||
| 1209 | (setq data (decode-coding-string data 'utf-8)) | ||
| 1210 | ;; Remove a trailing nul character. | ||
| 1211 | (let ((len (length data))) | ||
| 1212 | (if (and (> len 0) (= (aref data (1- len)) ?\0)) | ||
| 1213 | (setq data (substring data 0 (1- len))))))) | ||
| 1207 | (put-text-property 0 (length data) 'foreign-selection data-type data)) | 1214 | (put-text-property 0 (length data) 'foreign-selection data-type data)) |
| 1208 | data)) | 1215 | data)) |
| 1209 | 1216 | ||
| 1210 | (defun x-selection-value (type) | 1217 | (defun x-selection-value (type) |
| 1211 | (let (text tiff-image) | 1218 | (let ((data-types '(public.utf16-plain-text |
| 1212 | (setq text (condition-case nil | 1219 | com.apple.traditional-mac-plain-text |
| 1213 | (x-get-selection type 'public.utf16-plain-text) | 1220 | public.file-url)) |
| 1214 | (error nil))) | 1221 | text tiff-image) |
| 1215 | (if (not text) | 1222 | (while (and (null text) data-types) |
| 1216 | (setq text (condition-case nil | 1223 | (setq text (condition-case nil |
| 1217 | (x-get-selection type | 1224 | (x-get-selection type (car data-types)) |
| 1218 | 'com.apple.traditional-mac-plain-text) | 1225 | (error nil))) |
| 1219 | (error nil)))) | 1226 | (setq data-types (cdr data-types))) |
| 1220 | (if text | 1227 | (if text |
| 1221 | (remove-text-properties 0 (length text) '(foreign-selection nil) text)) | 1228 | (remove-text-properties 0 (length text) '(foreign-selection nil) text)) |
| 1222 | (setq tiff-image (condition-case nil | 1229 | (setq tiff-image (condition-case nil |
| @@ -1237,7 +1244,8 @@ in `selection-converter-alist', which see." | |||
| 1237 | ;;; selection won't be added to the kill ring over and over. | 1244 | ;;; selection won't be added to the kill ring over and over. |
| 1238 | (defun x-get-selection-value () | 1245 | (defun x-get-selection-value () |
| 1239 | (let (clip-text primary-text) | 1246 | (let (clip-text primary-text) |
| 1240 | (when x-select-enable-clipboard | 1247 | (if (not x-select-enable-clipboard) |
| 1248 | (setq x-last-selected-text-clipboard nil) | ||
| 1241 | (setq clip-text (x-selection-value 'CLIPBOARD)) | 1249 | (setq clip-text (x-selection-value 'CLIPBOARD)) |
| 1242 | (if (string= clip-text "") (setq clip-text nil)) | 1250 | (if (string= clip-text "") (setq clip-text nil)) |
| 1243 | 1251 | ||
| @@ -1286,11 +1294,14 @@ in `selection-converter-alist', which see." | |||
| 1286 | )) | 1294 | )) |
| 1287 | 1295 | ||
| 1288 | (put 'CLIPBOARD 'mac-scrap-name "com.apple.scrap.clipboard") | 1296 | (put 'CLIPBOARD 'mac-scrap-name "com.apple.scrap.clipboard") |
| 1289 | (if (eq system-type 'darwin) | 1297 | (when (eq system-type 'darwin) |
| 1290 | (put 'FIND 'mac-scrap-name "com.apple.scrap.find")) | 1298 | (put 'FIND 'mac-scrap-name "com.apple.scrap.find") |
| 1299 | (put 'PRIMARY 'mac-scrap-name | ||
| 1300 | (format "org.gnu.Emacs.%d.selection.PRIMARY" (emacs-pid)))) | ||
| 1291 | (put 'com.apple.traditional-mac-plain-text 'mac-ostype "TEXT") | 1301 | (put 'com.apple.traditional-mac-plain-text 'mac-ostype "TEXT") |
| 1292 | (put 'public.utf16-plain-text 'mac-ostype "utxt") | 1302 | (put 'public.utf16-plain-text 'mac-ostype "utxt") |
| 1293 | (put 'public.tiff 'mac-ostype "TIFF") | 1303 | (put 'public.tiff 'mac-ostype "TIFF") |
| 1304 | (put 'public.file-url 'mac-ostype "furl") | ||
| 1294 | 1305 | ||
| 1295 | (defun mac-select-convert-to-string (selection type value) | 1306 | (defun mac-select-convert-to-string (selection type value) |
| 1296 | (let ((str (cdr (xselect-convert-to-string selection nil value))) | 1307 | (let ((str (cdr (xselect-convert-to-string selection nil value))) |
| @@ -1326,6 +1337,16 @@ in `selection-converter-alist', which see." | |||
| 1326 | (setq next-selection-coding-system nil) | 1337 | (setq next-selection-coding-system nil) |
| 1327 | (cons type str)))) | 1338 | (cons type str)))) |
| 1328 | 1339 | ||
| 1340 | (defun mac-select-convert-to-file-url (selection type value) | ||
| 1341 | (let ((filename (xselect-convert-to-filename selection type value)) | ||
| 1342 | (coding (or file-name-coding-system default-file-name-coding-system))) | ||
| 1343 | (if (and filename coding) | ||
| 1344 | (setq filename (encode-coding-string filename coding))) | ||
| 1345 | (and filename | ||
| 1346 | (concat "file://localhost" | ||
| 1347 | (mapconcat 'url-hexify-string | ||
| 1348 | (split-string filename "/") "/"))))) | ||
| 1349 | |||
| 1329 | (setq selection-converter-alist | 1350 | (setq selection-converter-alist |
| 1330 | (nconc | 1351 | (nconc |
| 1331 | '((public.utf16-plain-text . mac-select-convert-to-string) | 1352 | '((public.utf16-plain-text . mac-select-convert-to-string) |
| @@ -1333,6 +1354,7 @@ in `selection-converter-alist', which see." | |||
| 1333 | ;; This is not enabled by default because the `Import Image' | 1354 | ;; This is not enabled by default because the `Import Image' |
| 1334 | ;; menu makes Emacs crash or hang for unknown reasons. | 1355 | ;; menu makes Emacs crash or hang for unknown reasons. |
| 1335 | ;; (public.tiff . nil) | 1356 | ;; (public.tiff . nil) |
| 1357 | (public.file-url . mac-select-convert-to-file-url) | ||
| 1336 | ) | 1358 | ) |
| 1337 | selection-converter-alist)) | 1359 | selection-converter-alist)) |
| 1338 | 1360 | ||
| @@ -1702,6 +1724,7 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman") | |||
| 1702 | (setq interprogram-cut-function 'x-select-text) | 1724 | (setq interprogram-cut-function 'x-select-text) |
| 1703 | (setq interprogram-paste-function 'x-get-selection-value) | 1725 | (setq interprogram-paste-function 'x-get-selection-value) |
| 1704 | 1726 | ||
| 1727 | (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value) | ||
| 1705 | 1728 | ||
| 1706 | ;;; Turn off window-splitting optimization; Mac is usually fast enough | 1729 | ;;; Turn off window-splitting optimization; Mac is usually fast enough |
| 1707 | ;;; that this is only annoying. | 1730 | ;;; that this is only annoying. |
| @@ -1756,7 +1779,9 @@ Switch to a buffer editing the last file dropped." | |||
| 1756 | '(lambda () | 1779 | '(lambda () |
| 1757 | (defvar mac-ready-for-drag-n-drop t))) | 1780 | (defvar mac-ready-for-drag-n-drop t))) |
| 1758 | 1781 | ||
| 1759 | ;;;; Scroll bars | 1782 | ;;;; Non-toolkit Scroll bars |
| 1783 | |||
| 1784 | (unless x-toolkit-scroll-bars | ||
| 1760 | 1785 | ||
| 1761 | ;; for debugging | 1786 | ;; for debugging |
| 1762 | ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event)) | 1787 | ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event)) |
| @@ -1816,6 +1841,7 @@ Switch to a buffer editing the last file dropped." | |||
| 1816 | (mac-scroll-ignore-events) | 1841 | (mac-scroll-ignore-events) |
| 1817 | (scroll-up 1))) | 1842 | (scroll-up 1))) |
| 1818 | 1843 | ||
| 1844 | ) | ||
| 1819 | 1845 | ||
| 1820 | ;;;; Others | 1846 | ;;;; Others |
| 1821 | 1847 | ||