]> code.delx.au - gnu-emacs/blobdiff - lisp/term/mac-win.el
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-37
[gnu-emacs] / lisp / term / mac-win.el
index 869a79e296664e02c58949518b0183b2eb35471d..1dea51aa7c0f05690117d66f1a380036a64b4b4e 100644 (file)
@@ -1,6 +1,7 @@
 ;;; mac-win.el --- parse switches controlling interface with Mac window system
 
-;; Copyright (C) 1999, 2000, 2002, 2003, 2004  Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005
+;;   Free Software Foundation, Inc.
 
 ;; Author: Andrew Choi <akochoi@mac.com>
 ;; Keywords: terminals
@@ -76,7 +77,7 @@
 ;;(require 'select)
 (require 'menu-bar)
 (require 'fontset)
-(require 'x-dnd)
+(require 'dnd)
 
 (defvar x-invocation-args)
 
@@ -229,6 +230,55 @@ This function returns ARGS minus the arguments that have been processed."
            (funcall handler this-switch))
        (setq args (cons orig-this-switch args)))))
   (nconc (nreverse args) x-invocation-args))
+
+\f
+;;
+;; Standard Mac cursor shapes
+;;
+
+(defconst mac-pointer-arrow 0)
+(defconst mac-pointer-copy-arrow 1)
+(defconst mac-pointer-alias-arrow 2)
+(defconst mac-pointer-contextual-menu-arrow 3)
+(defconst mac-pointer-I-beam 4)
+(defconst mac-pointer-cross 5)
+(defconst mac-pointer-plus 6)
+(defconst mac-pointer-watch 7)
+(defconst mac-pointer-closed-hand 8)
+(defconst mac-pointer-open-hand 9)
+(defconst mac-pointer-pointing-hand 10)
+(defconst mac-pointer-counting-up-hand 11)
+(defconst mac-pointer-counting-down-hand 12)
+(defconst mac-pointer-counting-up-and-down-hand 13)
+(defconst mac-pointer-spinning 14)
+(defconst mac-pointer-resize-left 15)
+(defconst mac-pointer-resize-right 16)
+(defconst mac-pointer-resize-left-right 17)
+;; Mac OS X 10.2 and later
+(defconst mac-pointer-not-allowed 18)
+;; Mac OS X 10.3 and later
+(defconst mac-pointer-resize-up 19)
+(defconst mac-pointer-resize-down 20)
+(defconst mac-pointer-resize-up-down 21)
+(defconst mac-pointer-poof 22)
+
+;;
+;; Standard X cursor shapes that have Mac counterparts
+;;
+
+(defconst x-pointer-left-ptr mac-pointer-arrow)
+(defconst x-pointer-xterm mac-pointer-I-beam)
+(defconst x-pointer-crosshair mac-pointer-cross)
+(defconst x-pointer-plus mac-pointer-plus)
+(defconst x-pointer-watch mac-pointer-watch)
+(defconst x-pointer-hand2 mac-pointer-pointing-hand)
+(defconst x-pointer-left-side mac-pointer-resize-left)
+(defconst x-pointer-right-side mac-pointer-resize-right)
+(defconst x-pointer-sb-h-double-arrow mac-pointer-resize-left-right)
+(defconst x-pointer-top-side mac-pointer-resize-up)
+(defconst x-pointer-bottom-side mac-pointer-resize-down)
+(defconst x-pointer-sb-v-double-arrow mac-pointer-resize-up-down)
+
 \f
 ;;
 ;; Available colors
@@ -1009,30 +1059,55 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
 
 ;; Map certain keypad keys into ASCII characters
 ;; that people usually expect.
-(define-key function-key-map [return] [?\C-m])
-(define-key function-key-map [M-return] [?\M-\C-m])
+(define-key function-key-map [backspace] [?\d])
+(define-key function-key-map [delete] [?\d])
 (define-key function-key-map [tab] [?\t])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [backspace] [127])
-(define-key function-key-map [M-backspace] [?\M-\d])
+(define-key function-key-map [linefeed] [?\n])
+(define-key function-key-map [clear] [?\C-l])
+(define-key function-key-map [return] [?\C-m])
 (define-key function-key-map [escape] [?\e])
+(define-key function-key-map [M-backspace] [?\M-\d])
+(define-key function-key-map [M-delete] [?\M-\d])
+(define-key function-key-map [M-tab] [?\M-\t])
+(define-key function-key-map [M-linefeed] [?\M-\n])
+(define-key function-key-map [M-clear] [?\M-\C-l])
+(define-key function-key-map [M-return] [?\M-\C-m])
 (define-key function-key-map [M-escape] [?\M-\e])
 
 ;; These tell read-char how to convert
 ;; these special chars to ASCII.
-(put 'return 'ascii-character 13)
+(put 'backspace 'ascii-character ?\d)
+(put 'delete 'ascii-character ?\d)
 (put 'tab 'ascii-character ?\t)
-(put 'backspace 'ascii-character 127)
+(put 'linefeed 'ascii-character ?\n)
+(put 'clear 'ascii-character ?\C-l)
+(put 'return 'ascii-character ?\C-m)
 (put 'escape 'ascii-character ?\e)
 
 \f
