comparison lisp/term/mac-win.el @ 83716:a73440d2f146 merge-multi-tty-to-trunk

Merge multi-tty branch Revision: emacs@sv.gnu.org/emacs--devo--0--patch-866
author Miles Bader <miles@gnu.org>
date Wed, 29 Aug 2007 05:28:10 +0000
parents 27d11c1d4e46
children 727d03075a75
comparison
equal deleted inserted replaced
82950:ed8435ec5652 83716:a73440d2f146
63 ;; -xrm 63 ;; -xrm
64 64
65 ;; An alist of X options and the function which handles them. See 65 ;; An alist of X options and the function which handles them. See
66 ;; ../startup.el. 66 ;; ../startup.el.
67 67
68 (if (not (eq window-system 'mac)) 68 ;; (if (not (eq window-system 'mac))
69 (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name))) 69 ;; (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
70 70
71 (require 'frame) 71 (require 'frame)
72 (require 'mouse) 72 (require 'mouse)
73 (require 'scroll-bar) 73 (require 'scroll-bar)
74 (require 'faces) 74 (require 'faces)
1060 ;;;; Function keys 1060 ;;;; Function keys
1061 1061
1062 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame 1062 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1063 global-map) 1063 global-map)
1064 1064
1065 (defun x-setup-function-keys (frame)
1066 "Setup Function Keys for mac."
1065 ;; Map certain keypad keys into ASCII characters 1067 ;; Map certain keypad keys into ASCII characters
1066 ;; that people usually expect. 1068 ;; that people usually expect.
1067 (define-key function-key-map [backspace] [?\d]) 1069 (define-key local-function-key-map [backspace] [?\d])
1068 (define-key function-key-map [delete] [?\d]) 1070 (define-key local-function-key-map [delete] [?\d])
1069 (define-key function-key-map [tab] [?\t]) 1071 (define-key local-function-key-map [tab] [?\t])
1070 (define-key function-key-map [linefeed] [?\n]) 1072 (define-key local-function-key-map [linefeed] [?\n])
1071 (define-key function-key-map [clear] [?\C-l]) 1073 (define-key local-function-key-map [clear] [?\C-l])
1072 (define-key function-key-map [return] [?\C-m]) 1074 (define-key local-function-key-map [return] [?\C-m])
1073 (define-key function-key-map [escape] [?\e]) 1075 (define-key local-function-key-map [escape] [?\e])
1074 (define-key function-key-map [M-backspace] [?\M-\d]) 1076 (define-key local-function-key-map [M-backspace] [?\M-\d])
1075 (define-key function-key-map [M-delete] [?\M-\d]) 1077 (define-key local-function-key-map [M-delete] [?\M-\d])
1076 (define-key function-key-map [M-tab] [?\M-\t]) 1078 (define-key local-function-key-map [M-tab] [?\M-\t])
1077 (define-key function-key-map [M-linefeed] [?\M-\n]) 1079 (define-key local-function-key-map [M-linefeed] [?\M-\n])
1078 (define-key function-key-map [M-clear] [?\M-\C-l]) 1080 (define-key local-function-key-map [M-clear] [?\M-\C-l])
1079 (define-key function-key-map [M-return] [?\M-\C-m]) 1081 (define-key local-function-key-map [M-return] [?\M-\C-m])
1080 (define-key function-key-map [M-escape] [?\M-\e]) 1082 (define-key local-function-key-map [M-escape] [?\M-\e])
1083 )
1081 1084
1082 ;; These tell read-char how to convert 1085 ;; These tell read-char how to convert
1083 ;; these special chars to ASCII. 1086 ;; these special chars to ASCII.
1084 (put 'backspace 'ascii-character ?\d) 1087 (put 'backspace 'ascii-character ?\d)
1085 (put 'delete 'ascii-character ?\d) 1088 (put 'delete 'ascii-character ?\d)
2292 (dolist (item (mac-ae-list ae)) 2295 (dolist (item (mac-ae-list ae))
2293 (if (not (equal (car item) "null")) 2296 (if (not (equal (car item) "null"))
2294 (mac-dnd-drop-data event (selected-frame) window 2297 (mac-dnd-drop-data event (selected-frame) window
2295 (cdr item) (car item) action))))) 2298 (cdr item) (car item) action)))))
2296 2299
2297 ;;; Do the actual Windows setup here; the above code just defines
2298 ;;; functions and variables that we use now.
2299
2300 (setq command-line-args (x-handle-args command-line-args))
2301
2302 ;;; Make sure we have a valid resource name.
2303 (or (stringp x-resource-name)
2304 (let (i)
2305 (setq x-resource-name (invocation-name))
2306
2307 ;; Change any . or * characters in x-resource-name to hyphens,
2308 ;; so as not to choke when we use it in X resource queries.
2309 (while (setq i (string-match "[.*]" x-resource-name))
2310 (aset x-resource-name i ?-))))
2311
2312 (if (x-display-list)
2313 ;; On Mac OS 8/9, Most coding systems used in code conversion for
2314 ;; font names are not ready at the time when the terminal frame is
2315 ;; created. So we reconstruct font name table for the initial
2316 ;; frame.
2317 (mac-clear-font-name-table)
2318 (x-open-connection "Mac"
2319 x-command-line-resources
2320 ;; Exit Emacs with fatal error if this fails.
2321 t))
2322
2323 (setq frame-creation-function 'x-create-frame-with-faces)
2324
2325 (defvar mac-font-encoder-list 2300 (defvar mac-font-encoder-list
2326 '(("mac-roman" mac-roman-encoder 2301 '(("mac-roman" mac-roman-encoder
2327 ccl-encode-mac-roman-font "%s") 2302 ccl-encode-mac-roman-font "%s")
2328 ("mac-centraleurroman" encode-mac-centraleurroman 2303 ("mac-centraleurroman" encode-mac-centraleurroman
2329 ccl-encode-mac-centraleurroman-font "%s ce") 2304 ccl-encode-mac-centraleurroman-font "%s ce")
2497 (let ((fontset 2472 (let ((fontset
2498 (create-fontset-from-ascii-font font resolved-font fontset-name))) 2473 (create-fontset-from-ascii-font font resolved-font fontset-name)))
2499 (fontset-add-mac-fonts fontset t) 2474 (fontset-add-mac-fonts fontset t)
2500 fontset)) 2475 fontset))
2501 2476
2477 (defun x-win-suspend-error ()
2478 (error "Suspending an Emacs running under Mac makes no sense"))
2479
2480 (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
2481
2482 (defvar mac-initialized nil
2483 "Non-nil if the w32 window system has been initialized.")
2484
2485 (defun mac-initialize-window-system ()
2486 "Initialize Emacs for Mac GUI frames."
2487
2488 ;;; Do the actual Windows setup here; the above code just defines
2489 ;;; functions and variables that we use now.
2490
2491 (setq command-line-args (x-handle-args command-line-args))
2492
2493 ;;; Make sure we have a valid resource name.
2494 (or (stringp x-resource-name)
2495 (let (i)
2496 (setq x-resource-name (invocation-name))
2497
2498 ;; Change any . or * characters in x-resource-name to hyphens,
2499 ;; so as not to choke when we use it in X resource queries.
2500 (while (setq i (string-match "[.*]" x-resource-name))
2501 (aset x-resource-name i ?-))))
2502
2503 (if (x-display-list)
2504 ;; On Mac OS 8/9, Most coding systems used in code conversion for
2505 ;; font names are not ready at the time when the terminal frame is
2506 ;; created. So we reconstruct font name table for the initial
2507 ;; frame.
2508 (mac-clear-font-name-table)
2509 (x-open-connection "Mac"
2510 x-command-line-resources
2511 ;; Exit Emacs with fatal error if this fails.
2512 t))
2513
2514 (add-hook 'suspend-hook 'x-win-suspend-error)
2515
2516 ;;; Arrange for the kill and yank functions to set and check the clipboard.
2517 (setq interprogram-cut-function 'x-select-text)
2518 (setq interprogram-paste-function 'x-get-selection-value)
2519
2520
2521
2522
2523 ;;; Turn off window-splitting optimization; Mac is usually fast enough
2524 ;;; that this is only annoying.
2525 (setq split-window-keep-point t)
2526
2527 ;; Don't show the frame name; that's redundant.
2528 (setq-default mode-line-frame-identification " ")
2529
2530 ;; Turn on support for mouse wheels.
2531 (mouse-wheel-mode 1)
2532
2533
2534 ;; Enable CLIPBOARD copy/paste through menu bar commands.
2535 (menu-bar-enable-clipboard)
2536
2537
2538 ;; Initiate drag and drop
2539
2540 (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2541
2542
2543 ;;;; Non-toolkit Scroll bars
2544
2545 (unless x-toolkit-scroll-bars
2546
2547 ;; for debugging
2548 ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
2549
2550 ;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
2551
2552 (global-set-key
2553 [vertical-scroll-bar down-mouse-1]
2554 'mac-handle-scroll-bar-event)
2555
2556 (global-unset-key [vertical-scroll-bar drag-mouse-1])
2557 (global-unset-key [vertical-scroll-bar mouse-1])
2558
2502 ;; Adjust Courier font specifications in x-fixed-font-alist. 2559 ;; Adjust Courier font specifications in x-fixed-font-alist.
2503 (let ((courier-fonts (assoc "Courier" x-fixed-font-alist))) 2560 (let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
2504 (if courier-fonts 2561 (if courier-fonts
2505 (dolist (label-fonts (cdr courier-fonts)) 2562 (dolist (label-fonts (cdr courier-fonts))
2506 (setcdr label-fonts 2563 (setcdr label-fonts
2603 (if (and rv 2660 (if (and rv
2604 (string-match "^\\(true\\|yes\\|on\\)$" rv)) 2661 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2605 (setq default-frame-alist 2662 (setq default-frame-alist
2606 (cons '(reverse . t) default-frame-alist))))) 2663 (cons '(reverse . t) default-frame-alist)))))
2607 2664
2608 (defun x-win-suspend-error () 2665 (setq mac-initialized t)))
2609 (error "Suspending an Emacs running under Mac makes no sense"))
2610 (add-hook 'suspend-hook 'x-win-suspend-error)
2611
2612 ;;; Arrange for the kill and yank functions to set and check the clipboard.
2613 (setq interprogram-cut-function 'x-select-text)
2614 (setq interprogram-paste-function 'x-get-selection-value)
2615
2616 (defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
2617
2618 ;;; Turn off window-splitting optimization; Mac is usually fast enough
2619 ;;; that this is only annoying.
2620 (setq split-window-keep-point t)
2621
2622 ;; Don't show the frame name; that's redundant.
2623 (setq-default mode-line-frame-identification " ")
2624
2625 ;; Turn on support for mouse wheels.
2626 (mouse-wheel-mode 1)
2627
2628
2629 ;; Enable CLIPBOARD copy/paste through menu bar commands.
2630 (menu-bar-enable-clipboard)
2631
2632 ;; Initiate drag and drop
2633
2634 (define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
2635
2636
2637 ;;;; Non-toolkit Scroll bars
2638
2639 (unless x-toolkit-scroll-bars
2640
2641 ;; for debugging
2642 ;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
2643
2644 ;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
2645
2646 (global-set-key
2647 [vertical-scroll-bar down-mouse-1]
2648 'mac-handle-scroll-bar-event)
2649
2650 (global-unset-key [vertical-scroll-bar drag-mouse-1])
2651 (global-unset-key [vertical-scroll-bar mouse-1])
2652 2666
2653 (defun mac-handle-scroll-bar-event (event) 2667 (defun mac-handle-scroll-bar-event (event)
2654 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling." 2668 "Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
2655 (interactive "e") 2669 (interactive "e")
2656 (let* ((position (event-start event)) 2670 (let* ((position (event-start event))
2694 (defun mac-scroll-up-line () 2708 (defun mac-scroll-up-line ()
2695 (track-mouse 2709 (track-mouse
2696 (mac-scroll-ignore-events) 2710 (mac-scroll-ignore-events)
2697 (scroll-up 1))) 2711 (scroll-up 1)))
2698 2712
2699 )
2700 2713
2701 2714
2702 ;;;; Others 2715 ;;;; Others
2703 2716
2704 (unless (eq system-type 'darwin) 2717 (unless (eq system-type 'darwin)
2732 ;; results in characters with jagged edges. However, without it, 2745 ;; results in characters with jagged edges. However, without it,
2733 ;; fonts with both truetype and bitmap representations but no italic 2746 ;; fonts with both truetype and bitmap representations but no italic
2734 ;; or bold bitmap versions will not display these variants correctly. 2747 ;; or bold bitmap versions will not display these variants correctly.
2735 (setq scalable-fonts-allowed t) 2748 (setq scalable-fonts-allowed t)
2736 2749
2750 (add-to-list 'handle-args-function-alist '(mac . x-handle-args))
2751 (add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
2752 (add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
2753
2754 (provide 'mac-win)
2755
2737 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6 2756 ;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
2738 ;;; mac-win.el ends here 2757 ;;; mac-win.el ends here