Commit 1a578e9b authored by Andrew Choi's avatar Andrew Choi
Browse files

Initial check-in: changes for building Emacs under Mac OS.

2000-10-23  Andrew Choi  <akochoi@i-cable.com>

	* dispextern.h [macintosh]: Include macgui.h instead of macterm.h.

	* dispnew.c [macintosh]: Include macterm.h.
	(init_display) [macintosh]: initialization for window system.

	* emacs.c (main) [macintosh]: Call syms_of_textprop,
	syms_of_macfns, syms_of_ccl, syms_of_fontset, syms_of_xterm,
	syms_of_search, x_term_init, and init_keyboard before calling
	init_window_once.  Also, call syms_of_xmenu.

	* fontset.c (syms_of_fontset) [macintosh]: Set ASCII font of
	default fontset to Monaco.

	* frame.c [macintosh]: Include macterm.h.  Remove declarations of
	NewMacWindow and DisposeMacWindow.
	(make_terminal_frame) [macintosh]: Call make_mac_terminal_frame
	instead of calling NewMacWindow and setting fields of
	f->output_data.mac directly.  Call init_frame_faces.
	(Fdelete_frame) [macintosh]: Remove unused code.
	(Fmodify_frame_parameters) [macintosh]: Call
	x_set_frame_parameters instead of mac_set_frame_parameters.

	* frame.h [macintosh]: Define menu_bar_lines field in struct
	frame.  Define FRAME_EXTERNAL_MENU_BAR macro.

	* keyboard.c [macintosh]: Include macterm.h.
	(kbd_buffer_get_event) [macintosh]: Generate delete_window_event
	and menu_bar_activate_event type events as for X and NT.
	(make_lispy_event) [macintosh]: Construct lisp events of type
	MENU_BAR_EVENT as for X and NT.

	* sysdep.c [macintosh]: Remove declaration for sys_signal.
	Include stdlib.h.  Remove definition of Vx_bitmap_file_path.
	(sys_subshell) [macintosh]: Remove definition entirely.
	(init_sys_modes) [macintosh]: Do not initialize Vwindow_system and
	Vwindow_system_version here.  Remove initialization of
	Vx_bitmap_file_path.
	(read_input_waiting): Correct the number of parameters passed to
	read_socket_hook.
	Move all Macintosh functions to mac/mac.c.

	* term.c [macintosh]: Include macterm.h.

	* window.c [macintosh]: Include macterm.h.

	* xdisp.c [macintosh]: Include macterm.h.  Declare
	set_frame_menubar and pending_menu_activation.
	(echo_area_display) [macintosh]: Do not return if terminal frame
	is the selected frame.
	(update_menu_bar) [macintosh]: Check FRAME_EXTERNAL_MENU_BAR (f).
	Allow only the selected frame to set menu bar.
	(redisplay_window) [macintosh]: Obtain menu bar to redisplay by
	calling FRAME_EXTERNAL_MENU_BAR (f).
	(display_menu_bar) [macintosh]: Check FRAME_MAC_P (f).

	* xfaces.c [macintosh]: Include macterm.h.  Define x_display_info
	and check_x.  Declare XCreateGC.  Define x_create_gc and
	x_free_gc.  Initialize font_sort_order.
	(x_face_list_fonts) [macintosh]: Use the same code as WINDOWSNT,
	but call x_list_fonts instead of w32_list_fonts.
	(Finternal_face_x_get_resource) [macintosh]: Do not call
	display_x_get_resource.
	(prepare_face_for_display) [macintosh]: Set xgcv.font.
	(realize_x_face) [macintosh]: Load the font if it is specified in
	ATTRS.
	(syms_of_xfaces) [macintosh]: Initialize Vscalable_fonts_allowed
	to Qt.

	* cus-edit.el (custom-button-face): Use 3D look for mac.
	(custom-button-pressed-face): Likewise.

	* faces.el (set-face-attributes-from-resources): Handle mac frames
	in the same way as x and w32 frames.
	(face-valid-attribute-values): Likewise.
	(read-face-attribute): Likewise.
	(defined-colors): Likewise.
	(color-defined-p): Likewise.
	(color-values): Likewise.
	(display-grayscale-p): Likewise.
	(face-set-after-frame-default): Likewise.
	(mode-line): Same default face as for x and w32.
	(tool-bar): Likewise.

	* frame.el: Remove call to frame-notice-user-settings at end of
	the file.

	* info.el (Info-fontify-node): make underlines invisible for mac
	as for x, pc, and w32 frame types.

	* term/mac-win.el: New file.
