Mercurial > emacs
comparison lisp/term/mac-win.el @ 71175:ed68e074ebb4
(mac-ts-active-input-overlay): Add defvar.
(mac-ae-number, mac-ae-frame, mac-ae-script-language)
(mac-bytes-to-text-range, mac-ae-text-range-array)
(mac-ts-update-active-input-buf, mac-split-string-by-property-change)
(mac-replace-untranslated-utf-8-chars, mac-ts-update-active-input-area)
(mac-ts-unicode-for-key-event): New functions.
(mac-handle-toolbar-switch-mode): Use mac-ae-frame.
(mac-handle-font-selection): Use mac-ae-number.
(mac-ts-active-input-buf, mac-ts-update-active-input-area-seqno):
New variables.
(mac-ts-caret-position, mac-ts-raw-text, mac-ts-selected-raw-text)
(mac-ts-converted-text, mac-ts-selected-converted-text)
(mac-ts-block-fill-text, mac-ts-outline-text)
(mac-ts-selected-text, mac-ts-no-hilite): New faces.
(mac-ts-hilite-style-faces): New constant.
(mac-apple-event-map): Bind text input events.
(mac-dispatch-apple-event): Use command-execute instead of
call-interactively.
(global-map): Don't bind mac-apple-event.
(special-event-map): Bind mac-apple-event.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Sat, 03 Jun 2006 02:31:51 +0000 |
parents | e5af358ce93a |
children | a183bff9cb83 46b1096093f5 a8190f7e546e |
comparison
equal
deleted
inserted
replaced
71174:aedf192fdf04 | 71175:ed68e074ebb4 |
---|---|
82 (defvar mac-service-selection) | 82 (defvar mac-service-selection) |
83 (defvar mac-system-script-code) | 83 (defvar mac-system-script-code) |
84 (defvar mac-apple-event-map) | 84 (defvar mac-apple-event-map) |
85 (defvar mac-atsu-font-table) | 85 (defvar mac-atsu-font-table) |
86 (defvar mac-font-panel-mode) | 86 (defvar mac-font-panel-mode) |
87 (defvar mac-ts-active-input-overlay) | |
87 (defvar x-invocation-args) | 88 (defvar x-invocation-args) |
88 | 89 |
89 (defvar x-command-line-resources nil) | 90 (defvar x-command-line-resources nil) |
90 | 91 |
91 ;; Handler for switches of the form "-switch value" or "-switch". | 92 ;; Handler for switches of the form "-switch value" or "-switch". |
1568 (mapcar | 1569 (mapcar |
1569 (lambda (type-data) | 1570 (lambda (type-data) |
1570 (mac-coerce-ae-data (car type-data) (cdr type-data) type)) | 1571 (mac-coerce-ae-data (car type-data) (cdr type-data) type)) |
1571 (cdr desc))))))) | 1572 (cdr desc))))))) |
1572 | 1573 |
1574 (defun mac-ae-number (ae keyword) | |
1575 (let ((type-data (mac-ae-parameter ae keyword)) | |
1576 str) | |
1577 (if (and type-data | |
1578 (setq str (mac-coerce-ae-data (car type-data) | |
1579 (cdr type-data) "TEXT"))) | |
1580 (string-to-number str) | |
1581 nil))) | |
1582 | |
1573 (defun mac-bytes-to-integer (bytes &optional from to) | 1583 (defun mac-bytes-to-integer (bytes &optional from to) |
1574 (or from (setq from 0)) | 1584 (or from (setq from 0)) |
1575 (or to (setq to (length bytes))) | 1585 (or to (setq to (length bytes))) |
1576 (let* ((len (- to from)) | 1586 (let* ((len (- to from)) |
1577 (extended-sign-len (- (1+ (ceiling (log most-positive-fixnum 2))) | 1587 (extended-sign-len (- (1+ (ceiling (log most-positive-fixnum 2))) |
1607 ;; optional parameter keyAESearchText from the Spotlight search. | 1617 ;; optional parameter keyAESearchText from the Spotlight search. |
1608 (defun mac-ae-text-for-search (ae) | 1618 (defun mac-ae-text-for-search (ae) |
1609 (let ((utf8-text (cdr (mac-ae-parameter ae "stxt" "utf8")))) | 1619 (let ((utf8-text (cdr (mac-ae-parameter ae "stxt" "utf8")))) |
1610 (and utf8-text | 1620 (and utf8-text |
1611 (decode-coding-string utf8-text 'utf-8)))) | 1621 (decode-coding-string utf8-text 'utf-8)))) |
1622 | |
1623 (defun mac-ae-text (ae) | |
1624 (or (cdr (mac-ae-parameter ae nil "TEXT")) | |
1625 (error "No text in Apple event."))) | |
1626 | |
1627 (defun mac-ae-frame (ae &optional keyword type) | |
1628 (let ((bytes (cdr (mac-ae-parameter ae keyword type)))) | |
1629 (if (or (null bytes) (/= (length bytes) 4)) | |
1630 (error "No window reference in Apple event.") | |
1631 (let ((window-id (mac-coerce-ae-data "long" bytes "TEXT")) | |
1632 (rest (frame-list)) | |
1633 frame) | |
1634 (while (and (null frame) rest) | |
1635 (if (string= (frame-parameter (car rest) 'window-id) window-id) | |
1636 (setq frame (car rest))) | |
1637 (setq rest (cdr rest))) | |
1638 frame)))) | |
1639 | |
1640 (defun mac-ae-script-language (ae keyword) | |
1641 ;; struct WritingCode { | |
1642 ;; ScriptCode theScriptCode; | |
1643 ;; LangCode theLangCode; | |
1644 ;; }; | |
1645 (let ((bytes (cdr (mac-ae-parameter ae keyword "intl")))) | |
1646 (and bytes | |
1647 (cons (mac-bytes-to-integer bytes 0 2) | |
1648 (mac-bytes-to-integer bytes 2 4))))) | |
1649 | |
1650 (defun mac-bytes-to-text-range (bytes &optional from to) | |
1651 ;; struct TextRange { | |
1652 ;; long fStart; | |
1653 ;; long fEnd; | |
1654 ;; short fHiliteStyle; | |
1655 ;; }; | |
1656 (or from (setq from 0)) | |
1657 (or to (setq to (length bytes))) | |
1658 (and (= (- to from) (+ 4 4 2)) | |
1659 (list (mac-bytes-to-integer bytes from (+ from 4)) | |
1660 (mac-bytes-to-integer bytes (+ from 4) (+ from 8)) | |
1661 (mac-bytes-to-integer bytes (+ from 8) to)))) | |
1662 | |
1663 (defun mac-ae-text-range-array (ae keyword) | |
1664 ;; struct TextRangeArray { | |
1665 ;; short fNumOfRanges; | |
1666 ;; TextRange fRange[1]; | |
1667 ;; }; | |
1668 (let* ((bytes (cdr (mac-ae-parameter ae keyword "tray"))) | |
1669 (len (length bytes)) | |
1670 nranges result) | |
1671 (when (and bytes (>= len 2) | |
1672 (progn | |
1673 (setq nranges (mac-bytes-to-integer bytes 0 2)) | |
1674 (= len (+ 2 (* nranges 10))))) | |
1675 (setq result (make-vector nranges nil)) | |
1676 (dotimes (i nranges) | |
1677 (aset result i | |
1678 (mac-bytes-to-text-range bytes (+ (* i 10) 2) | |
1679 (+ (* i 10) 12))))) | |
1680 result)) | |
1612 | 1681 |
1613 (defun mac-ae-open-documents (event) | 1682 (defun mac-ae-open-documents (event) |
1614 "Open the documents specified by the Apple event EVENT." | 1683 "Open the documents specified by the Apple event EVENT." |
1615 (interactive "e") | 1684 (interactive "e") |
1616 (let ((ae (mac-event-ae event))) | 1685 (let ((ae (mac-event-ae event))) |
1635 (re-search-forward | 1704 (re-search-forward |
1636 (mapconcat 'regexp-quote (split-string search-text) "\\|") | 1705 (mapconcat 'regexp-quote (split-string search-text) "\\|") |
1637 nil t))))) | 1706 nil t))))) |
1638 (select-frame-set-input-focus (selected-frame))) | 1707 (select-frame-set-input-focus (selected-frame))) |
1639 | 1708 |
1640 (defun mac-ae-text (ae) | |
1641 (or (cdr (mac-ae-parameter ae nil "TEXT")) | |
1642 (error "No text in Apple event."))) | |
1643 | |
1644 (defun mac-ae-get-url (event) | 1709 (defun mac-ae-get-url (event) |
1645 "Open the URL specified by the Apple event EVENT. | 1710 "Open the URL specified by the Apple event EVENT. |
1646 Currently the `mailto' scheme is supported." | 1711 Currently the `mailto' scheme is supported." |
1647 (interactive "e") | 1712 (interactive "e") |
1648 (let* ((ae (mac-event-ae event)) | 1713 (let* ((ae (mac-event-ae event)) |
1683 (let* ((ae (mac-event-ae event)) | 1748 (let* ((ae (mac-event-ae event)) |
1684 (modifiers (cdr (mac-ae-parameter ae "kmod")))) | 1749 (modifiers (cdr (mac-ae-parameter ae "kmod")))) |
1685 (if (and modifiers (not (string= modifiers "\000\000\000\000"))) | 1750 (if (and modifiers (not (string= modifiers "\000\000\000\000"))) |
1686 ;; Globally toggle tool-bar-mode if some modifier key is pressed. | 1751 ;; Globally toggle tool-bar-mode if some modifier key is pressed. |
1687 (tool-bar-mode) | 1752 (tool-bar-mode) |
1688 (let ((window-id | 1753 (let ((frame (mac-ae-frame ae))) |
1689 (mac-coerce-ae-data "long" (cdr (mac-ae-parameter ae)) "TEXT")) | |
1690 (rest (frame-list)) | |
1691 frame) | |
1692 (while (and (null frame) rest) | |
1693 (if (string= (frame-parameter (car rest) 'window-id) window-id) | |
1694 (setq frame (car rest))) | |
1695 (setq rest (cdr rest))) | |
1696 (set-frame-parameter frame 'tool-bar-lines | 1754 (set-frame-parameter frame 'tool-bar-lines |
1697 (if (= (frame-parameter frame 'tool-bar-lines) 0) | 1755 (if (= (frame-parameter frame 'tool-bar-lines) 0) |
1698 1 0)))))) | 1756 1 0)))))) |
1699 | 1757 |
1700 ;; kEventClassWindow/kEventWindowToolbarSwitchMode | 1758 ;; kEventClassWindow/kEventWindowToolbarSwitchMode |
1720 | 1778 |
1721 (defun mac-handle-font-selection (event) | 1779 (defun mac-handle-font-selection (event) |
1722 "Change default face attributes according to font selection EVENT." | 1780 "Change default face attributes according to font selection EVENT." |
1723 (interactive "e") | 1781 (interactive "e") |
1724 (let* ((ae (mac-event-ae event)) | 1782 (let* ((ae (mac-event-ae event)) |
1725 (fm-font-size (cdr (mac-ae-parameter ae "fmsz"))) | 1783 (fm-font-size (mac-ae-number ae "fmsz")) |
1726 (atsu-font-id (cdr (mac-ae-parameter ae "auid"))) | 1784 (atsu-font-id (cdr (mac-ae-parameter ae "auid"))) |
1727 (attribute-values (gethash atsu-font-id mac-atsu-font-table))) | 1785 (attribute-values (gethash atsu-font-id mac-atsu-font-table))) |
1728 (if fm-font-size | 1786 (if fm-font-size |
1729 (setq attribute-values | 1787 (setq attribute-values |
1730 `(:height ,(* 10 (mac-bytes-to-integer fm-font-size)) | 1788 `(:height ,(* 10 fm-font-size) ,@attribute-values))) |
1731 ,@attribute-values))) | |
1732 (apply 'set-face-attribute 'default (selected-frame) attribute-values))) | 1789 (apply 'set-face-attribute 'default (selected-frame) attribute-values))) |
1733 | 1790 |
1734 ;; kEventClassFont/kEventFontPanelClosed | 1791 ;; kEventClassFont/kEventFontPanelClosed |
1735 (define-key mac-apple-event-map [font panel-closed] | 1792 (define-key mac-apple-event-map [font panel-closed] |
1736 'mac-handle-font-panel-closed) | 1793 'mac-handle-font-panel-closed) |
1742 "Font Panel" | 1799 "Font Panel" |
1743 "Show the font panel as a floating dialog") | 1800 "Show the font panel as a floating dialog") |
1744 'showhide-speedbar) | 1801 'showhide-speedbar) |
1745 | 1802 |
1746 ) ;; (fboundp 'mac-set-font-panel-visibility) | 1803 ) ;; (fboundp 'mac-set-font-panel-visibility) |
1804 | |
1805 ;;; Text Services | |
1806 (defvar mac-ts-active-input-buf "" | |
1807 "Byte sequence of the current Mac TSM active input area.") | |
1808 (defvar mac-ts-update-active-input-area-seqno 0 | |
1809 "Number of processed update-active-input-area events.") | |
1810 (setq mac-ts-active-input-overlay (make-overlay 0 0)) | |
1811 | |
1812 (defface mac-ts-caret-position | |
1813 '((t :inverse-video t)) | |
1814 "Face for caret position in Mac TSM active input area. | |
1815 This is used only when the active input area is displayed in the | |
1816 echo area." | |
1817 :group 'mac) | |
1818 | |
1819 (defface mac-ts-raw-text | |
1820 '((t :underline t)) | |
1821 "Face for raw text in Mac TSM active input area." | |
1822 :group 'mac) | |
1823 | |
1824 (defface mac-ts-selected-raw-text | |
1825 '((t :underline t)) | |
1826 "Face for selected raw text in Mac TSM active input area." | |
1827 :group 'mac) | |
1828 | |
1829 (defface mac-ts-converted-text | |
1830 '((((background dark)) :underline "gray20") | |
1831 (t :underline "gray80")) | |
1832 "Face for converted text in Mac TSM active input area." | |
1833 :group 'mac) | |
1834 | |
1835 (defface mac-ts-selected-converted-text | |
1836 '((t :underline t)) | |
1837 "Face for selected converted text in Mac TSM active input area." | |
1838 :group 'mac) | |
1839 | |
1840 (defface mac-ts-block-fill-text | |
1841 '((t :underline t)) | |
1842 "Face for block fill text in Mac TSM active input area." | |
1843 :group 'mac) | |
1844 | |
1845 (defface mac-ts-outline-text | |
1846 '((t :underline t)) | |
1847 "Face for outline text in Mac TSM active input area." | |
1848 :group 'mac) | |
1849 | |
1850 (defface mac-ts-selected-text | |
1851 '((t :underline t)) | |
1852 "Face for selected text in Mac TSM active input area." | |
1853 :group 'mac) | |
1854 | |
1855 (defface mac-ts-no-hilite | |
1856 '((t :inherit default)) | |
1857 "Face for no hilite in Mac TSM active input area." | |
1858 :group 'mac) | |
1859 | |
1860 (defconst mac-ts-hilite-style-faces | |
1861 '((2 . mac-ts-raw-text) ; kTSMHiliteRawText | |
1862 (3 . mac-ts-selected-raw-text) ; kTSMHiliteSelectedRawText | |
1863 (4 . mac-ts-converted-text) ; kTSMHiliteConvertedText | |
1864 (5 . mac-ts-selected-converted-text) ; kTSMHiliteSelectedConvertedText | |
1865 (6 . mac-ts-block-fill-text) ; kTSMHiliteBlockFillText | |
1866 (7 . mac-ts-outline-text) ; kTSMHiliteOutlineText | |
1867 (8 . mac-ts-selected-text) ; kTSMHiliteSelectedText | |
1868 (9 . mac-ts-no-hilite)) ; kTSMHiliteNoHilite | |
1869 "Alist of Mac TSM hilite style vs Emacs face.") | |
1870 | |
1871 (defun mac-ts-update-active-input-buf (text fix-len hilite-rng update-rng) | |
1872 (let ((buf-len (length mac-ts-active-input-buf)) | |
1873 confirmed) | |
1874 (if (or (null update-rng) | |
1875 (/= (% (length update-rng) 2) 0)) | |
1876 ;; The parameter is missing (or in a bad format). The | |
1877 ;; existing inline input session is completely replaced with | |
1878 ;; the new text. | |
1879 (setq mac-ts-active-input-buf text) | |
1880 ;; Otherwise, the current subtext specified by the (2*j)-th | |
1881 ;; range is replaced with the new subtext specified by the | |
1882 ;; (2*j+1)-th range. | |
1883 (let ((tail buf-len) | |
1884 (i (length update-rng)) | |
1885 segments rng) | |
1886 (while (> i 0) | |
1887 (setq i (- i 2)) | |
1888 (setq rng (aref update-rng i)) | |
1889 (if (and (<= 0 (cadr rng)) (< (cadr rng) tail) | |
1890 (<= tail buf-len)) | |
1891 (setq segments | |
1892 (cons (substring mac-ts-active-input-buf (cadr rng) tail) | |
1893 segments))) | |
1894 (setq tail (car rng)) | |
1895 (setq rng (aref update-rng (1+ i))) | |
1896 (if (and (<= 0 (car rng)) (< (car rng) (cadr rng)) | |
1897 (<= (cadr rng) (length text))) | |
1898 (setq segments | |
1899 (cons (substring text (car rng) (cadr rng)) | |
1900 segments)))) | |
1901 (if (and (< 0 tail) (<= tail buf-len)) | |
1902 (setq segments | |
1903 (cons (substring mac-ts-active-input-buf 0 tail) | |
1904 segments))) | |
1905 (setq mac-ts-active-input-buf (apply 'concat segments)))) | |
1906 (setq buf-len (length mac-ts-active-input-buf)) | |
1907 ;; Confirm (a part of) inline input session. | |
1908 (cond ((< fix-len 0) | |
1909 ;; Entire inline session is being confirmed. | |
1910 (setq confirmed mac-ts-active-input-buf) | |
1911 (setq mac-ts-active-input-buf "")) | |
1912 ((= fix-len 0) | |
1913 ;; None of the text is being confirmed (yet). | |
1914 (setq confirmed "")) | |
1915 (t | |
1916 (if (> fix-len buf-len) | |
1917 (setq fix-len buf-len)) | |
1918 (setq confirmed (substring mac-ts-active-input-buf 0 fix-len)) | |
1919 (setq mac-ts-active-input-buf | |
1920 (substring mac-ts-active-input-buf fix-len)))) | |
1921 (setq buf-len (length mac-ts-active-input-buf)) | |
1922 ;; Update highlighting and the caret position in the new inline | |
1923 ;; input session. | |
1924 (remove-text-properties 0 buf-len '(cursor nil) mac-ts-active-input-buf) | |
1925 (mapc (lambda (rng) | |
1926 (cond ((and (= (nth 2 rng) 1) ; kTSMHiliteCaretPosition | |
1927 (<= 0 (car rng)) (< (car rng) buf-len)) | |
1928 (put-text-property (car rng) buf-len | |
1929 'cursor t mac-ts-active-input-buf)) | |
1930 ((and (<= 0 (car rng)) (< (car rng) (cadr rng)) | |
1931 (<= (cadr rng) buf-len)) | |
1932 (put-text-property (car rng) (cadr rng) 'face | |
1933 (cdr (assq (nth 2 rng) | |
1934 mac-ts-hilite-style-faces)) | |
1935 mac-ts-active-input-buf)))) | |
1936 hilite-rng) | |
1937 confirmed)) | |
1938 | |
1939 (defun mac-split-string-by-property-change (string) | |
1940 (let ((tail (length string)) | |
1941 head result) | |
1942 (unless (= tail 0) | |
1943 (while (setq head (previous-property-change tail string) | |
1944 result (cons (substring string (or head 0) tail) result) | |
1945 tail head))) | |
1946 result)) | |
1947 | |
1948 (defun mac-replace-untranslated-utf-8-chars (string &optional to-string) | |
1949 (or to-string (setq to-string "$,3u=(B")) | |
1950 (mapconcat | |
1951 (lambda (str) | |
1952 (if (get-text-property 0 'untranslated-utf-8 str) to-string str)) | |
1953 (mac-split-string-by-property-change string) | |
1954 "")) | |
1955 | |
1956 (defun mac-ts-update-active-input-area (event) | |
1957 "Update Mac TSM active input area according to EVENT. | |
1958 The confirmed text is converted to Emacs input events and pushed | |
1959 into `unread-command-events'. The unconfirmed text is displayed | |
1960 either in the current buffer or in the echo area." | |
1961 (interactive "e") | |
1962 (let* ((ae (mac-event-ae event)) | |
1963 (text (or (cdr (mac-ae-parameter ae "tstx" "utxt")) "")) | |
1964 (script-language (mac-ae-script-language ae "tssl")) | |
1965 (coding (or (cdr (assq (car script-language) | |
1966 mac-script-code-coding-systems)) | |
1967 'mac-roman)) | |
1968 (fix-len (mac-bytes-to-integer | |
1969 (cdr (mac-ae-parameter ae "tsfx" "long")))) | |
1970 ;; Optional parameters | |
1971 (hilite-rng (mac-ae-text-range-array ae "tshi")) | |
1972 (update-rng (mac-ae-text-range-array ae "tsup")) | |
1973 ;;(pin-rng (mac-bytes-to-text-range (cdr (mac-ae-parameter ae "tspn" "txrn")))) | |
1974 ;;(clause-offsets (cdr (mac-ae-parameter ae "tscl" "ofay"))) | |
1975 (seqno (mac-ae-number ae "tsSn")) | |
1976 confirmed) | |
1977 (unless (= seqno mac-ts-update-active-input-area-seqno) | |
1978 ;; Reset internal states if sequence number is out of sync. | |
1979 (setq mac-ts-active-input-buf "")) | |
1980 (setq confirmed | |
1981 (mac-ts-update-active-input-buf text fix-len hilite-rng update-rng)) | |
1982 (let ((use-echo-area | |
1983 (or isearch-mode | |
1984 (and cursor-in-echo-area (current-message)) | |
1985 ;; Overlay strings are not shown in some cases. | |
1986 (get-char-property (point) 'display) | |
1987 (get-char-property (point) 'invisible) | |
1988 (get-char-property (point) 'composition))) | |
1989 active-input-string caret-seen) | |
1990 ;; Decode the active input area text with inheriting faces and | |
1991 ;; the caret position. | |
1992 (setq active-input-string | |
1993 (mapconcat | |
1994 (lambda (str) | |
1995 (let ((decoded (mac-utxt-to-string str coding))) | |
1996 (put-text-property 0 (length decoded) 'face | |
1997 (get-text-property 0 'face str) decoded) | |
1998 (when (and (not caret-seen) | |
1999 (get-text-property 0 'cursor str)) | |
2000 (setq caret-seen t) | |
2001 (if use-echo-area | |
2002 (put-text-property 0 1 'face 'mac-ts-caret-position | |
2003 decoded) | |
2004 (put-text-property 0 1 'cursor t decoded))) | |
2005 decoded)) | |
2006 (mac-split-string-by-property-change mac-ts-active-input-buf) | |
2007 "")) | |
2008 (put-text-property 0 (length active-input-string) | |
2009 'mac-ts-active-input-string t active-input-string) | |
2010 (if use-echo-area | |
2011 (let (msg message-log-max) | |
2012 (if (and (current-message) | |
2013 ;; Don't get confused by previously displayed | |
2014 ;; `active-input-string'. | |
2015 (null (get-text-property 0 'mac-ts-active-input-string | |
2016 (current-message)))) | |
2017 (setq msg (propertize (current-message) 'display | |
2018 (concat (current-message) | |
2019 active-input-string))) | |
2020 (setq msg active-input-string)) | |
2021 (message "%s" msg) | |
2022 (overlay-put mac-ts-active-input-overlay 'before-string nil)) | |
2023 (move-overlay mac-ts-active-input-overlay | |
2024 (point) (point) (current-buffer)) | |
2025 (overlay-put mac-ts-active-input-overlay 'before-string | |
2026 active-input-string)) | |
2027 ;; Unread confirmed characters and insert them in a keyboard | |
2028 ;; macro being defined. | |
2029 (apply 'isearch-unread | |
2030 (append (mac-replace-untranslated-utf-8-chars | |
2031 (mac-utxt-to-string confirmed coding)) '()))) | |
2032 ;; The event is successfully processed. Sync the sequence number. | |
2033 (setq mac-ts-update-active-input-area-seqno (1+ seqno)))) | |
2034 | |
2035 (defun mac-ts-unicode-for-key-event (event) | |
2036 "Convert Unicode key EVENT to Emacs key events and unread them." | |
2037 (interactive "e") | |
2038 (let* ((ae (mac-event-ae event)) | |
2039 (text (cdr (mac-ae-parameter ae "tstx" "utxt"))) | |
2040 (script-language (mac-ae-script-language ae "tssl")) | |
2041 (coding (or (cdr (assq (car script-language) | |
2042 mac-script-code-coding-systems)) | |
2043 'mac-roman))) | |
2044 ;; Unread characters and insert them in a keyboard macro being | |
2045 ;; defined. | |
2046 (apply 'isearch-unread | |
2047 (append (mac-replace-untranslated-utf-8-chars | |
2048 (mac-utxt-to-string text coding)) '())))) | |
2049 | |
2050 ;; kEventClassTextInput/kEventTextInputUpdateActiveInputArea | |
2051 (define-key mac-apple-event-map [text-input update-active-input-area] | |
2052 'mac-ts-update-active-input-area) | |
2053 ;; kEventClassTextInput/kEventTextInputUnicodeForKeyEvent | |
2054 (define-key mac-apple-event-map [text-input unicode-for-key-event] | |
2055 'mac-ts-unicode-for-key-event) | |
1747 | 2056 |
1748 ;;; Services | 2057 ;;; Services |
1749 (defun mac-service-open-file () | 2058 (defun mac-service-open-file () |
1750 "Open the file specified by the selection value for Services." | 2059 "Open the file specified by the selection value for Services." |
1751 (interactive) | 2060 (interactive) |
1809 (setq binding (lookup-key binding (vector service-message)))) | 2118 (setq binding (lookup-key binding (vector service-message)))) |
1810 ;; Replace (cadr event) with a dummy position so that event-start | 2119 ;; Replace (cadr event) with a dummy position so that event-start |
1811 ;; returns it. | 2120 ;; returns it. |
1812 (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0)) | 2121 (setcar (cdr event) (list (selected-window) (point) '(0 . 0) 0)) |
1813 (if (null (mac-ae-parameter ae 'emacs-suspension-id)) | 2122 (if (null (mac-ae-parameter ae 'emacs-suspension-id)) |
1814 (call-interactively binding) | 2123 (command-execute binding nil (vector event) t) |
1815 (condition-case err | 2124 (condition-case err |
1816 (progn | 2125 (progn |
1817 (call-interactively binding) | 2126 (command-execute binding nil (vector event) t) |
1818 (mac-resume-apple-event ae)) | 2127 (mac-resume-apple-event ae)) |
1819 (error | 2128 (error |
1820 (mac-ae-set-reply-parameter ae "errs" | 2129 (mac-ae-set-reply-parameter ae "errs" |
1821 (cons "TEXT" (error-message-string err))) | 2130 (cons "TEXT" (error-message-string err))) |
1822 (mac-resume-apple-event ae -10000)))))) ; errAEEventFailed | 2131 (mac-resume-apple-event ae -10000)))))) ; errAEEventFailed |
1823 | 2132 |
1824 (global-set-key [mac-apple-event] 'mac-dispatch-apple-event) | 2133 (define-key special-event-map [mac-apple-event] 'mac-dispatch-apple-event) |
1825 | 2134 |
1826 ;; Processing of Apple events are deferred at the startup time. For | 2135 ;; Processing of Apple events are deferred at the startup time. For |
1827 ;; example, files dropped onto the Emacs application icon can only be | 2136 ;; example, files dropped onto the Emacs application icon can only be |
1828 ;; processed when the initial frame has been created: this is where | 2137 ;; processed when the initial frame has been created: this is where |
1829 ;; the files should be opened. | 2138 ;; the files should be opened. |