comparison lisp/ediff/ediff-wind.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents e04119814345
children c7528f8e288d
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1 ;;; ediff-wind.el --- window manipulation utilities 1 ;;; ediff-wind.el --- window manipulation utilities
2 2
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4 4
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6 6
7 ;; This file is part of GNU Emacs. 7 ;; This file is part of GNU Emacs.
8 8
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA. 22 ;; Boston, MA 02111-1307, USA.
23 23
24 ;;; Code: 24 ;;; Code:
25 25
26 (provide 'ediff-wind) 26 (require 'ediff-init)
27 27
28 ;; Compiler pacifier 28 ;; Compiler pacifier
29 (defvar icon-title-format) 29 (defvar icon-title-format)
30 (defvar top-toolbar-height) 30 (defvar top-toolbar-height)
31 (defvar bottom-toolbar-height) 31 (defvar bottom-toolbar-height)
33 (defvar right-toolbar-height) 33 (defvar right-toolbar-height)
34 (defvar left-toolbar-width) 34 (defvar left-toolbar-width)
35 (defvar right-toolbar-width) 35 (defvar right-toolbar-width)
36 (defvar default-menubar) 36 (defvar default-menubar)
37 (defvar frame-icon-title-format) 37 (defvar frame-icon-title-format)
38 (defvar ediff-diff-status)
39
40 (eval-when-compile
41 (let ((load-path (cons (expand-file-name ".") load-path)))
42 (or (featurep 'ediff-init)
43 (load "ediff-init.el" nil nil 'nosuffix))
44 (or (featurep 'ediff-util)
45 (load "ediff-util.el" nil nil 'nosuffix))
46 (or (featurep 'ediff-help)
47 (load "ediff-help.el" nil nil 'nosuffix))
48 (or (featurep 'ediff-tbar)
49 (load "ediff-tbar.el" 'noerror nil 'nosuffix))
50 ))
51 ;; end pacifier 38 ;; end pacifier
52
53 (require 'ediff-init)
54
55 ;; be careful with ediff-tbar
56 (if ediff-xemacs-p
57 (condition-case nil
58 (require 'ediff-tbar)
59 (error
60 (defun ediff-compute-toolbar-width () 0)))
61 (defun ediff-compute-toolbar-width () 0))
62 39
63 40
64 (defvar ediff-window-setup-function (if (ediff-window-display-p) 41 (defvar ediff-window-setup-function (if (ediff-window-display-p)
65 'ediff-setup-windows-multiframe 42 'ediff-setup-windows-multiframe
66 'ediff-setup-windows-plain) 43 'ediff-setup-windows-plain)
533 (setq done-A t 510 (setq done-A t
534 done-B t))) 511 done-B t)))
535 512
536 (if use-same-frame 513 (if use-same-frame
537 (let ((window-min-height 1)) 514 (let ((window-min-height 1))
538 (if (and (eq frame-A frame-B) 515 ;; avoid dedicated and non-splittable windows
539 (eq frame-B frame-C) 516 (ediff-skip-unsuitable-frames)
540 (frame-live-p frame-A))
541 (select-frame frame-A)
542 ;; avoid dedicated and non-splittable windows
543 (ediff-skip-unsuitable-frames))
544 (delete-other-windows) 517 (delete-other-windows)
545 (setq merge-window-lines 518 (setq merge-window-lines
546 (max 2 (round (* (window-height) merge-window-share)))) 519 (max 2 (round (* (window-height) merge-window-share))))
547 (switch-to-buffer buf-A) 520 (switch-to-buffer buf-A)
548 (setq wind-A (selected-window)) 521 (setq wind-A (selected-window))
700 (setq wind-C (selected-window)) 673 (setq wind-C (selected-window))
701 (setq done-C t))) 674 (setq done-C t)))
702 675
703 (if use-same-frame 676 (if use-same-frame
704 (let (wind-width-or-height) ; this affects 3way setups only 677 (let (wind-width-or-height) ; this affects 3way setups only
705 (if (and (eq frame-A frame-B) (frame-live-p frame-A)) 678 ;; avoid dedicated and non-splittable windows
706 (select-frame frame-A) 679 (ediff-skip-unsuitable-frames)
707 ;; avoid dedicated and non-splittable windows
708 (ediff-skip-unsuitable-frames))
709 (delete-other-windows) 680 (delete-other-windows)
710 (switch-to-buffer buf-A) 681 (switch-to-buffer buf-A)
711 (setq wind-A (selected-window)) 682 (setq wind-A (selected-window))
712 683
713 (if three-way-comparison 684 (if three-way-comparison
880 dont-iconify-ctl-frame)) 851 dont-iconify-ctl-frame))
881 852
882 ;; 1 more line for the modeline 853 ;; 1 more line for the modeline
883 (setq lines (1+ (count-lines (point-min) (point-max))) 854 (setq lines (1+ (count-lines (point-min) (point-max)))
884 fheight lines 855 fheight lines
885 fwidth (max (+ (ediff-help-message-line-length) 2) 856 fwidth (+ (ediff-help-message-line-length) 2)
886 (ediff-compute-toolbar-width)) 857 adjusted-parameters (append (list
887 adjusted-parameters ;;(append 858 ;; possibly change surrogate minibuffer
888 (list 859 (cons 'minibuffer
889 ;; possibly change surrogate minibuffer 860 (minibuffer-window
890 (cons 'minibuffer 861 designated-minibuffer-frame))
891 (minibuffer-window 862 (cons 'width fwidth)
892 designated-minibuffer-frame)) 863 (cons 'height fheight))
893 (cons 'width fwidth) 864 (funcall
894 (cons 'height fheight)) 865 ediff-control-frame-position-function
895 ;;(funcall 866 ctl-buffer fwidth fheight)))
896 ;;ediff-control-frame-position-function
897 ;;ctl-buffer fwidth fheight)
898 ;;)
899 )
900 (if ediff-use-long-help-message 867 (if ediff-use-long-help-message
901 (setq adjusted-parameters 868 (setq adjusted-parameters
902 (cons '(auto-raise . nil) adjusted-parameters))) 869 (cons '(auto-raise . nil) adjusted-parameters)))
903 870
904 ;; In XEmacs, buffer menubar needs to be killed before frame parameters 871 ;; In XEmacs, buffer menubar needs to be killed before frame parameters
905 ;; are changed. 872 ;; are changed.
906 (if ediff-xemacs-p 873 (if ediff-xemacs-p
907 (progn 874 (progn
908 (set-specifier top-toolbar-height (list ctl-frame 2))
909 (sit-for 0)
910 (set-specifier top-toolbar-height (list ctl-frame 0)) 875 (set-specifier top-toolbar-height (list ctl-frame 0))
911 ;;(set-specifier bottom-toolbar-height (list ctl-frame 0)) 876 (set-specifier bottom-toolbar-height (list ctl-frame 0))
912 (set-specifier left-toolbar-width (list ctl-frame 0)) 877 (set-specifier left-toolbar-width (list ctl-frame 0))
913 (set-specifier right-toolbar-width (list ctl-frame 0)) 878 (set-specifier right-toolbar-width (list ctl-frame 0))
879 ;; XEmacs needed a redisplay, as it had trouble setting
880 ;; height correctly otherwise.
881 ;;(sit-for 0)
914 )) 882 ))
915 883
916 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order 884 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
917 ;; to make sure that at least once we do it for non-iconified frame. If 885 ;; to make sure that at least once we do it for non-iconified frame. If
918 ;; appears that in the OS/2 port of Emacs, one can't modify frame 886 ;; appears that in the OS/2 port of Emacs, one can't modify frame
919 ;; parameters of iconified frames. As a precaution, we do likewise for 887 ;; parameters of iconified frames. As a precaution, we do likewise for
920 ;; windows-nt. 888 ;; windows-nt.
921 (if (memq system-type '(emx windows-nt windows-95)) 889 (if (memq system-type '(emx windows-nt windows-95))
922 (modify-frame-parameters ctl-frame adjusted-parameters)) 890 (modify-frame-parameters ctl-frame adjusted-parameters))
923 891
924 ;; make or zap toolbar (if not requested)
925 (ediff-make-bottom-toolbar ctl-frame)
926
927 (goto-char (point-min)) 892 (goto-char (point-min))
928 893
929 (modify-frame-parameters ctl-frame adjusted-parameters) 894 (modify-frame-parameters ctl-frame adjusted-parameters)
930 (make-frame-visible ctl-frame) 895 (make-frame-visible ctl-frame)
931 896
932 ;; This works around a bug in 19.25 and earlier. There, if frame gets 897 ;; This works around a bug in 19.25 and earlier. There, if frame gets
933 ;; iconified, the current buffer changes to that of the frame that 898 ;; iconified, the current buffer changes to that of the frame that
941 (iconify-frame ctl-frame)) 906 (iconify-frame ctl-frame))
942 ((or deiconify-ctl-frame (not ctl-frame-iconified-p)) 907 ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
943 (raise-frame ctl-frame))) 908 (raise-frame ctl-frame)))
944 909
945 (set-window-dedicated-p (selected-window) t) 910 (set-window-dedicated-p (selected-window) t)
946
947 ;; Now move the frame. We must do it separately due to an obscure bug in
948 ;; XEmacs
949 (modify-frame-parameters
950 ctl-frame
951 (funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
952 911
953 ;; synchronize so the cursor will move to control frame 912 ;; synchronize so the cursor will move to control frame
954 ;; per RMS suggestion 913 ;; per RMS suggestion
955 (if (ediff-window-display-p) 914 (if (ediff-window-display-p)
956 (let ((count 7)) 915 (let ((count 7))
972 )) 931 ))
973 932
974 (ediff-eval-in-buffer ctl-buffer 933 (ediff-eval-in-buffer ctl-buffer
975 (run-hooks 'ediff-after-setup-control-frame-hook)) 934 (run-hooks 'ediff-after-setup-control-frame-hook))
976 )) 935 ))
977
978 936
979 (defun ediff-destroy-control-frame (ctl-buffer) 937 (defun ediff-destroy-control-frame (ctl-buffer)
980 (ediff-eval-in-buffer ctl-buffer 938 (ediff-eval-in-buffer ctl-buffer
981 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) 939 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
982 (let ((ctl-frame ediff-control-frame)) 940 (let ((ctl-frame ediff-control-frame))
1099 buf-B-state-diff "" 1057 buf-B-state-diff ""
1100 buf-C-state-diff "")) 1058 buf-C-state-diff ""))
1101 1059
1102 ;; control buffer format 1060 ;; control buffer format
1103 (setq mode-line-format 1061 (setq mode-line-format
1104 (if (ediff-narrow-control-frame-p) 1062 (list (if (ediff-narrow-control-frame-p) " " "-- ")
1105 (list " " mode-line-buffer-identification) 1063 mode-line-buffer-identification
1106 (list "-- " mode-line-buffer-identification " Quick Help"))) 1064 " Quick Help"))
1107 ;; control buffer id 1065 ;; control buffer id
1108 (setq mode-line-buffer-identification 1066 (setq mode-line-buffer-identification
1109 (if (ediff-narrow-control-frame-p) 1067 (if (ediff-narrow-control-frame-p)
1110 (ediff-make-narrow-control-buffer-id 'skip-name) 1068 (ediff-make-narrow-control-buffer-id 'skip-name)
1111 (ediff-make-wide-control-buffer-id))) 1069 (ediff-make-wide-control-buffer-id)))
1229 (eq (window-buffer A-wind) ediff-buffer-A) 1187 (eq (window-buffer A-wind) ediff-buffer-A)
1230 (eq (window-buffer B-wind) ediff-buffer-B) 1188 (eq (window-buffer B-wind) ediff-buffer-B)
1231 (or (not ediff-3way-job) 1189 (or (not ediff-3way-job)
1232 (eq (window-buffer C-wind) ediff-buffer-C)) 1190 (eq (window-buffer C-wind) ediff-buffer-C))
1233 (string= ediff-window-config-saved 1191 (string= ediff-window-config-saved
1234 (format "%S%S%S%S%S%S%S" 1192 (format "\%S\%S\%S\%S\%S\%S\%S"
1235 ctl-wind A-wind B-wind C-wind 1193 ctl-wind A-wind B-wind C-wind
1236 ediff-split-window-function 1194 ediff-split-window-function
1237 (ediff-multiframe-setup-p) 1195 (ediff-multiframe-setup-p)
1238 ediff-wide-display-p))))))) 1196 ediff-wide-display-p)))))))
1239 1197
1240 1198
1241 ;;; Local Variables: 1199 ;;; Local Variables:
1242 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) 1200 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1243 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) 1201 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
1244 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
1245 ;;; End: 1202 ;;; End:
1246 1203
1204 (provide 'ediff-wind)
1205
1206
1247 ;;; ediff-wind.el ends here 1207 ;;; ediff-wind.el ends here