;;; ediff-wind.el --- window manipulation utilities
-;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
;; 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; 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:
(require 'ediff-init)
In this case, Ediff will use those frames to display these buffers.")
(defconst ediff-control-frame-parameters
- (if (ediff-window-display-p)
- (list
- '(name . "Ediff")
- ;;'(unsplittable . t)
- '(minibuffer . nil)
- '(vertical-scroll-bars . nil) ; Emacs only
- '(scrollbar-width . 0) ; XEmacs only
- '(menu-bar-lines . 0) ; Emacs only
- ;; don't lower and auto-raise
- '(auto-lower . nil)
- '(auto-raise . t)
- ;; this blocks queries from window manager as to where to put
- ;; ediff's control frame. we put the frame outside the display,
- ;; so the initial frame won't jump all over the screen
- (cons 'top (if (fboundp 'ediff-display-pixel-height)
- (1+ (ediff-display-pixel-height))
- 3000))
- (cons 'left (if (fboundp 'ediff-display-pixel-width)
- (1+ (ediff-display-pixel-width))
- 3000))
- ))
+ (list
+ '(name . "Ediff")
+ ;;'(unsplittable . t)
+ '(minibuffer . nil)
+ '(user-position . t) ; Emacs only
+ '(vertical-scroll-bars . nil) ; Emacs only
+ '(scrollbar-width . 0) ; XEmacs only
+ '(menu-bar-lines . 0) ; Emacs only
+ '(visibility . nil) ; doesn't work for XEmacs yet
+ ;; don't lower and auto-raise
+ '(auto-lower . nil)
+ '(auto-raise . t)
+ ;; this blocks queries from window manager as to where to put
+ ;; ediff's control frame. we put the frame outside the display,
+ ;; so the initial frame won't jump all over the screen
+ (cons 'top (if (fboundp 'ediff-display-pixel-height)
+ (1+ (ediff-display-pixel-height))
+ 3000))
+ (cons 'left (if (fboundp 'ediff-display-pixel-width)
+ (1+ (ediff-display-pixel-width))
+ 3000))
+ )
"Frame parameters for displaying Ediff Control Panel.
Do not specify width and height here. These are computed automatically.")
+;; position of the mouse; used to decide whether to warp the mouse into ctl
+;; frame
+(ediff-defvar-local ediff-mouse-pixel-position nil "")
+
+;; not used for now
+(defvar ediff-mouse-pixel-threshold 30
+ "If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
+
+(defvar ediff-grab-mouse t
+ "*If t, Ediff will always grab the mouse and put it in the control frame.
+If 'maybe, Ediff will do it sometimes, but not after operations that require
+relatively long time. If nil, the mouse will be entirely user's
+responsibility.")
+
(defvar ediff-control-frame-position-function 'ediff-make-frame-position
"Function to call to determine the desired location for the control panel.
Expects three parameters: the control buffer, the desired width and height
of the control frame. It returns an association list
of the form \(\(top . <position>\) \(left . <position>\)\)")
-(defvar ediff-control-frame-upward-shift (if ediff-xemacs-p 36 4)
+(defvar ediff-control-frame-upward-shift (if ediff-xemacs-p 42 14)
"*The upward shift of control frame from the top of buffer A's frame.
Measured in pixels.
This is used by the default control frame positioning function,
(defvar ediff-prefer-iconified-control-frame nil
"*If t, keep control panel iconified when help message is off.
This has effect only on a windowing system.
-If t, hiting `?' to toggle control panel off iconifies it.
+If t, hitting `?' to toggle control panel off iconifies it.
This is only useful in Emacs and only for certain kinds of window managers,
such as TWM and its derivatives, since the window manager must permit
(defun ediff-setup-windows (buffer-A buffer-B buffer-C control-buffer)
;; Make sure we are not in the minibuffer window when we try to delete
;; all other windows.
- (run-hooks 'ediff-before-setup-windows-hooks)
+ (run-hooks 'ediff-before-setup-windows-hook)
(if (eq (selected-window) (minibuffer-window))
(other-window 1))
(funcall
(ediff-eval-in-buffer control-buffer ediff-window-setup-function)
buffer-A buffer-B buffer-C control-buffer))
- (run-hooks 'ediff-after-setup-windows-hooks))
+ (run-hooks 'ediff-after-setup-windows-hook))
;; Just set up 3 windows.
;; Usually used without windowing systems
(defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
;; skip dedicated and unsplittable frames
(ediff-destroy-control-frame control-buffer)
- (let ((window-min-height 2)
+ (let ((window-min-height 1)
split-window-function
merge-window-share merge-window-lines
wind-A wind-B wind-C)
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
- ;; XEmacs seems to have a lot of trouble with display
- ;; It won't set things right unless we tell it to sit still
- (if ediff-xemacs-p (sit-for 0))
+ ;; XEmacs used to have a lot of trouble with display
+ ;; It did't set things right unless we tell it to sit still
+ ;; 19.12 seems ok.
+ ;;(if ediff-xemacs-p (sit-for 0))
(split-window-vertically (max 2 (- (window-height) merge-window-lines)))
(if (eq (selected-window) wind-A)
(defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer)
;; skip dedicated and unsplittable frames
(ediff-destroy-control-frame control-buffer)
- (let ((window-min-height 2)
+ (let ((window-min-height 1)
split-window-function wind-width-or-height
three-way-comparison
wind-A-start wind-B-start wind-A wind-B wind-C)
(window-width wind-A))
3)))
- ;; XEmacs seems to have a lot of trouble with display
- ;; It won't set things right unless we tell it to sit still
- (if ediff-xemacs-p (sit-for 0))
+ ;; XEmacs used to have a lot of trouble with display
+ ;; It did't set things right unless we told it to sit still
+ ;; 19.12 seems ok.
+ ;;(if ediff-xemacs-p (sit-for 0))
(funcall split-window-function wind-width-or-height)
))
-;; dispatch the appropriate window setup function
+;; dispatch an appropriate window setup function
(defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
(ediff-eval-in-buffer control-buf
(setq ediff-multiframe t))
;; Unsplittable frames are taken care of later.
(ediff-skip-unsuitable-frames 'ok-unsplittable)
- (let* ((window-min-height 2)
+ (let* ((window-min-height 1)
(wind-A (ediff-get-visible-buffer-window buf-A))
(wind-B (ediff-get-visible-buffer-window buf-B))
(wind-C (ediff-get-visible-buffer-window buf-C))
(if use-same-frame
(let ((curr-frame (selected-frame))
- (window-min-height 2))
+ (window-min-height 1))
;; avoid dedicated and non-splittable windows
(ediff-skip-unsuitable-frames)
(or (eq curr-frame (selected-frame))
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
- ;; XEmacs seems to have a lot of trouble with display
- ;; It won't set things right unless we tell it to catch breath
- (if ediff-xemacs-p (sit-for 0))
+ ;; XEmacs used to have a lot of trouble with display
+ ;; It did't set things right unless we told it to catch breath
+ ;;(if ediff-xemacs-p (sit-for 0))
(split-window-vertically
(max 2 (- (window-height) merge-window-lines)))
;; Unsplittable frames are taken care of later.
(ediff-skip-unsuitable-frames 'ok-unsplittable)
- (let* ((window-min-height 2)
+ (let* ((window-min-height 1)
(wind-A (ediff-get-visible-buffer-window buf-A))
(wind-B (ediff-get-visible-buffer-window buf-B))
(wind-C (ediff-get-visible-buffer-window buf-C))
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
- ;; XEmacs seems to have a lot of trouble with display
- ;; It won't set things right unless we tell it to catch breath
- (if ediff-xemacs-p (sit-for 0))
+ ;; XEmacs used to have a lot of trouble with display
+ ;; It didn't set things right unless we told it to catch breath
+ ;;(if ediff-xemacs-p (sit-for 0))
(if three-way-comparison
(setq wind-width-or-height
(or
(window-dedicated-p (selected-window))
(ediff-frame-iconified-p (selected-frame))
+ (< (frame-height (selected-frame))
+ (* 3 window-min-height))
(if ok-unsplittable
nil
(ediff-frame-unsplittable-p (selected-frame)))))
;; fed up, no appropriate frame
(progn
;;(redraw-display)
- (select-frame (ediff-make-frame '((unsplittable)))))))))
+ (select-frame (make-frame '((unsplittable)))))))))
;; Prepare or refresh control frame
(defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
- (let ((window-min-height 2)
+ (let ((window-min-height 1)
ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
- ctl-frame old-ctl-frame lines
+ ctl-frame old-ctl-frame lines user-grabbed-mouse
fheight fwidth adjusted-parameters)
(ediff-eval-in-buffer ctl-buffer
(if ediff-xemacs-p (set-buffer-menubar nil))
- (run-hooks 'ediff-before-setup-control-frame-hooks))
+ ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
+ (run-hooks 'ediff-before-setup-control-frame-hook))
(setq old-ctl-frame (ediff-eval-in-buffer ctl-buffer ediff-control-frame))
- ;; Delete the old ctl frame and get a new ctl frame.
- ;; The old ctl frame is deleted to let emacs reset default minibuffer
- ;; frame or when the ctl frame needs to be moved.
- ;; The old frame isn't reused, since ediff-setup-control-frame is called
- ;; very rarely, so the overhead is minimal.
- (if (frame-live-p old-ctl-frame) (delete-frame old-ctl-frame))
- ;;(redraw-display)
- ;; new ctl frame should be created while ctl-buff is current, so that
- ;; the local default-minibuffer-frame will be consulted and
- ;; that ediff-control-frame-parameters will have the right value.
(ediff-eval-in-buffer ctl-buffer
- (let ((default-minibuffer-frame designated-minibuffer-frame))
- (setq ctl-frame (make-frame ediff-control-frame-parameters)
- ediff-control-frame ctl-frame)))
+ (setq ctl-frame (if (frame-live-p old-ctl-frame)
+ old-ctl-frame
+ (make-frame ediff-control-frame-parameters))
+ ediff-control-frame ctl-frame))
(setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
(select-frame ctl-frame)
(switch-to-buffer ctl-buffer))
;; must be before ediff-setup-control-buffer
- (if ediff-xemacs-p
- ;; just a precaution--we should be in ctl-buffer already
- (ediff-eval-in-buffer ctl-buffer
- (make-local-variable 'frame-title-format)
- (make-local-variable 'frame-icon-title-format)))
+ ;; just a precaution--we should be in ctl-buffer already
+ (ediff-eval-in-buffer ctl-buffer
+ (make-local-variable 'frame-title-format)
+ (make-local-variable 'frame-icon-title-format) ; XEmacs
+ (make-local-variable 'icon-title-format)) ; Emacs
(ediff-setup-control-buffer ctl-buffer)
(setq dont-iconify-ctl-frame
dont-iconify-ctl-frame))
;; 1 more line for the modeline
- (setq lines (if ediff-xemacs-p
- (+ 2 (count-lines (point-min) (point-max)))
- (1+ (count-lines (point-min) (point-max))))
+ (setq lines (1+ (count-lines (point-min) (point-max)))
fheight lines
fwidth (+ (ediff-help-message-line-length) 2)
adjusted-parameters (append (list
+ '(visibility . t)
+ ;; possibly change surrogate minibuffer
+ (cons 'minibuffer
+ (minibuffer-window
+ designated-minibuffer-frame))
(cons 'width fwidth)
(cons 'height fheight))
(funcall
ediff-control-frame-position-function
ctl-buffer fwidth fheight)))
+ (if ediff-use-long-help-message
+ (setq adjusted-parameters
+ (cons '(auto-raise . nil) adjusted-parameters)))
;; In XEmacs, buffer menubar needs to be killed before frame parameters
- ;; are changed. XEmacs needs to redisplay, as it has trouble setting
- ;; height correctly otherwise.
+ ;; are changed.
(if ediff-xemacs-p
(progn
(set-specifier top-toolbar-height (list ctl-frame 0))
(set-specifier bottom-toolbar-height (list ctl-frame 0))
(set-specifier left-toolbar-width (list ctl-frame 0))
(set-specifier right-toolbar-width (list ctl-frame 0))
- (sit-for 0)))
+ ;; XEmacs needed a redisplay, as it had trouble setting
+ ;; height correctly otherwise.
+ ;;(sit-for 0)
+ ))
- ;; Under OS/2 (emx) we have to call modify frame parameters twice, in
- ;; order to make sure that at least once we do it for non-iconified
- ;; frame. If appears that in the OS/2 port of Emacs, one can't modify
- ;; frame parameters of iconified frames.
- (if (eq system-type 'emx)
+ ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
+ ;; to make sure that at least once we do it for non-iconified frame. If
+ ;; appears that in the OS/2 port of Emacs, one can't modify frame
+ ;; parameters of iconified frames. As a precaution, we do likewise for
+ ;; windows-nt.
+ (if (memq system-type '(emx windows-nt windows-95))
(modify-frame-parameters ctl-frame adjusted-parameters))
(goto-char (point-min))
- (cond ((and ediff-prefer-iconified-control-frame
- (not ctl-frame-iconified-p)
- (not dont-iconify-ctl-frame))
- (iconify-frame ctl-frame))
- ((or deiconify-ctl-frame
- (not ctl-frame-iconified-p))
- (raise-frame ctl-frame)))
+ (modify-frame-parameters ctl-frame adjusted-parameters)
;; This works around a bug in 19.25 and earlier. There, if frame gets
;; iconified, the current buffer changes to that of the frame that
(select-frame ctl-frame)
(ediff-refresh-control-frame)
- (modify-frame-parameters ctl-frame adjusted-parameters)
+ (cond ((and ediff-prefer-iconified-control-frame
+ (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
+ (iconify-frame ctl-frame))
+ ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
+ (raise-frame ctl-frame)))
(if ediff-xemacs-p
(set-window-buffer-dedicated (selected-window) ctl-buffer)
(set-window-dedicated-p (selected-window) t))
- (or ediff-xemacs-p (sit-for 0 200)) ; emacs has trouble here, needs time
+ ;; resynch so the cursor will move to control frame
+ ;; per RMS suggestion
+ (if (ediff-window-display-p)
+ (let ((count 7))
+ (sit-for .1)
+ (while (and (not (frame-visible-p ctl-frame)) (> count 0))
+ (setq count (1- count))
+ (sit-for .3))))
+
(or (ediff-frame-iconified-p ctl-frame)
- (ediff-reset-mouse ctl-frame))
- (or ediff-xemacs-p (unfocus-frame))
+ ;; don't warp the mouse, unless ediff-grab-mouse = t
+ (ediff-reset-mouse ctl-frame
+ (or (eq this-command 'ediff-quit)
+ (not (eq ediff-grab-mouse t)))))
(if ediff-xemacs-p
(ediff-eval-in-buffer ctl-buffer
))
(ediff-eval-in-buffer ctl-buffer
- (run-hooks 'ediff-after-setup-control-frame-hooks))
+ (run-hooks 'ediff-after-setup-control-frame-hook))
))
(defun ediff-destroy-control-frame (ctl-buffer)
(let ((ctl-frame ediff-control-frame))
(if ediff-xemacs-p
(set-buffer-menubar default-menubar))
- ;;(redraw-display)
(setq ediff-control-frame nil)
(delete-frame ctl-frame)
)))
(ediff-skip-unsuitable-frames)
- (ediff-reset-mouse))
+ ;;(ediff-reset-mouse nil)
+ )
;; finds a good place to clip control frame
(ediff-eval-in-buffer ctl-buffer
(let* ((frame-A (window-frame ediff-window-A))
(frame-A-parameters (frame-parameters frame-A))
- (frame-A-top (cdr (assoc 'top frame-A-parameters)))
- (frame-A-left (cdr (assoc 'left frame-A-parameters)))
+ (frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
+ (frame-A-left (eval (cdr (assoc 'left frame-A-parameters))))
(frame-A-width (frame-width frame-A))
(ctl-frame ediff-control-frame)
horizontal-adjustment upward-adjustment
- ctl-frame-top)
+ ctl-frame-top ctl-frame-left)
;; Multiple control frames are clipped based on the value of
;; ediff-control-buffer-number. This is done in order not to obscure
(setq horizontal-adjustment (* 2 ediff-control-buffer-number)
upward-adjustment (* -14 ediff-control-buffer-number))
- (setq ctl-frame-top (- frame-A-top
- upward-adjustment
- ediff-control-frame-upward-shift))
- (list
- (cons 'top (if (> ctl-frame-top 0) ctl-frame-top 1))
- (cons 'left (+ frame-A-left
- (if ediff-prefer-long-help-message
- (* (ediff-frame-char-width ctl-frame)
- (+ ediff-wide-control-frame-rightward-shift
- horizontal-adjustment))
- (- (* frame-A-width
- (ediff-frame-char-width frame-A))
- (* (ediff-frame-char-width ctl-frame)
- (+ ctl-frame-width
- ediff-narrow-control-frame-leftward-shift
- horizontal-adjustment))))))))))
+ (setq ctl-frame-top
+ (- frame-A-top upward-adjustment ediff-control-frame-upward-shift)
+ ctl-frame-left
+ (+ frame-A-left
+ (if ediff-use-long-help-message
+ (* (ediff-frame-char-width ctl-frame)
+ (+ ediff-wide-control-frame-rightward-shift
+ horizontal-adjustment))
+ (- (* frame-A-width (ediff-frame-char-width frame-A))
+ (* (ediff-frame-char-width ctl-frame)
+ (+ ctl-frame-width
+ ediff-narrow-control-frame-leftward-shift
+ horizontal-adjustment))))))
+ (setq ctl-frame-top
+ (min ctl-frame-top
+ (- (ediff-display-pixel-height)
+ (* 2 ctl-frame-height
+ (ediff-frame-char-height ctl-frame))))
+ ctl-frame-left
+ (min ctl-frame-left
+ (- (ediff-display-pixel-width)
+ (* ctl-frame-width (ediff-frame-char-width ctl-frame)))))
+ ;; keep ctl frame within the visible bounds
+ (setq ctl-frame-top (max ctl-frame-top 1)
+ ctl-frame-left (max ctl-frame-left 1))
+
+ (list (cons 'top ctl-frame-top)
+ (cons 'left ctl-frame-left))
+ )))
(defun ediff-xemacs-select-frame-hook ()
- (if (equal (selected-frame) ediff-control-frame)
+ (if (and (equal (selected-frame) ediff-control-frame)
+ (not ediff-use-long-help-message))
(raise-frame ediff-control-frame)))
(defun ediff-make-wide-display ()
(cw (ediff-frame-char-width frame-A))
(wd (- (/ (ediff-display-pixel-width) cw) 5)))
(setq ediff-wide-display-orig-parameters
- (list (cons 'left (max 0 (cdr (assoc 'left frame-A-params))))
+ (list (cons 'left (max 0 (eval (cdr (assoc 'left frame-A-params)))))
(cons 'width (cdr (assoc 'width frame-A-params))))
ediff-wide-display-frame frame-A)
(modify-frame-parameters frame-A (list (cons 'left cw)
"")
buf-C-state-diff (if (and (ediff-buffer-live-p ediff-buffer-C)
(or buf-C-state-diff buf-C-state-merge))
- (format "[%s%s] "
+ (format "[%s%s%s] "
(or buf-C-state-diff "")
(if buf-C-state-merge
(concat " " buf-C-state-merge)
- ""))
+ "")
+ (if (ediff-get-state-of-ancestor
+ ediff-current-difference)
+ " AncestorEmpty"
+ "")
+ )
""))
(setq buf-A-state-diff ""
buf-B-state-diff ""
(setq mode-line-format
(list " C: " 'ediff-diff-status mode-line-format))
(force-mode-line-update)))
+ (if (ediff-buffer-live-p ediff-ancestor-buffer)
+ (ediff-eval-in-buffer ediff-ancestor-buffer
+ (ediff-strip-mode-line-format)
+ ;; we keep the second dummy string in the mode line format of the
+ ;; ancestor, since for other buffers Ediff prepends 2 strings and
+ ;; ediff-strip-mode-line-format expects that.
+ (setq mode-line-format
+ (list " Ancestor: "
+ (cond ((not (stringp buf-C-state-merge))
+ "")
+ ((string-match "prefer-A" buf-C-state-merge)
+ "[=diff(B)] ")
+ ((string-match "prefer-B" buf-C-state-merge)
+ "[=diff(A)] ")
+ (t ""))
+ mode-line-format))))
))
(defun ediff-refresh-control-frame ()
- (if ediff-xemacs-p
- (progn
- (setq frame-title-format (ediff-make-narrow-control-buffer-id)
- frame-icon-title-format (ediff-make-narrow-control-buffer-id))
- ;; this forces update of the frame title
- (modify-frame-parameters ediff-control-frame '(())))
- (modify-frame-parameters
- ediff-control-frame
- (list (cons 'name (ediff-make-narrow-control-buffer-id))))
- ))
+ (setq frame-title-format (ediff-make-narrow-control-buffer-id)
+ frame-icon-title-format (ediff-make-narrow-control-buffer-id) ; XEmacs
+ icon-title-format (ediff-make-narrow-control-buffer-id)) ; Emacs
+ ;; the emacs part will be modified once the 'name and 'title
+ ;; frame parameters are separated
+ (if ediff-emacs-p
+ (modify-frame-parameters
+ ediff-control-frame
+ (list (cons 'name (ediff-make-narrow-control-buffer-id))))
+ ;; force an update of the frame title
+ (modify-frame-parameters ediff-control-frame '(()))))
(defun ediff-make-narrow-control-buffer-id (&optional skip-name)