1 ;;; mac-win.el --- support for "Macintosh windows"
3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
5 ;; Author: Andrew Choi <akochoi@i-cable.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 ;; ---------------------------------------------------------------------------
29 ;; We want to delay setting frame parameters until the faces are setup
31 ;; Mac can't handle ~ prefix in file names
32 ;(setq auto-save-list-file-prefix ".saves-")
34 (setq frame-creation-function
'x-create-frame-with-faces
)
37 ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
39 ;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
42 [vertical-scroll-bar down-mouse-1
]
43 'mac-handle-scroll-bar-event
)
45 (global-unset-key [vertical-scroll-bar drag-mouse-1
])
46 (global-unset-key [vertical-scroll-bar mouse-1
])
48 (defun mac-handle-scroll-bar-event (event)
49 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
51 (let* ((position (event-start event
))
52 (window (nth 0 position
))
53 (bar-part (nth 4 position
)))
54 (select-window window
)
57 (goto-char (window-start window
))
58 (mac-scroll-down-line))
59 ((eq bar-part
'above-handle
)
61 ((eq bar-part
'handle
)
62 (scroll-bar-drag event
))
63 ((eq bar-part
'below-handle
)
66 (goto-char (window-start window
))
67 (mac-scroll-up-line)))))
69 (defun mac-scroll-down ()
71 (while (not (eq (car-safe (read-event)) 'mouse-1
)) nil
)
74 (defun mac-scroll-down-line ()
76 (while (not (eq (car-safe (read-event)) 'mouse-1
)) nil
)
79 (defun mac-scroll-up ()
81 (while (not (eq (car-safe (read-event)) 'mouse-1
)) nil
)
84 (defun mac-scroll-up-line ()
86 (while (not (eq (car-safe (read-event)) 'mouse-1
)) nil
)
89 (defun xw-defined-colors (&optional frame
)
90 "Internal function called by `defined-colors', which see."
91 (or frame
(setq frame
(selected-frame)))
92 (let ((all-colors x-colors
)
96 (setq this-color
(car all-colors
)
97 all-colors
(cdr all-colors
))
98 (and (color-supported-p this-color frame t
)
99 (setq defined-colors
(cons this-color defined-colors
))))
102 ;; Don't have this yet.
103 (fset 'x-get-resource
'ignore
)
105 ;; This variable specifies the Unix program to call (as a process) to
106 ;; deteremine the amount of free space on a file system (defaults to
107 ;; df). If it is not set to nil, ls-lisp will not work correctly
108 ;; unless an external application df is implemented on the Mac.
111 (setq dired-free-space-program nil
)
113 ;; Set this so that Emacs calls subprocesses with "sh" as shell to
114 ;; expand filenames Note no subprocess for the shell is actually
115 ;; started (see run_mac_command in sysdep.c).
116 (setq shell-file-name
"sh")
118 ;; X Window emulation in macterm.c is not complete enough to start a
119 ;; frame without a minibuffer properly. Call this to tell ediff
120 ;; library to use a single frame.
121 (ediff-toggle-multiframe)
123 ;; Setup to use the Mac clipboard. The functions mac-cut-function and
124 ;; mac-paste-function are defined in mac.c.
125 (set-selection-coding-system 'compound-text-mac
)
127 (setq interprogram-cut-function
130 (encode-coding-string str selection-coding-system t
) push
)))
132 (setq interprogram-paste-function
134 (decode-coding-string
135 (mac-paste-function) selection-coding-system t
)))
137 (defun mac-drag-n-drop (event)
138 "Edit the files listed in the drag-n-drop event.\n\
139 Switch to a buffer editing the last file dropped."
142 ;; Make sure the drop target has positive co-ords
143 ;; before setting the selected frame - otherwise it
144 ;; won't work. <skx@tardis.ed.ac.uk>
145 (let* ((window (posn-window (event-start event
)))
146 (coords (posn-x-y (event-start event
)))
149 (if (and (> x
0) (> y
0))
150 (set-frame-selected-window nil window
))
151 (mapcar 'find-file
(car (cdr (cdr event
)))))
155 (global-set-key [drag-n-drop
] 'mac-drag-n-drop
)
157 ;; By checking whether the variable mac-ready-for-drag-n-drop has been
158 ;; defined, the event loop in macterm.c can be informed that it can
159 ;; now receive Finder drag and drop events. Files dropped onto the
160 ;; Emacs application icon can only be processed when the initial frame
161 ;; has been created: this is where the files should be opened.
162 (add-hook 'after-init-hook
164 (defvar mac-ready-for-drag-n-drop t
)))
166 ; Define constant values to be set to mac-keyboard-text-encoding
167 (defconst kTextEncodingMacRoman
0)
168 (defconst kTextEncodingISOLatin1
513 "0x201")
169 (defconst kTextEncodingISOLatin2
514 "0x202")
172 (define-ccl-program ccl-encode-mac-roman-font
174 (if (r0 != ,(charset-id 'ascii
))
175 (if (r0 == ,(charset-id 'latin-iso8859-1
))
176 (translate-character mac-roman-encoder r0 r1
)
179 (translate-character mac-roman-encoder r0 r1
)))))
180 "CCL program for Mac Roman font")
182 (setq font-ccl-encoder-alist
183 (cons '("mac-roman" . ccl-encode-mac-roman-font
)
184 font-ccl-encoder-alist
))
186 ;; Create a fontset that uses mac-roman font. With this fontset,
187 ;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
188 ;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
190 (if (fboundp 'new-fontset
)
192 (create-fontset-from-fontset-spec
193 "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac,
194 ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
195 (let ((monaco-font '("monaco" .
"mac-roman")))
199 (or (generic-char-p key
)
200 (memq (char-charset key
)
201 '(ascii eight-bit-control eight-bit-graphic
))
202 (set-fontset-font "fontset-mac" key monaco-font
))))
203 (get 'mac-roman-encoder
'translation-table
)))))
205 ;; To display filenames in Chinese or Japanese, replace mac-roman with
207 (setq file-name-coding-system
'mac-roman
)
209 ;; (prefer-coding-system 'mac-roman)
215 (defvar x-colors
'("LightGreen"
814 "LightGoldenrodYellow"
815 "light goldenrod yellow"
832 "medium spring green"
967 "The list of X colors from the `rgb.txt' file.
968 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
970 ;;; mac-win.el ends here