1 ;;; mac-win.el --- support for "Macintosh windows"
3 ;; Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
5 ;; Author: Andrew Choi <akochoi@mac.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])
50 (defun mac-handle-scroll-bar-event (event)
51 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
53 (let* ((position (event-start event))
54 (window (nth 0 position))
55 (bar-part (nth 4 position)))
56 (select-window window)
59 (goto-char (window-start window))
60 (mac-scroll-down-line))
61 ((eq bar-part 'above-handle)
63 ((eq bar-part 'handle)
64 (scroll-bar-drag event))
65 ((eq bar-part 'below-handle)
68 (goto-char (window-start window))
69 (mac-scroll-up-line)))))
71 (defun mac-scroll-ignore-events ()
72 ;; Ignore confusing non-mouse events
73 (while (not (memq (car-safe (read-event))
74 '(mouse-1 double-mouse-1 triple-mouse-1))) nil))
76 (defun mac-scroll-down ()
78 (mac-scroll-ignore-events)
81 (defun mac-scroll-down-line ()
83 (mac-scroll-ignore-events)
86 (defun mac-scroll-up ()
88 (mac-scroll-ignore-events)
91 (defun mac-scroll-up-line ()
93 (mac-scroll-ignore-events)
96 (defun xw-defined-colors (&optional frame)
97 "Internal function called by `defined-colors', which see."
98 (or frame (setq frame (selected-frame)))
99 (let ((all-colors x-colors)
101 (defined-colors nil))
103 (setq this-color (car all-colors)
104 all-colors (cdr all-colors))
105 (and (color-supported-p this-color frame t)
106 (setq defined-colors (cons this-color defined-colors))))
109 ;; Don't have this yet.
110 (fset 'x-get-resource 'ignore)
112 (unless (eq system-type 'darwin)
113 ;; This variable specifies the Unix program to call (as a process) to
114 ;; deteremine the amount of free space on a file system (defaults to
115 ;; df). If it is not set to nil, ls-lisp will not work correctly
116 ;; unless an external application df is implemented on the Mac.
117 (setq directory-free-space-program nil)
119 ;; Set this so that Emacs calls subprocesses with "sh" as shell to
120 ;; expand filenames Note no subprocess for the shell is actually
121 ;; started (see run_mac_command in sysdep.c).
122 (setq shell-file-name "sh"))
124 ;; X Window emulation in macterm.c is not complete enough to start a
125 ;; frame without a minibuffer properly. Call this to tell ediff
126 ;; library to use a single frame.
127 ; (ediff-toggle-multiframe)
129 ;; Setup to use the Mac clipboard. The functions mac-cut-function and
130 ;; mac-paste-function are defined in mac.c.
131 (set-selection-coding-system 'compound-text-mac)
133 (setq interprogram-cut-function
136 (encode-coding-string str selection-coding-system t) push)))
138 (setq interprogram-paste-function
140 (let ((clipboard (mac-paste-function)))
142 (decode-coding-string clipboard selection-coding-system t)))))
144 ;; Don't show the frame name; that's redundant.
145 (setq-default mode-line-frame-identification " ")
147 (defun mac-drag-n-drop (event)
148 "Edit the files listed in the drag-n-drop event.\n\
149 Switch to a buffer editing the last file dropped."
152 ;; Make sure the drop target has positive co-ords
153 ;; before setting the selected frame - otherwise it
154 ;; won't work. <skx@tardis.ed.ac.uk>
155 (let* ((window (posn-window (event-start event)))
156 (coords (posn-x-y (event-start event)))
159 (if (and (> x 0) (> y 0))
160 (set-frame-selected-window nil window))
164 (decode-coding-string
166 (or file-name-coding-system
167 default-file-name-coding-system))))
168 (car (cdr (cdr event)))))
172 (global-set-key [drag-n-drop] 'mac-drag-n-drop)
174 ;; By checking whether the variable mac-ready-for-drag-n-drop has been
175 ;; defined, the event loop in macterm.c can be informed that it can
176 ;; now receive Finder drag and drop events. Files dropped onto the
177 ;; Emacs application icon can only be processed when the initial frame
178 ;; has been created: this is where the files should be opened.
179 (add-hook 'after-init-hook
181 (defvar mac-ready-for-drag-n-drop t)))
183 ; Define constant values to be set to mac-keyboard-text-encoding
184 (defconst kTextEncodingMacRoman 0)
185 (defconst kTextEncodingISOLatin1 513 "0x201")
186 (defconst kTextEncodingISOLatin2 514 "0x202")
189 (define-ccl-program ccl-encode-mac-roman-font
191 (if (r0 != ,(charset-id 'ascii))
193 (translate-character mac-roman-encoder r0 r1)
196 (translate-character mac-roman-encoder r0 r1)))))
197 "CCL program for Mac Roman font")
200 ((encoding-vector (make-vector 256 nil))
202 (vec ;; mac-centraleuropean (128..255) -> UCS mapping
203 [ #x00C4 ;; 128:LATIN CAPITAL LETTER A WITH DIAERESIS
204 #x0100 ;; 129:LATIN CAPITAL LETTER A WITH MACRON
205 #x0101 ;; 130:LATIN SMALL LETTER A WITH MACRON
206 #x00C9 ;; 131:LATIN CAPITAL LETTER E WITH ACUTE
207 #x0104 ;; 132:LATIN CAPITAL LETTER A WITH OGONEK
208 #x00D6 ;; 133:LATIN CAPITAL LETTER O WITH DIAERESIS
209 #x00DC ;; 134:LATIN CAPITAL LETTER U WITH DIAERESIS
210 #x00E1 ;; 135:LATIN SMALL LETTER A WITH ACUTE
211 #x0105 ;; 136:LATIN SMALL LETTER A WITH OGONEK
212 #x010C ;; 137:LATIN CAPITAL LETTER C WITH CARON
213 #x00E4 ;; 138:LATIN SMALL LETTER A WITH DIAERESIS
214 #x010D ;; 139:LATIN SMALL LETTER C WITH CARON
215 #x0106 ;; 140:LATIN CAPITAL LETTER C WITH ACUTE
216 #x0107 ;; 141:LATIN SMALL LETTER C WITH ACUTE
217 #x00E9 ;; 142:LATIN SMALL LETTER E WITH ACUTE
218 #x0179 ;; 143:LATIN CAPITAL LETTER Z WITH ACUTE
219 #x017A ;; 144:LATIN SMALL LETTER Z WITH ACUTE
220 #x010E ;; 145:LATIN CAPITAL LETTER D WITH CARON
221 #x00ED ;; 146:LATIN SMALL LETTER I WITH ACUTE
222 #x010F ;; 147:LATIN SMALL LETTER D WITH CARON
223 #x0112 ;; 148:LATIN CAPITAL LETTER E WITH MACRON
224 #x0113 ;; 149:LATIN SMALL LETTER E WITH MACRON
225 #x0116 ;; 150:LATIN CAPITAL LETTER E WITH DOT ABOVE
226 #x00F3 ;; 151:LATIN SMALL LETTER O WITH ACUTE
227 #x0117 ;; 152:LATIN SMALL LETTER E WITH DOT ABOVE
228 #x00F4 ;; 153:LATIN SMALL LETTER O WITH CIRCUMFLEX
229 #x00F6 ;; 154:LATIN SMALL LETTER O WITH DIAERESIS
230 #x00F5 ;; 155:LATIN SMALL LETTER O WITH TILDE
231 #x00FA ;; 156:LATIN SMALL LETTER U WITH ACUTE
232 #x011A ;; 157:LATIN CAPITAL LETTER E WITH CARON
233 #x011B ;; 158:LATIN SMALL LETTER E WITH CARON
234 #x00FC ;; 159:LATIN SMALL LETTER U WITH DIAERESIS
236 #x00B0 ;; 161:DEGREE SIGN
237 #x0118 ;; 162:LATIN CAPITAL LETTER E WITH OGONEK
238 #x00A3 ;; 163:POUND SIGN
239 #x00A7 ;; 164:SECTION SIGN
241 #x00B6 ;; 166:PILCROW SIGN
242 #x00DF ;; 167:LATIN SMALL LETTER SHARP S
243 #x00AE ;; 168:REGISTERED SIGN
244 #x00A9 ;; 169:COPYRIGHT SIGN
245 #x2122 ;; 170:TRADE MARK SIGN
246 #x0119 ;; 171:LATIN SMALL LETTER E WITH OGONEK
247 #x00A8 ;; 172:DIAERESIS
248 #x2260 ;; 173:NOT EQUAL TO
249 #x0123 ;; 174:LATIN SMALL LETTER G WITH CEDILLA
250 #x012E ;; 175:LATIN CAPITAL LETTER I WITH OGONEK
251 #x012F ;; 176:LATIN SMALL LETTER I WITH OGONEK
252 #x012A ;; 177:LATIN CAPITAL LETTER I WITH MACRON
253 #x2264 ;; 178:LESS-THAN OR EQUAL TO
254 #x2265 ;; 179:GREATER-THAN OR EQUAL TO
255 #x012B ;; 180:LATIN SMALL LETTER I WITH MACRON
256 #x0136 ;; 181:LATIN CAPITAL LETTER K WITH CEDILLA
257 #x2202 ;; 182:PARTIAL DIFFERENTIAL
258 #x2211 ;; 183:N-ARY SUMMATION
259 #x0142 ;; 184:LATIN SMALL LETTER L WITH STROKE
260 #x013B ;; 185:LATIN CAPITAL LETTER L WITH CEDILLA
261 #x013C ;; 186:LATIN SMALL LETTER L WITH CEDILLA
262 #x013D ;; 187:LATIN CAPITAL LETTER L WITH CARON
263 #x013E ;; 188:LATIN SMALL LETTER L WITH CARON
264 #x0139 ;; 189:LATIN CAPITAL LETTER L WITH ACUTE
265 #x013A ;; 190:LATIN SMALL LETTER L WITH ACUTE
266 #x0145 ;; 191:LATIN CAPITAL LETTER N WITH CEDILLA
267 #x0146 ;; 192:LATIN SMALL LETTER N WITH CEDILLA
268 #x0143 ;; 193:LATIN CAPITAL LETTER N WITH ACUTE
269 #x00AC ;; 194:NOT SIGN
270 #x221A ;; 195:SQUARE ROOT
271 #x0144 ;; 196:LATIN SMALL LETTER N WITH ACUTE
272 #x0147 ;; 197:LATIN CAPITAL LETTER N WITH CARON
273 #x2206 ;; 198:INCREMENT
274 #x00AB ;; 199:LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
275 #x00BB ;; 200:RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
276 #x2026 ;; 201:HORIZONTAL ELLIPSIS
277 #x00A0 ;; 202:NO-BREAK SPACE
278 #x0148 ;; 203:LATIN SMALL LETTER N WITH CARON
279 #x0150 ;; 204:LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
280 #x00D5 ;; 205:LATIN CAPITAL LETTER O WITH TILDE
281 #x0151 ;; 206:LATIN SMALL LETTER O WITH DOUBLE ACUTE
282 #x014C ;; 207:LATIN CAPITAL LETTER O WITH MACRON
283 #x2013 ;; 208:EN DASH
284 #x2014 ;; 209:EM DASH
285 #x201C ;; 210:LEFT DOUBLE QUOTATION MARK
286 #x201D ;; 211:RIGHT DOUBLE QUOTATION MARK
287 #x2018 ;; 212:LEFT SINGLE QUOTATION MARK
288 #x2019 ;; 213:RIGHT SINGLE QUOTATION MARK
289 #x00F7 ;; 214:DIVISION SIGN
290 #x25CA ;; 215:LOZENGE
291 #x014D ;; 216:LATIN SMALL LETTER O WITH MACRON
292 #x0154 ;; 217:LATIN CAPITAL LETTER R WITH ACUTE
293 #x0155 ;; 218:LATIN SMALL LETTER R WITH ACUTE
294 #x0158 ;; 219:LATIN CAPITAL LETTER R WITH CARON
295 #x2039 ;; 220:SINGLE LEFT-POINTING ANGLE QUOTATION MARK
296 #x203A ;; 221:SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
297 #x0159 ;; 222:LATIN SMALL LETTER R WITH CARON
298 #x0156 ;; 223:LATIN CAPITAL LETTER R WITH CEDILLA
299 #x0157 ;; 224:LATIN SMALL LETTER R WITH CEDILLA
300 #x0160 ;; 225:LATIN CAPITAL LETTER S WITH CARON
301 #x201A ;; 226:SINGLE LOW-9 QUOTATION MARK
302 #x201E ;; 227:DOUBLE LOW-9 QUOTATION MARK
303 #x0161 ;; 228:LATIN SMALL LETTER S WITH CARON
304 #x015A ;; 229:LATIN CAPITAL LETTER S WITH ACUTE
305 #x015B ;; 230:LATIN SMALL LETTER S WITH ACUTE
306 #x00C1 ;; 231:LATIN CAPITAL LETTER A WITH ACUTE
307 #x0164 ;; 232:LATIN CAPITAL LETTER T WITH CARON
308 #x0165 ;; 233:LATIN SMALL LETTER T WITH CARON
309 #x00CD ;; 234:LATIN CAPITAL LETTER I WITH ACUTE
310 #x017D ;; 235:LATIN CAPITAL LETTER Z WITH CARON
311 #x017E ;; 236:LATIN SMALL LETTER Z WITH CARON
312 #x016A ;; 237:LATIN CAPITAL LETTER U WITH MACRON
313 #x00D3 ;; 238:LATIN CAPITAL LETTER O WITH ACUTE
314 #x00D4 ;; 239:LATIN CAPITAL LETTER O WITH CIRCUMFLEX
315 #x016B ;; 240:LATIN SMALL LETTER U WITH MACRON
316 #x016E ;; 241:LATIN CAPITAL LETTER U WITH RING ABOVE
317 #x00DA ;; 242:LATIN CAPITAL LETTER U WITH ACUTE
318 #x016F ;; 243:LATIN SMALL LETTER U WITH RING ABOVE
319 #x0170 ;; 244:LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
320 #x0171 ;; 245:LATIN SMALL LETTER U WITH DOUBLE ACUTE
321 #x0172 ;; 246:LATIN CAPITAL LETTER U WITH OGONEK
322 #x0173 ;; 247:LATIN SMALL LETTER U WITH OGONEK
323 #x00DD ;; 248:LATIN CAPITAL LETTER Y WITH ACUTE
324 #x00FD ;; 249:LATIN SMALL LETTER Y WITH ACUTE
325 #x0137 ;; 250:LATIN SMALL LETTER K WITH CEDILLA
326 #x017B ;; 251:LATIN CAPITAL LETTER Z WITH DOT ABOVE
327 #x0141 ;; 252:LATIN CAPITAL LETTER L WITH STROKE
328 #x017C ;; 253:LATIN SMALL LETTER Z WITH DOT ABOVE
329 #x0122 ;; 254:LATIN CAPITAL LETTER G WITH CEDILLA
334 (aset encoding-vector i i)
337 (aset encoding-vector i
338 (decode-char 'ucs (aref vec (- i 128))))
340 (setq translation-table
341 (make-translation-table-from-vector encoding-vector))
342 ;; (define-translation-table 'mac-centraleuropean-decoder translation-table)
343 (define-translation-table 'mac-centraleuropean-encoder
344 (char-table-extra-slot translation-table 0)))
347 ((encoding-vector (make-vector 256 nil))
349 (vec ;; mac-cyrillic (128..255) -> UCS mapping
350 [ #x0410 ;; 128:CYRILLIC CAPITAL LETTER A
351 #x0411 ;; 129:CYRILLIC CAPITAL LETTER BE
352 #x0412 ;; 130:CYRILLIC CAPITAL LETTER VE
353 #x0413 ;; 131:CYRILLIC CAPITAL LETTER GHE
354 #x0414 ;; 132:CYRILLIC CAPITAL LETTER DE
355 #x0415 ;; 133:CYRILLIC CAPITAL LETTER IE
356 #x0416 ;; 134:CYRILLIC CAPITAL LETTER ZHE
357 #x0417 ;; 135:CYRILLIC CAPITAL LETTER ZE
358 #x0418 ;; 136:CYRILLIC CAPITAL LETTER I
359 #x0419 ;; 137:CYRILLIC CAPITAL LETTER SHORT I
360 #x041A ;; 138:CYRILLIC CAPITAL LETTER KA
361 #x041B ;; 139:CYRILLIC CAPITAL LETTER EL
362 #x041C ;; 140:CYRILLIC CAPITAL LETTER EM
363 #x041D ;; 141:CYRILLIC CAPITAL LETTER EN
364 #x041E ;; 142:CYRILLIC CAPITAL LETTER O
365 #x041F ;; 143:CYRILLIC CAPITAL LETTER PE
366 #x0420 ;; 144:CYRILLIC CAPITAL LETTER ER
367 #x0421 ;; 145:CYRILLIC CAPITAL LETTER ES
368 #x0422 ;; 146:CYRILLIC CAPITAL LETTER TE
369 #x0423 ;; 147:CYRILLIC CAPITAL LETTER U
370 #x0424 ;; 148:CYRILLIC CAPITAL LETTER EF
371 #x0425 ;; 149:CYRILLIC CAPITAL LETTER HA
372 #x0426 ;; 150:CYRILLIC CAPITAL LETTER TSE
373 #x0427 ;; 151:CYRILLIC CAPITAL LETTER CHE
374 #x0428 ;; 152:CYRILLIC CAPITAL LETTER SHA
375 #x0429 ;; 153:CYRILLIC CAPITAL LETTER SHCHA
376 #x042A ;; 154:CYRILLIC CAPITAL LETTER HARD SIGN
377 #x042B ;; 155:CYRILLIC CAPITAL LETTER YERU
378 #x042C ;; 156:CYRILLIC CAPITAL LETTER SOFT SIGN
379 #x042D ;; 157:CYRILLIC CAPITAL LETTER E
380 #x042E ;; 158:CYRILLIC CAPITAL LETTER YU
381 #x042F ;; 159:CYRILLIC CAPITAL LETTER YA
383 #x00B0 ;; 161:DEGREE SIGN
384 #x0490 ;; 162:CYRILLIC CAPITAL LETTER GHE WITH UPTURN
385 #x00A3 ;; 163:POUND SIGN
386 #x00A7 ;; 164:SECTION SIGN
388 #x00B6 ;; 166:PILCROW SIGN
389 #x0406 ;; 167:CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
390 #x00AE ;; 168:REGISTERED SIGN
391 #x00A9 ;; 169:COPYRIGHT SIGN
392 #x2122 ;; 170:TRADE MARK SIGN
393 #x0402 ;; 171:CYRILLIC CAPITAL LETTER DJE
394 #x0452 ;; 172:CYRILLIC SMALL LETTER DJE
395 #x2260 ;; 173:NOT EQUAL TO
396 #x0403 ;; 174:CYRILLIC CAPITAL LETTER GJE
397 #x0453 ;; 175:CYRILLIC SMALL LETTER GJE
398 #x221E ;; 176:INFINITY
399 #x00B1 ;; 177:PLUS-MINUS SIGN
400 #x2264 ;; 178:LESS-THAN OR EQUAL TO
401 #x2265 ;; 179:GREATER-THAN OR EQUAL TO
402 #x0456 ;; 180:CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
403 #x00B5 ;; 181:MICRO SIGN
404 #x0491 ;; 182:CYRILLIC SMALL LETTER GHE WITH UPTURN
405 #x0408 ;; 183:CYRILLIC CAPITAL LETTER JE
406 #x0404 ;; 184:CYRILLIC CAPITAL LETTER UKRAINIAN IE
407 #x0454 ;; 185:CYRILLIC SMALL LETTER UKRAINIAN IE
408 #x0407 ;; 186:CYRILLIC CAPITAL LETTER YI
409 #x0457 ;; 187:CYRILLIC SMALL LETTER YI
410 #x0409 ;; 188:CYRILLIC CAPITAL LETTER LJE
411 #x0459 ;; 189:CYRILLIC SMALL LETTER LJE
412 #x040A ;; 190:CYRILLIC CAPITAL LETTER NJE
413 #x045A ;; 191:CYRILLIC SMALL LETTER NJE
414 #x0458 ;; 192:CYRILLIC SMALL LETTER JE
415 #x0405 ;; 193:CYRILLIC CAPITAL LETTER DZE
416 #x00AC ;; 194:NOT SIGN
417 #x221A ;; 195:SQUARE ROOT
418 #x0192 ;; 196:LATIN SMALL LETTER F WITH HOOK
419 #x2248 ;; 197:ALMOST EQUAL TO
420 #x2206 ;; 198:INCREMENT
421 #x00AB ;; 199:LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
422 #x00BB ;; 200:RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
423 #x2026 ;; 201:HORIZONTAL ELLIPSIS
424 #x00A0 ;; 202:NO-BREAK SPACE
425 #x040B ;; 203:CYRILLIC CAPITAL LETTER TSHE
426 #x045B ;; 204:CYRILLIC SMALL LETTER TSHE
427 #x040C ;; 205:CYRILLIC CAPITAL LETTER KJE
428 #x045C ;; 206:CYRILLIC SMALL LETTER KJE
429 #x0455 ;; 207:CYRILLIC SMALL LETTER DZE
430 #x2013 ;; 208:EN DASH
431 #x2014 ;; 209:EM DASH
432 #x201C ;; 210:LEFT DOUBLE QUOTATION MARK
433 #x201D ;; 211:RIGHT DOUBLE QUOTATION MARK
434 #x2018 ;; 212:LEFT SINGLE QUOTATION MARK
435 #x2019 ;; 213:RIGHT SINGLE QUOTATION MARK
436 #x00F7 ;; 214:DIVISION SIGN
437 #x201E ;; 215:DOUBLE LOW-9 QUOTATION MARK
438 #x040E ;; 216:CYRILLIC CAPITAL LETTER SHORT U
439 #x045E ;; 217:CYRILLIC SMALL LETTER SHORT U
440 #x040F ;; 218:CYRILLIC CAPITAL LETTER DZHE
441 #x045F ;; 219:CYRILLIC SMALL LETTER DZHE
442 #x2116 ;; 220:NUMERO SIGN
443 #x0401 ;; 221:CYRILLIC CAPITAL LETTER IO
444 #x0451 ;; 222:CYRILLIC SMALL LETTER IO
445 #x044F ;; 223:CYRILLIC SMALL LETTER YA
446 #x0430 ;; 224:CYRILLIC SMALL LETTER A
447 #x0431 ;; 225:CYRILLIC SMALL LETTER BE
448 #x0432 ;; 226:CYRILLIC SMALL LETTER VE
449 #x0433 ;; 227:CYRILLIC SMALL LETTER GHE
450 #x0434 ;; 228:CYRILLIC SMALL LETTER DE
451 #x0435 ;; 229:CYRILLIC SMALL LETTER IE
452 #x0436 ;; 230:CYRILLIC SMALL LETTER ZHE
453 #x0437 ;; 231:CYRILLIC SMALL LETTER ZE
454 #x0438 ;; 232:CYRILLIC SMALL LETTER I
455 #x0439 ;; 233:CYRILLIC SMALL LETTER SHORT I
456 #x043A ;; 234:CYRILLIC SMALL LETTER KA
457 #x043B ;; 235:CYRILLIC SMALL LETTER EL
458 #x043C ;; 236:CYRILLIC SMALL LETTER EM
459 #x043D ;; 237:CYRILLIC SMALL LETTER EN
460 #x043E ;; 238:CYRILLIC SMALL LETTER O
461 #x043F ;; 239:CYRILLIC SMALL LETTER PE
462 #x0440 ;; 240:CYRILLIC SMALL LETTER ER
463 #x0441 ;; 241:CYRILLIC SMALL LETTER ES
464 #x0442 ;; 242:CYRILLIC SMALL LETTER TE
465 #x0443 ;; 243:CYRILLIC SMALL LETTER U
466 #x0444 ;; 244:CYRILLIC SMALL LETTER EF
467 #x0445 ;; 245:CYRILLIC SMALL LETTER HA
468 #x0446 ;; 246:CYRILLIC SMALL LETTER TSE
469 #x0447 ;; 247:CYRILLIC SMALL LETTER CHE
470 #x0448 ;; 248:CYRILLIC SMALL LETTER SHA
471 #x0449 ;; 249:CYRILLIC SMALL LETTER SHCHA
472 #x044A ;; 250:CYRILLIC SMALL LETTER HARD SIGN
473 #x044B ;; 251:CYRILLIC SMALL LETTER YERU
474 #x044C ;; 252:CYRILLIC SMALL LETTER SOFT SIGN
475 #x044D ;; 253:CYRILLIC SMALL LETTER E
476 #x044E ;; 254:CYRILLIC SMALL LETTER YU
477 #x20AC ;; 255:EURO SIGN
481 (aset encoding-vector i i)
484 (aset encoding-vector i
485 (decode-char 'ucs (aref vec (- i 128))))
487 (setq translation-table
488 (make-translation-table-from-vector encoding-vector))
489 ;; (define-translation-table 'mac-cyrillic-decoder translation-table)
490 (define-translation-table 'mac-cyrillic-encoder
491 (char-table-extra-slot translation-table 0)))
493 (defvar mac-font-encoder-list
494 '(("mac-roman" mac-roman-encoder
495 ccl-encode-mac-roman-font "%s")
496 ("mac-centraleuropean" mac-centraleuropean-encoder
497 ccl-encode-mac-centraleuropean-font "%s ce")
498 ("mac-cyrillic" mac-cyrillic-encoder
499 ccl-encode-mac-cyrillic-font "%s cy")))
502 (mapcar (lambda (lst) (nth 1 lst)) mac-font-encoder-list))
505 latin-iso8859-3 latin-iso8859-4
506 cyrillic-iso8859-5 greek-iso8859-7 hebrew-iso8859-8
507 latin-iso8859-9 latin-iso8859-14 latin-iso8859-15)))
508 (dolist (encoder encoder-list)
509 (let ((table (get encoder 'translation-table)))
510 (dolist (charset charset-list)
512 (let* ((c (make-char charset (+ i 32)))
513 (mu (aref ucs-mule-to-mule-unicode c))
514 (mac-encoded (and mu (aref table mu))))
516 (aset table c mac-encoded))))))))
518 (define-ccl-program ccl-encode-mac-centraleuropean-font
520 (if (r0 != ,(charset-id 'ascii))
522 (translate-character mac-centraleuropean-encoder r0 r1)
525 (translate-character mac-centraleuropean-encoder r0 r1)))))
526 "CCL program for Mac Central European font")
528 (define-ccl-program ccl-encode-mac-cyrillic-font
530 (if (r0 != ,(charset-id 'ascii))
532 (translate-character mac-cyrillic-encoder r0 r1)
535 (translate-character mac-cyrillic-encoder r0 r1)))))
536 "CCL program for Mac Cyrillic font")
539 (setq font-ccl-encoder-alist
541 (mapcar (lambda (lst) (cons (nth 0 lst) (nth 2 lst)))
542 mac-font-encoder-list)
543 font-ccl-encoder-alist))
545 (defun fontset-add-mac-fonts (fontset &optional base-family)
547 (setq base-family (downcase base-family))
549 (downcase (x-resolve-font-name
550 (fontset-font fontset (charset-id 'ascii))))))
551 (setq base-family (aref (x-decompose-font-name ascii-font)
552 xlfd-regexp-family-subnum))))
553 ;; (if (not (string-match "^fontset-" fontset))
555 ;; (concat "fontset-" (aref (x-decompose-font-name fontset)
556 ;; xlfd-regexp-encoding-subnum))))
560 (mapcar (lambda (lst)
561 (cons (cons (format (nth 3 lst) base-family) (nth 0 lst))
563 mac-font-encoder-list)))
564 (let ((font (car font-encoder))
565 (encoder (cdr font-encoder)))
570 (memq (char-charset key)
571 '(ascii eight-bit-control eight-bit-graphic))
572 (set-fontset-font fontset key font)))
573 (get encoder 'translation-table)))))
575 (defun create-fontset-from-mac-roman-font (font &optional resolved-font
577 "Create a fontset from a Mac roman font FONT.
579 Optional 1st arg RESOLVED-FONT is a resolved name of FONT. If
580 omitted, `x-resolve-font-name' is called to get the resolved name. At
581 this time, if FONT is not available, error is signaled.
583 Optional 2nd arg FONTSET-NAME is a string to be used in
584 `<CHARSET_ENCODING>' fields of a new fontset name. If it is omitted,
585 an appropriate name is generated automatically.
587 It returns a name of the created fontset."
589 (create-fontset-from-ascii-font font resolved-font fontset-name)))
590 (fontset-add-mac-fonts fontset)
593 ;; Create a fontset that uses mac-roman font. With this fontset,
594 ;; characters decoded from mac-roman encoding (ascii, latin-iso8859-1,
595 ;; and mule-unicode-xxxx-yyyy) are displayed by a mac-roman font.
597 (if (fboundp 'new-fontset)
600 (setup-default-fontset)
601 (create-fontset-from-fontset-spec
602 "-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac,
603 ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
604 (fontset-add-mac-fonts "fontset-mac")))
606 (if (eq system-type 'darwin)
607 ;; On Darwin filenames are encoded in UTF-8
608 (setq file-name-coding-system 'utf-8)
609 ;; To display filenames in Chinese or Japanese, replace mac-roman with
611 (setq file-name-coding-system 'mac-roman))
613 ;; If Emacs is started from the Finder, change the default directory
614 ;; to the user's home directory.
615 (if (string= default-directory "/")
618 ;; Tell Emacs to use pipes instead of pty's for processes because the
619 ;; latter sometimes lose characters. Pty support is compiled in since
620 ;; ange-ftp will not work without it.
621 (setq process-connection-type nil)
623 ;; Assume that fonts are always scalable on the Mac. This sometimes
624 ;; results in characters with jagged edges. However, without it,
625 ;; fonts with both truetype and bitmap representations but no italic
626 ;; or bold bitmap versions will not display these variants correctly.
627 (setq scalable-fonts-allowed t)
629 ;; Make suspend-emacs [C-z] collapse the current frame
630 (substitute-key-definition 'suspend-emacs 'iconify-frame
633 ;; Support mouse-wheel scrolling
636 ;; (prefer-coding-system 'mac-roman)
638 ;; Map certain keypad keys into ASCII characters that people usually expect
639 (define-key function-key-map [return] [?\C-m])
640 (define-key function-key-map [M-return] [?\M-\C-m])
641 (define-key function-key-map [tab] [?\t])
642 (define-key function-key-map [M-tab] [?\M-\t])
643 (define-key function-key-map [backspace] [127])
644 (define-key function-key-map [M-backspace] [?\M-\d])
645 (define-key function-key-map [escape] [?\e])
646 (define-key function-key-map [M-escape] [?\M-\e])
648 ;; Tell read-char how to convert special chars to ASCII
649 (put 'return 'ascii-character 13)
650 (put 'tab 'ascii-character ?\t)
651 (put 'backspace 'ascii-character 127)
652 (put 'escape 'ascii-character ?\e)
658 (defvar x-colors '("LightGreen"
1257 "LightGoldenrodYellow"
1258 "light goldenrod yellow"
1275 "medium spring green"
1410 "The list of X colors from the `rgb.txt' file.
1411 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1413 ;;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
1414 ;;; mac-win.el ends here