parent d371949a
2000-10-23 Andrew Choi <akochoi@i-cable.com>
* cus-edit.el (custom-button-face): Use 3D look for mac.
(custom-button-pressed-face): Likewise.
* faces.el (set-face-attributes-from-resources): Handle mac frames
in the same way as x and w32 frames.
(face-valid-attribute-values): Likewise.
(read-face-attribute): Likewise.
(defined-colors): Likewise.
(color-defined-p): Likewise.
(color-values): Likewise.
(display-grayscale-p): Likewise.
(face-set-after-frame-default): Likewise.
(mode-line): Same default face as for x and w32.
(tool-bar): Likewise.
* frame.el: Remove call to frame-notice-user-settings at end of
the file.
* info.el (Info-fontify-node): make underlines invisible for mac
as for x, pc, and w32 frame types.
* term/mac-win.el: New file.
2000-10-22 Dave Love <fx@gnu.org>
* textmodes/refill.el: New file.
......
......@@ -1711,6 +1711,9 @@ and `face'."
(((type w32) (class color)) ; Like default modeline
(:box (:line-width 2 :style released-button)
:background "lightgrey" :foreground "black"))
(((type mac) (class color)) ; Like default modeline
(:box (:line-width 2 :style released-button)
:background "lightgrey" :foreground "black"))
(t
nil))
"Face used for buttons in customization buffers."
......@@ -1724,6 +1727,9 @@ and `face'."
(((type w32) (class color))
(:box (:line-width 2 :style pressed-button)
:background "lightgrey" :foreground "black"))
(((type mac) (class color))
(:box (:line-width 2 :style pressed-button)
:background "lightgrey" :foreground "black"))
(t
(:inverse-video t)))
"Face used for buttons in customization buffers."
......
......@@ -300,7 +300,7 @@ specifies an invalid attribute."
(defun set-face-attributes-from-resources (face frame)
"Set attributes of FACE from X resources for FRAME."
(when (memq (framep frame) '(x w32))
(when (memq (framep frame) '(x w32 mac))
(dolist (definition face-x-resources)
(let ((attribute (car definition)))
(dolist (entry (cdr definition))
......@@ -777,7 +777,7 @@ an integer value."
((:height)
'integerp)
(:stipple
(and (memq window-system '(x w32))
(and (memq window-system '(x w32 mac))
(mapcar #'list
(apply #'nconc
(mapcar (lambda (dir)
......@@ -1231,7 +1231,7 @@ is used. If nil or omitted, use the selected frame."
The argument FRAME specifies which frame to try.
The value may be different for frames on different display types.
If FRAME doesn't support colors, the value is nil."
(if (memq (framep (or frame (selected-frame))) '(x w32))
(if (memq (framep (or frame (selected-frame))) '(x w32 mac))
(xw-defined-colors frame)
(mapcar 'car (tty-color-alist frame))))
(defalias 'x-defined-colors 'defined-colors)
......@@ -1243,7 +1243,7 @@ If COLOR is the symbol `unspecified' or one of the strings
\"unspecified-fg\" or \"unspecified-bg\", the value is nil."
(if (member color '(unspecified "unspecified-bg" "unspecified-fg"))
nil
(if (member (framep (or frame (selected-frame))) '(x w32))
(if (member (framep (or frame (selected-frame))) '(x w32 mac))
(xw-color-defined-p color frame)
(numberp (tty-color-translate color frame)))))
(defalias 'x-color-defined-p 'color-defined-p)
......@@ -1258,7 +1258,7 @@ If COLOR is the symbol `unspecified' or one of the strings
\"unspecified-fg\" or \"unspecified-bg\", the value is nil."
(if (member color '(unspecified "unspecified-fg" "unspecified-bg"))
nil
(if (memq (framep (or frame (selected-frame))) '(x w32))
(if (memq (framep (or frame (selected-frame))) '(x w32 mac))
(xw-color-values color frame)
(tty-color-values color frame))))
(defalias 'x-color-values 'color-values)
......@@ -1268,7 +1268,7 @@ If COLOR is the symbol `unspecified' or one of the strings
The optional argument DISPLAY specifies which display to ask about.
DISPLAY should be either a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display."
(if (memq (framep-on-display display) '(x w32))
(if (memq (framep-on-display display) '(x w32 mac))
(xw-display-color-p display)
(tty-display-color-p display)))
(defalias 'x-display-color-p 'display-color-p)
......@@ -1445,7 +1445,7 @@ Initialize colors of certain faces from frame parameters."
(when spec
(face-spec-set face spec frame))
(internal-merge-in-global-face face frame)
(when (memq window-system '(x w32))
(when (memq window-system '(x w32 mac))
(make-face-x-resource-internal face frame))))
;; Initialize attributes from frame parameters.
......@@ -1527,7 +1527,7 @@ created."
(defface mode-line
'((((type x w32) (class color))
'((((type x w32 mac) (class color))
(:box (:line-width 2 :style released-button)
:background "grey75" :foreground "black"))
(t
......@@ -1572,7 +1572,7 @@ created."
(defface tool-bar
'((((type x w32) (class color))
'((((type x w32 mac) (class color))
(:box (:line-width 1 :style released-button)
:background "grey75" :foreground "black"))
(((type x) (class mono))
......
......@@ -1164,4 +1164,3 @@ If nil, don't show a cursor except in the selected window."
(provide 'frame)
;;; frame.el ends here
(frame-notice-user-settings):
......@@ -2427,7 +2427,7 @@ the variable `Info-file-list-for-emacs'."
;; This is a serious problem for trying to handle multiple
;; frame types at once. We want this text to be invisible
;; on frames that can display the font above.
(if (memq (framep (selected-frame)) '(x pc w32))
(if (memq (framep (selected-frame)) '(x pc w32 mac))
(add-text-properties (match-end 1) (match-end 2)
'(invisible t intangible t))))
(goto-char (point-min))
......
;;; mac-win.el --- support for "Macintosh windows".
;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
;; Author: Andrew Choi <akochoi@i-cable.com>
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Code:
;; ---------------------------------------------------------------------------
;; We want to delay setting frame parameters until the faces are setup
;; Mac can't handle ~ prefix in file names
;(setq auto-save-list-file-prefix ".saves-")
(setq frame-creation-function 'x-create-frame-with-faces)
;; for debugging
;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
(global-set-key
[vertical-scroll-bar down-mouse-1]
'mac-handle-scroll-bar-event)
(global-unset-key [vertical-scroll-bar drag-mouse-1])
(global-unset-key [vertical-scroll-bar mouse-1])
(defun mac-handle-scroll-bar-event (event)
"Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
(interactive "e")
(let* ((position (event-start event))
(window (nth 0 position))
(bar-part (nth 4 position)))
(select-window window)
(cond
((eq bar-part 'up)
(goto-char (window-start window))
(mac-scroll-down-line))
((eq bar-part 'above-handle)
(mac-scroll-down))
((eq bar-part 'handle)
(scroll-bar-drag event))
((eq bar-part 'below-handle)
(mac-scroll-up))
((eq bar-part 'down)
(goto-char (window-start window))
(mac-scroll-up-line)))))
(defun mac-scroll-down ()
(track-mouse
(while (not (eq (car-safe (read-event)) 'mouse-1)) nil)
(scroll-down)))
(defun mac-scroll-down-line ()
(track-mouse
(while (not (eq (car-safe (read-event)) 'mouse-1)) nil)
(scroll-down 1)))
(defun mac-scroll-up ()
(track-mouse
(while (not (eq (car-safe (read-event)) 'mouse-1)) nil)
(scroll-up)))
(defun mac-scroll-up-line ()
(track-mouse
(while (not (eq (car-safe (read-event)) 'mouse-1)) nil)
(scroll-up 1)))
(defun xw-defined-colors (&optional frame)
"Internal function called by `defined-colors', which see."
(or frame (setq frame (selected-frame)))
(let ((all-colors x-colors)
(this-color nil)
(defined-colors nil))
(while all-colors
(setq this-color (car all-colors)
all-colors (cdr all-colors))
(and (color-supported-p this-color frame t)
(setq defined-colors (cons this-color defined-colors))))
defined-colors))
;; Don't have this yet.
(fset 'x-get-resource 'ignore)
;; Use Lisp verison of ls instead of calling subprocess on ls (faster,
;; don't need to write ls).
(load "ls-lisp")
;; This variable specifies the Unix program to call (as a process) to
;; deteremine 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 dired-free-space-program nil)
;; 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")
;; 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)
;; Emacs must be told we're using an 8-bit code for file names.
;; Otherwise file names won't be displayed properly in dired mode,
;; etc.
(setq file-name-coding-system 'latin-1)
;; Setup to use the Mac clipboard. The functions mac-cut-function and
;; mac-paste-function are defined in mac.c.
(set-selection-coding-system 'compound-text-mac)
(setq interprogram-cut-function
'(lambda (str push)
(mac-cut-function
(encode-coding-string str selection-coding-system t) push)))
(setq interprogram-paste-function
'(lambda ()
(decode-coding-string
(mac-paste-function) selection-coding-system t)))
(defun mac-drag-n-drop (event)
"Edit the files listed in the drag-n-drop event.\n\
Switch to a buffer editing the last file dropped."
(interactive "e")
(save-excursion
;; Make sure the drop target has positive co-ords
;; before setting the selected frame - otherwise it
;; won't work. <skx@tardis.ed.ac.uk>
(let* ((window (posn-window (event-start event)))
(coords (posn-x-y (event-start event)))
(x (car coords))
(y (cdr coords)))
(if (and (> x 0) (> y 0))
(set-frame-selected-window nil window))
(mapcar 'find-file (car (cdr (cdr event)))))
(raise-frame)
(recenter)))
(global-set-key [drag-n-drop] 'mac-drag-n-drop)
; Tell event loop in macterm.c we are ready.
(setq mac-ready-for-drag-n-drop t)
; Define constant values to be set to mac-keyboard-text-encoding
(defconst kTextEncodingMacRoman 0)
(defconst kTextEncodingISOLatin1 513 "0x201")
(defconst kTextEncodingISOLatin2 514 "0x202")
;; Definitions for the Mac Roman character sets and coding system.
;; The Mac Roman encoding uses all 128 code points in the range 128 to
;; 255 for actual characters. Since Emacs cannot handle this many
;; code points as one character set, we divide it into two:
;; mac-roman-lower for code points 128 to 159 and mac-roman-upper for
;; code points 160 to 255.
(defvar mac-roman-lower-final-char
(get-unused-iso-final-char 1 96))
(defvar mac-roman-upper-final-char
(1+ mac-roman-lower-final-char))
(define-charset nil 'mac-roman-lower
(vector 1 96 1 0 mac-roman-lower-final-char 1
"Mac Roman lower" "Mac Roman lower" "Mac Roman lower"))
(define-charset nil 'mac-roman-upper
(vector 1 96 1 0 mac-roman-upper-final-char 1
"Mac Roman upper" "Mac Roman upper" "Mac Roman upper"))
;; Since Mac Roman does not follow the ISO 2022 standard and uses code
;; points in the range 128-159, it is necessary to define it as a
;; type-4 charset, with CCL programs and all.
(define-ccl-program decode-mac-roman
`(2
((loop
(read r0)
(if (r0 < 128) ;; ASCII
(if (r0 == ?\r) ;; assume such a file uses Mac EOL's
(write-repeat ?\n)
(write-repeat r0))
(if (r0 < 160) ;; lower
((r0 += 32)
(r1 = ,(charset-id 'mac-roman-lower))
(write-multibyte-character r1 r0)
(repeat))
((r1 = ,(charset-id 'mac-roman-upper)) ;; upper
(write-multibyte-character r1 r0)
(repeat)))))))
"CCL program to decode Mac Roman")
(define-ccl-program encode-mac-roman
`(1
((loop
(read-multibyte-character r0 r1)
(if (r0 == ,(charset-id 'ascii))
(if (r1 == ?\n)
(write-repeat ?\r)
(write-repeat r1))
(if (r0 == ,(charset-id 'mac-roman-lower))
((r1 += 96)
(write-repeat r1))
(if (r0 == ,(charset-id 'mac-roman-upper))
((r1 += 128)
(write-repeat r1))))))))
"CCL program to encode Mac Roman")
(make-coding-system
'mac-roman 4 ?M "Mac Roman Encoding"
'(decode-mac-roman . encode-mac-roman)
'((safe-charsets ascii mac-roman-lower mac-roman-upper)
(valid codes (0 . 255))))
;; This doesn't seem to do anything for type-4 charsets:
;; (put 'mac-roman 'eol-type (make-subsidiary-coding-system 'mac-roman))
(define-ccl-program ccl-encode-mac-roman-font
`(0
(if (r0 == ,(charset-id 'mac-roman-lower))
(r1 += 96)
(r1 += 128))))
(setq font-ccl-encoder-alist
(cons '("mac-roman" . ccl-encode-mac-roman-font)
font-ccl-encoder-alist))
(if (fboundp 'new-fontset)
(progn
(create-fontset-from-fontset-spec
"-etl-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-mac,
mac-roman-lower:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman,
mac-roman-upper:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman"
t)))
;; To display filenames in Chinese or Japanese, replace mac-roman with
;; big5 or sjis
(setq file-name-coding-system 'mac-roman)
;; (prefer-coding-system 'mac-roman)
(defun mac-roman-kbd-insert ()
"Insert a character in Mac Roman encoding at point.\n\
Called by keymap of Mac-kbd minor mode."
(interactive "*")
(let ((ch last-command-char))
(if (< ch 160)
(insert
(make-char 'mac-roman-lower
(- last-command-char 96)))
(insert
(make-char 'mac-roman-upper
(- last-command-char 128))))))
(defvar mac-roman-kbd-mode nil
"Non-nil if in Mac-kbd minor mode.")
(put 'mac-roman-kbd-mode 'permanent-local t)
(or (assq 'mac-roman-kbd-mode minor-mode-alist)
(setq minor-mode-alist
(cons '(mac-roman-kbd-mode " Mac-kbd") minor-mode-alist)))
(defvar mac-roman-kbd-mode-map
(let ((map (make-keymap))
(i 128))
(while (< i 256)
(define-key map (vector i) 'mac-roman-kbd-insert)
(setq i (1+ i)))
map)
"Keymap for Mac-kbd minor mode.")
(or (assq 'mac-roman-kbd-mode minor-mode-map-alist)
(setq minor-mode-map-alist
(cons (cons 'mac-roman-kbd-mode mac-roman-kbd-mode-map)
minor-mode-map-alist)))
(defun mac-roman-kbd-mode (&optional arg)
"Toggle Mac Roman Keyboard (Mac-kbd) minor mode.\n\
In this minor mode, characters in the range 128 to 255 generated by\n\
the Mac keyboard are inserted as mac-roman-lower or mac-roman-upper\n\
characters, in the mac-roman encoding.\n\
\n\
With an argument, a positive argument enables Mac Roman Keyboard mode,\n\
and a negative argument disables it."
(interactive "P")
(if (if arg
;; Negative arg means switch it off.
(<= (prefix-numeric-value arg) 0)
;; No arg means toggle.
mac-roman-kbd-mode)
(setq mac-roman-kbd-mode nil)
;; Enable mode.
(setq mac-roman-kbd-mode t)))
;;
;; Available colors
;;
(defvar x-colors '("LightGreen"
"light green"
"DarkRed"
"dark red"
"DarkMagenta"
"dark magenta"
"DarkCyan"
"dark cyan"
"DarkBlue"
"dark blue"
"DarkGray"
"dark gray"
"DarkGrey"
"dark grey"
"grey100"
"gray100"
"grey99"
"gray99"
"grey98"
"gray98"
"grey97"
"gray97"
"grey96"
"gray96"
"grey95"
"gray95"
"grey94"
"gray94"
"grey93"
"gray93"
"grey92"
"gray92"
"grey91"
"gray91"
"grey90"
"gray90"
"grey89"
"gray89"
"grey88"
"gray88"
"grey87"
"gray87"
"grey86"
"gray86"
"grey85"
"gray85"
"grey84"
"gray84"
"grey83"
"gray83"
"grey82"
"gray82"
"grey81"
"gray81"
"grey80"
"gray80"
"grey79"
"gray79"
"grey78"
"gray78"
"grey77"
"gray77"
"grey76"
"gray76"
"grey75"
"gray75"
"grey74"
"gray74"
"grey73"
"gray73"
"grey72"
"gray72"
"grey71"
"gray71"
"grey70"
"gray70"
"grey69"
"gray69"
"grey68"
"gray68"
"grey67"
"gray67"
"grey66"
"gray66"
"grey65"
"gray65"
"grey64"
"gray64"
"grey63"
"gray63"
"grey62"
"gray62"
"grey61"
"gray61"
"grey60"
"gray60"
"grey59"
"gray59"
"grey58"
"gray58"
"grey57"
"gray57"
"grey56"
"gray56"
"grey55"
"gray55"
"grey54"
"gray54"
"grey53"
"gray53"
"grey52"
"gray52"
"grey51"
"gray51"
"grey50"
"gray50"
"grey49"
"gray49"
"grey48"
"gray48"
"grey47"
"gray47"
"grey46"
"gray46"
"grey45"
"gray45"
"grey44"
"gray44"
"grey43"
"gray43"
"grey42"
"gray42"
"grey41"
"gray41"
"grey40"
"gray40"
"grey39"
"gray39"
"grey38"
"gray38"
"grey37"
"gray37"
"grey36"
"gray36"
"grey35"
"gray35"
"grey34"
"gray34"
"grey33"
"gray33"
"grey32"
"gray32"
"grey31"
"gray31"
"grey30"
"gray30"
"grey29"
"gray29"
"grey28"
"gray28"
"grey27"
"gray27"
"grey26"
"gray26"
"grey25"