-;;;; Keysyms
-
-;; Define constant values to be set to mac-keyboard-text-encoding
-(defconst kTextEncodingMacRoman 0)
-(defconst kTextEncodingISOLatin1 513 "0x201")
-(defconst kTextEncodingISOLatin2 514 "0x202")
-
+;;;; Keyboard layout/language change events
+(defconst mac-script-code-coding-systems
+  '((0 . mac-roman)                    ; smRoman
+    (1 . japanese-shift-jis)           ; smJapanese
+    (2 . chinese-big5)                 ; smTradChinese
+    (3 . korean-iso-8bit)              ; smKorean
+    (7 . mac-cyrillic)                 ; smCyrillic
+    (25 . chinese-iso-8bit)            ; smSimpChinese
+    (29 . mac-centraleurroman)         ; smCentralEuroRoman
+    )
+  "Alist of Mac script codes vs Emacs coding systems.")
+
+;;;; Keyboard layout/language change events
+(defun mac-handle-language-change (event)
+  (interactive "e")
+  (let ((coding-system
+        (cdr (assq (car (cadr event)) mac-script-code-coding-systems))))
+    (set-keyboard-coding-system (or coding-system 'mac-roman))
+    ;; MacJapanese maps reverse solidus to ?\x80.
+    (if (eq coding-system 'japanese-shift-jis)
+       (define-key key-translation-map [?\x80] "\\"))))
+
+(define-key special-event-map [language-change] 'mac-handle-language-change)
 \f
 ;;;; Selections and cut buffers
 
@@ -1119,7 +1194,10 @@ See the documentation of `create-fontset-from-fontset-spec for the format.")
          (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
        ;; Create a fontset from FONT.  The fontset name is
        ;; generated from FONT.
-       (create-fontset-from-ascii-font font resolved-name "startup"))))
+       (if (and (string= "mac" (aref xlfd-fields xlfd-regexp-registry-subnum))
+                (string= "roman" (aref xlfd-fields xlfd-regexp-encoding-subnum)))
+           (create-fontset-from-mac-roman-font font resolved-name "startup")
+         (create-fontset-from-ascii-font font resolved-name "startup")))))
 
 ;; Apply a geometry resource to the initial frame.  Put it at the end
 ;; of the alist, so that anything specified on the command line takes
@@ -1187,8 +1265,8 @@ Switch to a buffer editing the last file dropped."
                      (if (and (> start 0) (> end 0))
                          (progn (set-mark start)
                                 (goto-char end)))))
-               (x-dnd-handle-one-url window 'private
-                                     (concat "file:" file-name))))
+               (dnd-handle-one-url window 'private
+                                   (concat "file:" file-name))))
            (car (cdr (cdr event)))))
   (raise-frame))
 
@@ -1268,7 +1346,7 @@ Switch to a buffer editing the last file dropped."
 
 (unless (eq system-type 'darwin)
   ;; This variable specifies the Unix program to call (as a process) to
-  ;; deteremine the amount of free space on a file system (defaults to
+  ;; determine the amount of free space on a file system (defaults to
   ;; df).  If it is not set to nil, ls-lisp will not work correctly
   ;; unless an external application df is implemented on the Mac.
   (setq directory-free-space-program nil)
@@ -1276,29 +1354,25 @@ Switch to a buffer editing the last file dropped."
   ;; Set this so that Emacs calls subprocesses with "sh" as shell to
   ;; expand filenames Note no subprocess for the shell is actually
   ;; started (see run_mac_command in sysdep.c).
-  (setq shell-file-name "sh"))
+  (setq shell-file-name "sh")
+
+  ;; To display filenames in Chinese or Japanese, replace mac-roman with
+  ;; big5 or sjis
+  (setq file-name-coding-system 'mac-roman))
 
 ;; X Window emulation in macterm.c is not complete enough to start a
 ;; frame without a minibuffer properly.  Call this to tell ediff
 ;; library to use a single frame.
 ; (ediff-toggle-multiframe)
 
-(if (eq system-type 'darwin)
-    ;; On Darwin filenames are encoded in UTF-8
-    (setq file-name-coding-system 'utf-8)
-  ;; To display filenames in Chinese or Japanese, replace mac-roman with
-  ;; big5 or sjis
-  (setq file-name-coding-system 'mac-roman))
-
 ;; If Emacs is started from the Finder, change the default directory
 ;; to the user's home directory.
 (if (string= default-directory "/")
     (cd "~"))
 
-;; Tell Emacs to use pipes instead of pty's for processes because the
-;; latter sometimes lose characters.  Pty support is compiled in since
-;; ange-ftp will not work without it.
-(setq process-connection-type nil)
+;; Darwin 6- pty breakage is now controlled from the C code so that
+;; it applies to all builds on darwin.  See s/darwin.h PTY_ITERATION.
+;; (setq process-connection-type t)
 
 ;; Assume that fonts are always scalable on the Mac.  This sometimes
 ;; results in characters with jagged edges.  However, without it,
@@ -1308,5 +1382,5 @@ Switch to a buffer editing the last file dropped."
 
 ;; (prefer-coding-system 'mac-roman)
 
-;;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
+;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
 ;;; mac-win.el ends here