0
|
1 ;;; ediff-wind.el --- window manipulation utilities
|
|
2
|
16
|
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
0
|
4
|
|
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
|
|
6
|
|
7 ;; This file is part of GNU Emacs.
|
|
8
|
|
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
|
23
|
|
24 ;;; Code:
|
14
|
25
|
|
26 (provide 'ediff-wind)
|
0
|
27
|
|
28 ;; Compiler pacifier
|
|
29 (defvar icon-title-format)
|
|
30 (defvar top-toolbar-height)
|
|
31 (defvar bottom-toolbar-height)
|
|
32 (defvar left-toolbar-height)
|
|
33 (defvar right-toolbar-height)
|
|
34 (defvar left-toolbar-width)
|
|
35 (defvar right-toolbar-width)
|
|
36 (defvar default-menubar)
|
|
37 (defvar frame-icon-title-format)
|
14
|
38 (defvar ediff-diff-status)
|
|
39
|
|
40 (eval-when-compile
|
16
|
41 (let ((load-path (cons (expand-file-name ".") load-path)))
|
14
|
42 (or (featurep 'ediff-init)
|
|
43 (load "ediff-init.el" nil nil 'nosuffix))
|
16
|
44 (or (featurep 'ediff-util)
|
|
45 (load "ediff-util.el" nil nil 'nosuffix))
|
14
|
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 ))
|
0
|
51 ;; end pacifier
|
|
52
|
14
|
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
|
0
|
63
|
|
64 (defvar ediff-window-setup-function (if (ediff-window-display-p)
|
|
65 'ediff-setup-windows-multiframe
|
|
66 'ediff-setup-windows-plain)
|
|
67 "*Function called to set up windows.
|
|
68 Ediff provides a choice of two functions: ediff-setup-windows-plain, for
|
|
69 doing everything in one frame, and ediff-setup-windows-multiframe,
|
|
70 which sets the control panel in a separate frame. Also, if the latter
|
|
71 function detects that one of the buffers A/B is seen in some other frame,
|
|
72 it will try to keep that buffer in that frame.
|
|
73
|
|
74 If you don't like the two functions provided---write your own one.
|
|
75 The basic guidelines:
|
|
76 1. It should leave the control buffer current and the control window
|
|
77 selected.
|
|
78 2. It should set ediff-window-A, ediff-window-B, ediff-window-C,
|
|
79 and ediff-control-window to contain window objects that display
|
|
80 the corresponding buffers.
|
|
81 3. It should accept the following arguments:
|
|
82 buffer-A, buffer-B, buffer-C, control-buffer
|
|
83 Buffer C may not be used in jobs that compare only two buffers.
|
|
84 If you plan to do something fancy, take a close look at how the two
|
|
85 provided functions are written.")
|
|
86
|
|
87 ;; indicates if we are in a multiframe setup
|
|
88 (ediff-defvar-local ediff-multiframe nil "")
|
|
89
|
|
90 ;; Share of the frame occupied by the merge window (buffer C)
|
|
91 (ediff-defvar-local ediff-merge-window-share 0.45 "")
|
|
92
|
|
93 ;; The control window.
|
|
94 (ediff-defvar-local ediff-control-window nil "")
|
|
95 ;; Official window for buffer A
|
|
96 (ediff-defvar-local ediff-window-A nil "")
|
|
97 ;; Official window for buffer B
|
|
98 (ediff-defvar-local ediff-window-B nil "")
|
|
99 ;; Official window for buffer C
|
|
100 (ediff-defvar-local ediff-window-C nil "")
|
|
101 ;; Ediff's window configuration.
|
|
102 ;; Used to minimize the need to rearrange windows.
|
|
103 (ediff-defvar-local ediff-window-config-saved "" "")
|
|
104
|
|
105
|
|
106 (defvar ediff-split-window-function 'split-window-vertically
|
|
107 "*The function used to split the main window between buffer-A and buffer-B.
|
|
108 You can set it to a horizontal split instead of the default vertical split
|
|
109 by setting this variable to `split-window-horizontally'.
|
|
110 You can also have your own function to do fancy splits.
|
|
111 This variable has no effect when buffer-A/B are shown in different frames.
|
|
112 In this case, Ediff will use those frames to display these buffers.")
|
|
113
|
|
114 (defvar ediff-merge-split-window-function 'split-window-horizontally
|
|
115 "*The function used to split the main window between buffer-A and buffer-B.
|
|
116 You can set it to a vertical split instead of the default horizontal split
|
|
117 by setting this variable to `split-window-vertically'.
|
|
118 You can also have your own function to do fancy splits.
|
|
119 This variable has no effect when buffer-A/B/C are shown in different frames.
|
|
120 In this case, Ediff will use those frames to display these buffers.")
|
|
121
|
|
122 (defconst ediff-control-frame-parameters
|
|
123 (list
|
|
124 '(name . "Ediff")
|
|
125 ;;'(unsplittable . t)
|
|
126 '(minibuffer . nil)
|
|
127 '(user-position . t) ; Emacs only
|
|
128 '(vertical-scroll-bars . nil) ; Emacs only
|
|
129 '(scrollbar-width . 0) ; XEmacs only
|
|
130 '(menu-bar-lines . 0) ; Emacs only
|
|
131 ;; don't lower and auto-raise
|
|
132 '(auto-lower . nil)
|
|
133 '(auto-raise . t)
|
|
134 ;; this blocks queries from window manager as to where to put
|
|
135 ;; ediff's control frame. we put the frame outside the display,
|
|
136 ;; so the initial frame won't jump all over the screen
|
|
137 (cons 'top (if (fboundp 'ediff-display-pixel-height)
|
|
138 (1+ (ediff-display-pixel-height))
|
|
139 3000))
|
|
140 (cons 'left (if (fboundp 'ediff-display-pixel-width)
|
|
141 (1+ (ediff-display-pixel-width))
|
|
142 3000))
|
|
143 )
|
|
144 "Frame parameters for displaying Ediff Control Panel.
|
|
145 Do not specify width and height here. These are computed automatically.")
|
|
146
|
|
147 ;; position of the mouse; used to decide whether to warp the mouse into ctl
|
|
148 ;; frame
|
|
149 (ediff-defvar-local ediff-mouse-pixel-position nil "")
|
|
150
|
|
151 ;; not used for now
|
|
152 (defvar ediff-mouse-pixel-threshold 30
|
|
153 "If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
|
|
154
|
|
155 (defvar ediff-grab-mouse t
|
|
156 "*If t, Ediff will always grab the mouse and put it in the control frame.
|
|
157 If 'maybe, Ediff will do it sometimes, but not after operations that require
|
|
158 relatively long time. If nil, the mouse will be entirely user's
|
|
159 responsibility.")
|
|
160
|
|
161 (defvar ediff-control-frame-position-function 'ediff-make-frame-position
|
|
162 "Function to call to determine the desired location for the control panel.
|
|
163 Expects three parameters: the control buffer, the desired width and height
|
|
164 of the control frame. It returns an association list
|
|
165 of the form \(\(top . <position>\) \(left . <position>\)\)")
|
|
166
|
|
167 (defvar ediff-control-frame-upward-shift (if ediff-xemacs-p 42 14)
|
|
168 "*The upward shift of control frame from the top of buffer A's frame.
|
|
169 Measured in pixels.
|
|
170 This is used by the default control frame positioning function,
|
|
171 `ediff-make-frame-position'. This variable is provided for easy
|
|
172 customization of the default.")
|
|
173
|
|
174 (defvar ediff-narrow-control-frame-leftward-shift (if ediff-xemacs-p 7 3)
|
|
175 "*The leftward shift of control frame from the right edge of buf A's frame.
|
|
176 Measured in characters.
|
|
177 This is used by the default control frame positioning function,
|
|
178 `ediff-make-frame-position' to adjust the position of the control frame
|
|
179 when it shows the short menu. This variable is provided for easy
|
|
180 customization of the default.")
|
|
181
|
|
182 (defvar ediff-wide-control-frame-rightward-shift 7
|
|
183 "*The rightward shift of control frame from the left edge of buf A's frame.
|
|
184 Measured in characters.
|
|
185 This is used by the default control frame positioning function,
|
|
186 `ediff-make-frame-position' to adjust the position of the control frame
|
|
187 when it shows the full menu. This variable is provided for easy
|
|
188 customization of the default.")
|
|
189
|
|
190
|
|
191 ;; Wide frame display
|
|
192
|
|
193 ;; t means Ediff is using wide display
|
|
194 (ediff-defvar-local ediff-wide-display-p nil "")
|
|
195 ;; keeps frame config for toggling wide display
|
|
196 (ediff-defvar-local ediff-wide-display-orig-parameters nil
|
|
197 "Frame parameters to be restored when the user wants to toggle the wide
|
|
198 display off.")
|
|
199 (ediff-defvar-local ediff-wide-display-frame nil
|
|
200 "Frame to be used for wide display.")
|
|
201 (ediff-defvar-local ediff-make-wide-display-function 'ediff-make-wide-display
|
|
202 "The value is a function that is called to create a wide display.
|
|
203 The function is called without arguments. It should resize the frame in
|
|
204 which buffers A, B, and C are to be displayed, and it should save the old
|
|
205 frame parameters in `ediff-wide-display-orig-parameters'.
|
|
206 The variable `ediff-wide-display-frame' should be set to contain
|
|
207 the frame used for the wide display.")
|
|
208
|
|
209 ;; Frame used for the control panel in a windowing system.
|
|
210 (ediff-defvar-local ediff-control-frame nil "")
|
|
211
|
|
212 (defvar ediff-prefer-iconified-control-frame nil
|
|
213 "*If t, keep control panel iconified when help message is off.
|
|
214 This has effect only on a windowing system.
|
|
215 If t, hitting `?' to toggle control panel off iconifies it.
|
|
216
|
|
217 This is only useful in Emacs and only for certain kinds of window managers,
|
|
218 such as TWM and its derivatives, since the window manager must permit
|
|
219 keyboard input to go into icons. XEmacs completely ignores keyboard input
|
|
220 into icons, regardless of the window manager.")
|
|
221
|
|
222 ;;; Functions
|
|
223
|
|
224 (defun ediff-get-window-by-clicking (wind prev-wind wind-number)
|
|
225 (let (event)
|
|
226 (message
|
|
227 "Select windows by clicking. Please click on Window %d " wind-number)
|
|
228 (while (not (ediff-mouse-event-p (setq event (ediff-read-event))))
|
|
229 (if (sit-for 1) ; if sequence of events, wait till the final word
|
|
230 (beep 1))
|
|
231 (message "Please click on Window %d " wind-number))
|
|
232 (ediff-read-event) ; discard event
|
|
233 (setq wind (if ediff-xemacs-p
|
|
234 (event-window event)
|
|
235 (posn-window (event-start event))))
|
|
236 ))
|
|
237
|
|
238
|
|
239 ;; Select the lowest window on the frame.
|
|
240 (defun ediff-select-lowest-window ()
|
|
241 (if ediff-xemacs-p
|
|
242 (select-window (frame-lowest-window))
|
|
243 (let* ((lowest-window (selected-window))
|
|
244 (bottom-edge (car (cdr (cdr (cdr (window-edges))))))
|
|
245 (last-window (save-excursion
|
|
246 (other-window -1) (selected-window)))
|
|
247 (window-search t))
|
|
248 (while window-search
|
|
249 (let* ((this-window (next-window))
|
|
250 (next-bottom-edge
|
|
251 (car (cdr (cdr (cdr (window-edges this-window)))))))
|
|
252 (if (< bottom-edge next-bottom-edge)
|
|
253 (progn
|
|
254 (setq bottom-edge next-bottom-edge)
|
|
255 (setq lowest-window this-window)))
|
|
256
|
|
257 (select-window this-window)
|
|
258 (if (eq last-window this-window)
|
|
259 (progn
|
|
260 (select-window lowest-window)
|
|
261 (setq window-search nil))))))))
|
|
262
|
|
263
|
|
264 ;;; Common window setup routines
|
|
265
|
|
266 ;; Set up the window configuration. If POS is given, set the points to
|
|
267 ;; the beginnings of the buffers.
|
|
268 ;; When 3way comparison is added, this will have to choose the appropriate
|
|
269 ;; setup function based on ediff-job-name
|
|
270 (defun ediff-setup-windows (buffer-A buffer-B buffer-C control-buffer)
|
|
271 ;; Make sure we are not in the minibuffer window when we try to delete
|
|
272 ;; all other windows.
|
|
273 (run-hooks 'ediff-before-setup-windows-hook)
|
|
274 (if (eq (selected-window) (minibuffer-window))
|
|
275 (other-window 1))
|
|
276
|
|
277 ;; in case user did a no-no on a tty
|
|
278 (or (ediff-window-display-p)
|
|
279 (setq ediff-window-setup-function 'ediff-setup-windows-plain))
|
|
280
|
|
281 (or (ediff-keep-window-config control-buffer)
|
|
282 (funcall
|
|
283 (ediff-eval-in-buffer control-buffer ediff-window-setup-function)
|
|
284 buffer-A buffer-B buffer-C control-buffer))
|
|
285 (run-hooks 'ediff-after-setup-windows-hook))
|
|
286
|
|
287 ;; Just set up 3 windows.
|
|
288 ;; Usually used without windowing systems
|
|
289 ;; With windowing, we want to use dedicated frames.
|
|
290 (defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer)
|
|
291 (ediff-eval-in-buffer control-buffer
|
|
292 (setq ediff-multiframe nil))
|
|
293 (if ediff-merge-job
|
|
294 (ediff-setup-windows-plain-merge
|
|
295 buffer-A buffer-B buffer-C control-buffer)
|
|
296 (ediff-setup-windows-plain-compare
|
|
297 buffer-A buffer-B buffer-C control-buffer)))
|
|
298
|
|
299 (defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
|
|
300 ;; skip dedicated and unsplittable frames
|
|
301 (ediff-destroy-control-frame control-buffer)
|
|
302 (let ((window-min-height 1)
|
|
303 split-window-function
|
|
304 merge-window-share merge-window-lines
|
|
305 wind-A wind-B wind-C)
|
|
306 (ediff-eval-in-buffer control-buffer
|
|
307 (setq merge-window-share ediff-merge-window-share
|
|
308 ;; this lets us have local versions of ediff-split-window-function
|
|
309 split-window-function ediff-split-window-function))
|
|
310 (delete-other-windows)
|
|
311 (split-window-vertically)
|
|
312 (ediff-select-lowest-window)
|
|
313 (ediff-setup-control-buffer control-buffer)
|
|
314
|
|
315 ;; go to the upper window and split it betw A, B, and possibly C
|
|
316 (other-window 1)
|
|
317 (setq merge-window-lines
|
|
318 (max 2 (round (* (window-height) merge-window-share))))
|
|
319 (switch-to-buffer buf-A)
|
|
320 (setq wind-A (selected-window))
|
|
321
|
|
322 ;; XEmacs used to have a lot of trouble with display
|
|
323 ;; It did't set things right unless we tell it to sit still
|
|
324 ;; 19.12 seems ok.
|
|
325 ;;(if ediff-xemacs-p (sit-for 0))
|
|
326
|
|
327 (split-window-vertically (max 2 (- (window-height) merge-window-lines)))
|
|
328 (if (eq (selected-window) wind-A)
|
|
329 (other-window 1))
|
|
330 (setq wind-C (selected-window))
|
|
331 (switch-to-buffer buf-C)
|
|
332
|
|
333 (select-window wind-A)
|
|
334 (funcall split-window-function)
|
|
335
|
|
336 (if (eq (selected-window) wind-A)
|
|
337 (other-window 1))
|
|
338 (switch-to-buffer buf-B)
|
|
339 (setq wind-B (selected-window))
|
|
340
|
|
341 (ediff-eval-in-buffer control-buffer
|
|
342 (setq ediff-window-A wind-A
|
|
343 ediff-window-B wind-B
|
|
344 ediff-window-C wind-C))
|
|
345
|
|
346 (ediff-select-lowest-window)
|
|
347 (ediff-setup-control-buffer control-buffer)
|
|
348 ))
|
|
349
|
|
350
|
|
351 ;; This function handles all comparison jobs, including 3way jobs
|
|
352 (defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer)
|
|
353 ;; skip dedicated and unsplittable frames
|
|
354 (ediff-destroy-control-frame control-buffer)
|
|
355 (let ((window-min-height 1)
|
|
356 split-window-function wind-width-or-height
|
|
357 three-way-comparison
|
|
358 wind-A-start wind-B-start wind-A wind-B wind-C)
|
|
359 (ediff-eval-in-buffer control-buffer
|
|
360 (setq wind-A-start (ediff-overlay-start
|
|
361 (ediff-get-value-according-to-buffer-type
|
|
362 'A ediff-narrow-bounds))
|
|
363 wind-B-start (ediff-overlay-start
|
|
364 (ediff-get-value-according-to-buffer-type
|
|
365 'B ediff-narrow-bounds))
|
|
366 ;; this lets us have local versions of ediff-split-window-function
|
|
367 split-window-function ediff-split-window-function
|
|
368 three-way-comparison ediff-3way-comparison-job))
|
|
369 (delete-other-windows)
|
|
370 (split-window-vertically)
|
|
371 (ediff-select-lowest-window)
|
|
372 (ediff-setup-control-buffer control-buffer)
|
|
373
|
|
374 ;; go to the upper window and split it betw A, B, and possibly C
|
|
375 (other-window 1)
|
|
376 (switch-to-buffer buf-A)
|
|
377 (setq wind-A (selected-window))
|
|
378 (if three-way-comparison
|
|
379 (setq wind-width-or-height
|
|
380 (/ (if (eq split-window-function 'split-window-vertically)
|
|
381 (window-height wind-A)
|
|
382 (window-width wind-A))
|
|
383 3)))
|
|
384
|
|
385 ;; XEmacs used to have a lot of trouble with display
|
|
386 ;; It did't set things right unless we told it to sit still
|
|
387 ;; 19.12 seems ok.
|
|
388 ;;(if ediff-xemacs-p (sit-for 0))
|
|
389
|
|
390 (funcall split-window-function wind-width-or-height)
|
|
391
|
|
392 (if (eq (selected-window) wind-A)
|
|
393 (other-window 1))
|
|
394 (switch-to-buffer buf-B)
|
|
395 (setq wind-B (selected-window))
|
|
396
|
|
397 (if three-way-comparison
|
|
398 (progn
|
|
399 (funcall split-window-function) ; equally
|
|
400 (if (eq (selected-window) wind-B)
|
|
401 (other-window 1))
|
|
402 (switch-to-buffer buf-C)
|
|
403 (setq wind-C (selected-window))))
|
|
404
|
|
405 (ediff-eval-in-buffer control-buffer
|
|
406 (setq ediff-window-A wind-A
|
|
407 ediff-window-B wind-B
|
|
408 ediff-window-C wind-C))
|
|
409
|
|
410 ;; It is unlikely that we will want to implement 3way window comparison.
|
|
411 ;; So, only buffers A and B are used here.
|
|
412 (if ediff-windows-job
|
|
413 (progn
|
|
414 (set-window-start wind-A wind-A-start)
|
|
415 (set-window-start wind-B wind-B-start)))
|
|
416
|
|
417 (ediff-select-lowest-window)
|
|
418 (ediff-setup-control-buffer control-buffer)
|
|
419 ))
|
|
420
|
|
421
|
|
422 ;; dispatch an appropriate window setup function
|
|
423 (defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
|
|
424 (ediff-eval-in-buffer control-buf
|
|
425 (setq ediff-multiframe t))
|
|
426 (if ediff-merge-job
|
|
427 (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
|
|
428 (ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf)))
|
|
429
|
|
430 (defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf)
|
|
431 ;;; Algorithm:
|
|
432 ;;; 1. Never use frames that have dedicated windows in them---it is bad to
|
|
433 ;;; destroy dedicated windows.
|
|
434 ;;; 2. If A and B are in the same frame but C's frame is different--- use one
|
|
435 ;;; frame for A and B and use a separate frame for C.
|
|
436 ;;; 3. If C's frame is non-existent, then: if the first suitable
|
|
437 ;;; non-dedicated frame is different from A&B's, then use it for C.
|
|
438 ;;; Otherwise, put A,B, and C in one frame.
|
|
439 ;;; 4. If buffers A, B, C are is separate frames, use them to display these
|
|
440 ;;; buffers.
|
|
441
|
|
442 ;; Skip dedicated or iconified frames.
|
|
443 ;; Unsplittable frames are taken care of later.
|
|
444 (ediff-skip-unsuitable-frames 'ok-unsplittable)
|
|
445
|
|
446 (let* ((window-min-height 1)
|
|
447 (wind-A (ediff-get-visible-buffer-window buf-A))
|
|
448 (wind-B (ediff-get-visible-buffer-window buf-B))
|
|
449 (wind-C (ediff-get-visible-buffer-window buf-C))
|
|
450 (frame-A (if wind-A (window-frame wind-A)))
|
|
451 (frame-B (if wind-B (window-frame wind-B)))
|
|
452 (frame-C (if wind-C (window-frame wind-C)))
|
|
453 ;; on wide display, do things in one frame
|
|
454 (force-one-frame
|
|
455 (ediff-eval-in-buffer control-buf ediff-wide-display-p))
|
|
456 ;; this lets us have local versions of ediff-split-window-function
|
|
457 (split-window-function
|
|
458 (ediff-eval-in-buffer control-buf ediff-split-window-function))
|
|
459 (orig-wind (selected-window))
|
|
460 (orig-frame (selected-frame))
|
|
461 (use-same-frame (or force-one-frame
|
|
462 ;; A and C must be in one frame
|
|
463 (eq frame-A (or frame-C orig-frame))
|
|
464 ;; B and C must be in one frame
|
|
465 (eq frame-B (or frame-C orig-frame))
|
|
466 ;; A or B is not visible
|
|
467 (not (frame-live-p frame-A))
|
|
468 (not (frame-live-p frame-B))
|
|
469 ;; A or B is not suitable for display
|
|
470 (not (ediff-window-ok-for-display wind-A))
|
|
471 (not (ediff-window-ok-for-display wind-B))
|
|
472 ;; A and B in the same frame, and no good frame
|
|
473 ;; for C
|
|
474 (and (eq frame-A frame-B)
|
|
475 (not (frame-live-p frame-C)))
|
|
476 ))
|
|
477 ;; use-same-frame-for-AB implies wind A and B are ok for display
|
|
478 (use-same-frame-for-AB (and (not use-same-frame)
|
|
479 (eq frame-A frame-B)))
|
|
480 (merge-window-share (ediff-eval-in-buffer control-buf
|
|
481 ediff-merge-window-share))
|
|
482 merge-window-lines
|
|
483 designated-minibuffer-frame
|
|
484 done-A done-B done-C)
|
|
485
|
|
486 ;; buf-A on its own
|
|
487 (if (and (window-live-p wind-A)
|
|
488 (null use-same-frame) ; implies wind-A is suitable
|
|
489 (null use-same-frame-for-AB))
|
|
490 (progn ; bug A on its own
|
|
491 ;; buffer buf-A is seen in live wind-A
|
|
492 (select-window wind-A)
|
|
493 (delete-other-windows)
|
|
494 (setq wind-A (selected-window))
|
|
495 (setq done-A t)))
|
|
496
|
|
497 ;; buf-B on its own
|
|
498 (if (and (window-live-p wind-B)
|
|
499 (null use-same-frame) ; implies wind-B is suitable
|
|
500 (null use-same-frame-for-AB))
|
|
501 (progn ; buf B on its own
|
|
502 ;; buffer buf-B is seen in live wind-B
|
|
503 (select-window wind-B)
|
|
504 (delete-other-windows)
|
|
505 (setq wind-B (selected-window))
|
|
506 (setq done-B t)))
|
|
507
|
|
508 ;; buf-C on its own
|
|
509 (if (and (window-live-p wind-C)
|
|
510 (ediff-window-ok-for-display wind-C)
|
|
511 (null use-same-frame)) ; buf C on its own
|
|
512 (progn
|
|
513 ;; buffer buf-C is seen in live wind-C
|
|
514 (select-window wind-C)
|
|
515 (delete-other-windows)
|
|
516 (setq wind-C (selected-window))
|
|
517 (setq done-C t)))
|
|
518
|
|
519 (if (and use-same-frame-for-AB ; implies wind A and B are suitable
|
|
520 (window-live-p wind-A))
|
|
521 (progn
|
|
522 ;; wind-A must already be displaying buf-A
|
|
523 (select-window wind-A)
|
|
524 (delete-other-windows)
|
|
525 (setq wind-A (selected-window))
|
|
526
|
|
527 (funcall split-window-function)
|
|
528 (if (eq (selected-window) wind-A)
|
|
529 (other-window 1))
|
|
530 (switch-to-buffer buf-B)
|
|
531 (setq wind-B (selected-window))
|
|
532
|
|
533 (setq done-A t
|
|
534 done-B t)))
|
|
535
|
|
536 (if use-same-frame
|
|
537 (let ((window-min-height 1))
|
|
538 ;; avoid dedicated and non-splittable windows
|
|
539 (ediff-skip-unsuitable-frames)
|
|
540 (delete-other-windows)
|
|
541 (setq merge-window-lines
|
|
542 (max 2 (round (* (window-height) merge-window-share))))
|
|
543 (switch-to-buffer buf-A)
|
|
544 (setq wind-A (selected-window))
|
|
545
|
|
546 (split-window-vertically
|
|
547 (max 2 (- (window-height) merge-window-lines)))
|
|
548 (if (eq (selected-window) wind-A)
|
|
549 (other-window 1))
|
|
550 (setq wind-C (selected-window))
|
|
551 (switch-to-buffer buf-C)
|
|
552
|
|
553 (select-window wind-A)
|
|
554
|
|
555 (funcall split-window-function)
|
|
556 (if (eq (selected-window) wind-A)
|
|
557 (other-window 1))
|
|
558 (switch-to-buffer buf-B)
|
|
559 (setq wind-B (selected-window))
|
|
560
|
|
561 (setq done-A t
|
|
562 done-B t
|
|
563 done-C t)
|
|
564 ))
|
|
565
|
|
566 (or done-A ; Buf A to be set in its own frame,
|
|
567 ;;; or it was set before because use-same-frame = 1
|
|
568 (progn
|
|
569 ;; Buf-A was not set up yet as it wasn't visible,
|
|
570 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
|
|
571 (select-window orig-wind)
|
|
572 (delete-other-windows)
|
|
573 (switch-to-buffer buf-A)
|
|
574 (setq wind-A (selected-window))
|
|
575 ))
|
|
576 (or done-B ; Buf B to be set in its own frame,
|
|
577 ;;; or it was set before because use-same-frame = 1
|
|
578 (progn
|
|
579 ;; Buf-B was not set up yet as it wasn't visible
|
|
580 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
|
|
581 (select-window orig-wind)
|
|
582 (delete-other-windows)
|
|
583 (switch-to-buffer buf-B)
|
|
584 (setq wind-B (selected-window))
|
|
585 ))
|
|
586
|
|
587 (or done-C ; Buf C to be set in its own frame,
|
|
588 ;;; or it was set before because use-same-frame = 1
|
|
589 (progn
|
|
590 ;; Buf-C was not set up yet as it wasn't visible
|
|
591 ;; and use-same-frame = nil
|
|
592 (select-window orig-wind)
|
|
593 (delete-other-windows)
|
|
594 (switch-to-buffer buf-C)
|
|
595 (setq wind-C (selected-window))
|
|
596 ))
|
|
597
|
|
598 (ediff-eval-in-buffer control-buf
|
|
599 (setq ediff-window-A wind-A
|
|
600 ediff-window-B wind-B
|
|
601 ediff-window-C wind-C)
|
|
602 (setq frame-A (window-frame ediff-window-A)
|
|
603 designated-minibuffer-frame
|
|
604 (window-frame (minibuffer-window frame-A))))
|
|
605
|
|
606 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
|
|
607 ))
|
|
608
|
|
609
|
|
610 ;; Window setup for all comparison jobs, including 3way comparisons
|
|
611 (defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf)
|
|
612 ;;; Algorithm:
|
|
613 ;;; If a buffer is seen in a frame, use that frame for that buffer.
|
|
614 ;;; If it is not seen, use the current frame.
|
|
615 ;;; If both buffers are not seen, they share the current frame. If one
|
|
616 ;;; of the buffers is not seen, it is placed in the current frame (where
|
|
617 ;;; ediff started). If that frame is displaying the other buffer, it is
|
|
618 ;;; shared between the two buffers.
|
|
619 ;;; However, if we decide to put both buffers in one frame
|
|
620 ;;; and the selected frame isn't splittable, we create a new frame and
|
|
621 ;;; put both buffers there, event if one of this buffers is visible in
|
|
622 ;;; another frame.
|
|
623
|
|
624 ;; Skip dedicated or iconified frames.
|
|
625 ;; Unsplittable frames are taken care of later.
|
|
626 (ediff-skip-unsuitable-frames 'ok-unsplittable)
|
|
627
|
|
628 (let* ((window-min-height 1)
|
|
629 (wind-A (ediff-get-visible-buffer-window buf-A))
|
|
630 (wind-B (ediff-get-visible-buffer-window buf-B))
|
|
631 (wind-C (ediff-get-visible-buffer-window buf-C))
|
|
632 (frame-A (if wind-A (window-frame wind-A)))
|
|
633 (frame-B (if wind-B (window-frame wind-B)))
|
|
634 (frame-C (if wind-C (window-frame wind-C)))
|
|
635 (ctl-frame-exists-p (ediff-eval-in-buffer control-buf
|
|
636 (frame-live-p ediff-control-frame)))
|
|
637 ;; on wide display, do things in one frame
|
|
638 (force-one-frame
|
|
639 (ediff-eval-in-buffer control-buf ediff-wide-display-p))
|
|
640 ;; this lets us have local versions of ediff-split-window-function
|
|
641 (split-window-function
|
|
642 (ediff-eval-in-buffer control-buf ediff-split-window-function))
|
|
643 (three-way-comparison
|
|
644 (ediff-eval-in-buffer control-buf ediff-3way-comparison-job))
|
|
645 (orig-wind (selected-window))
|
|
646 (use-same-frame (or force-one-frame
|
|
647 (eq frame-A frame-B)
|
|
648 (not (ediff-window-ok-for-display wind-A))
|
|
649 (not (ediff-window-ok-for-display wind-B))
|
|
650 (if three-way-comparison
|
|
651 (or (eq frame-A frame-C)
|
|
652 (eq frame-B frame-C)
|
|
653 (not (ediff-window-ok-for-display wind-C))
|
|
654 (not (frame-live-p frame-A))
|
|
655 (not (frame-live-p frame-B))
|
|
656 (not (frame-live-p frame-C))))
|
|
657 (and (not (frame-live-p frame-B))
|
|
658 (or ctl-frame-exists-p
|
|
659 (eq frame-A (selected-frame))))
|
|
660 (and (not (frame-live-p frame-A))
|
|
661 (or ctl-frame-exists-p
|
|
662 (eq frame-B (selected-frame))))))
|
|
663 wind-A-start wind-B-start
|
|
664 designated-minibuffer-frame
|
|
665 done-A done-B done-C)
|
|
666
|
|
667 (ediff-eval-in-buffer control-buf
|
|
668 (setq wind-A-start (ediff-overlay-start
|
|
669 (ediff-get-value-according-to-buffer-type
|
|
670 'A ediff-narrow-bounds))
|
|
671 wind-B-start (ediff-overlay-start
|
|
672 (ediff-get-value-according-to-buffer-type
|
|
673 'B ediff-narrow-bounds))))
|
|
674
|
|
675 (if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own
|
|
676 (progn
|
|
677 ;; buffer buf-A is seen in live wind-A
|
|
678 (select-window wind-A) ; must be displaying buf-A
|
|
679 (delete-other-windows)
|
|
680 (setq wind-A (selected-window))
|
|
681 (setq done-A t)))
|
|
682
|
|
683 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
|
|
684 (progn
|
|
685 ;; buffer buf-B is seen in live wind-B
|
|
686 (select-window wind-B) ; must be displaying buf-B
|
|
687 (delete-other-windows)
|
|
688 (setq wind-B (selected-window))
|
|
689 (setq done-B t)))
|
|
690
|
|
691 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
|
|
692 (progn
|
|
693 ;; buffer buf-C is seen in live wind-C
|
|
694 (select-window wind-C) ; must be displaying buf-C
|
|
695 (delete-other-windows)
|
|
696 (setq wind-C (selected-window))
|
|
697 (setq done-C t)))
|
|
698
|
|
699 (if use-same-frame
|
|
700 (let (wind-width-or-height) ; this affects 3way setups only
|
|
701 ;; avoid dedicated and non-splittable windows
|
|
702 (ediff-skip-unsuitable-frames)
|
|
703 (delete-other-windows)
|
|
704 (switch-to-buffer buf-A)
|
|
705 (setq wind-A (selected-window))
|
|
706
|
|
707 (if three-way-comparison
|
|
708 (setq wind-width-or-height
|
|
709 (/
|
|
710 (if (eq split-window-function 'split-window-vertically)
|
|
711 (window-height wind-A)
|
|
712 (window-width wind-A))
|
|
713 3)))
|
|
714
|
|
715 (funcall split-window-function wind-width-or-height)
|
|
716 (if (eq (selected-window) wind-A)
|
|
717 (other-window 1))
|
|
718 (switch-to-buffer buf-B)
|
|
719 (setq wind-B (selected-window))
|
|
720
|
|
721 (if three-way-comparison
|
|
722 (progn
|
|
723 (funcall split-window-function) ; equally
|
|
724 (if (memq (selected-window) (list wind-A wind-B))
|
|
725 (other-window 1))
|
|
726 (switch-to-buffer buf-C)
|
|
727 (setq wind-C (selected-window))))
|
|
728 (setq done-A t
|
|
729 done-B t
|
|
730 done-C t)
|
|
731 ))
|
|
732
|
|
733 (or done-A ; Buf A to be set in its own frame
|
|
734 ;;; or it was set before because use-same-frame = 1
|
|
735 (progn
|
|
736 ;; Buf-A was not set up yet as it wasn't visible,
|
|
737 ;; and use-same-frame = nil
|
|
738 (select-window orig-wind)
|
|
739 (delete-other-windows)
|
|
740 (switch-to-buffer buf-A)
|
|
741 (setq wind-A (selected-window))
|
|
742 ))
|
|
743 (or done-B ; Buf B to be set in its own frame
|
|
744 ;;; or it was set before because use-same-frame = 1
|
|
745 (progn
|
|
746 ;; Buf-B was not set up yet as it wasn't visible,
|
|
747 ;; and use-same-frame = nil
|
|
748 (select-window orig-wind)
|
|
749 (delete-other-windows)
|
|
750 (switch-to-buffer buf-B)
|
|
751 (setq wind-B (selected-window))
|
|
752 ))
|
|
753
|
|
754 (if three-way-comparison
|
|
755 (or done-C ; Buf C to be set in its own frame
|
|
756 ;;; or it was set before because use-same-frame = 1
|
|
757 (progn
|
|
758 ;; Buf-C was not set up yet as it wasn't visible,
|
|
759 ;; and use-same-frame = nil
|
|
760 (select-window orig-wind)
|
|
761 (delete-other-windows)
|
|
762 (switch-to-buffer buf-C)
|
|
763 (setq wind-C (selected-window))
|
|
764 )))
|
|
765
|
|
766 (ediff-eval-in-buffer control-buf
|
|
767 (setq ediff-window-A wind-A
|
|
768 ediff-window-B wind-B
|
|
769 ediff-window-C wind-C)
|
|
770
|
|
771 (setq frame-A (window-frame ediff-window-A)
|
|
772 designated-minibuffer-frame
|
|
773 (window-frame (minibuffer-window frame-A))))
|
|
774
|
|
775 ;; It is unlikely that we'll implement a version of ediff-windows that
|
|
776 ;; would compare 3 windows at once. So, we don't use buffer C here.
|
|
777 (if ediff-windows-job
|
|
778 (progn
|
|
779 (set-window-start wind-A wind-A-start)
|
|
780 (set-window-start wind-B wind-B-start)))
|
|
781
|
|
782 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
|
|
783 ))
|
|
784
|
|
785 ;; skip unsplittable frames and frames that have dedicated windows.
|
|
786 ;; create a new splittable frame if none is found
|
|
787 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
|
|
788 (if (ediff-window-display-p)
|
|
789 (let (last-window)
|
|
790 (while (and (not (eq (selected-window) last-window))
|
|
791 (or
|
|
792 (ediff-frame-has-dedicated-windows (selected-frame))
|
|
793 (ediff-frame-iconified-p (selected-frame))
|
|
794 (< (frame-height (selected-frame))
|
|
795 (* 3 window-min-height))
|
|
796 (if ok-unsplittable
|
|
797 nil
|
|
798 (ediff-frame-unsplittable-p (selected-frame)))))
|
|
799 ;; remember where started
|
|
800 (or last-window (setq last-window (selected-window)))
|
|
801 ;; try new window
|
|
802 (other-window 1 t))
|
|
803 (if (eq (selected-window) last-window)
|
|
804 ;; fed up, no appropriate frame
|
|
805 (progn
|
|
806 (select-frame (make-frame '((unsplittable)))))))))
|
|
807
|
|
808 (defun ediff-frame-has-dedicated-windows (frame)
|
|
809 (let ((cur-fr (selected-frame))
|
|
810 ans)
|
|
811 (select-frame frame)
|
|
812 (walk-windows
|
|
813 (function (lambda (wind)
|
|
814 (if (window-dedicated-p wind)
|
|
815 (setq ans t))))
|
|
816 'ignore-minibuffer
|
|
817 frame)
|
|
818 (select-frame cur-fr)
|
|
819 ans))
|
|
820
|
|
821 ;; window is ok, if it is only one window on the frame, not counting the
|
|
822 ;; minibuffer, or none of the frame's windows is dedicated.
|
|
823 ;; The idea is that it is bad to destroy dedicated windows while creating an
|
|
824 ;; ediff window setup
|
|
825 (defun ediff-window-ok-for-display (wind)
|
|
826 (and
|
|
827 (window-live-p wind)
|
|
828 (or
|
|
829 ;; only one window
|
|
830 (eq wind (next-window wind 'ignore-minibuffer (window-frame wind)))
|
|
831 ;; none is dedicated
|
|
832 (not (ediff-frame-has-dedicated-windows (window-frame wind)))
|
|
833 )))
|
|
834
|
|
835 ;; Prepare or refresh control frame
|
|
836 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
|
|
837 (let ((window-min-height 1)
|
|
838 ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
|
|
839 ctl-frame old-ctl-frame lines
|
|
840 ;; user-grabbed-mouse
|
|
841 fheight fwidth adjusted-parameters)
|
|
842
|
|
843 (ediff-eval-in-buffer ctl-buffer
|
|
844 (if ediff-xemacs-p (set-buffer-menubar nil))
|
|
845 ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
|
|
846 (run-hooks 'ediff-before-setup-control-frame-hook))
|
|
847
|
|
848 (setq old-ctl-frame (ediff-eval-in-buffer ctl-buffer ediff-control-frame))
|
|
849 (ediff-eval-in-buffer ctl-buffer
|
|
850 (setq ctl-frame (if (frame-live-p old-ctl-frame)
|
|
851 old-ctl-frame
|
|
852 (make-frame ediff-control-frame-parameters))
|
|
853 ediff-control-frame ctl-frame))
|
|
854
|
|
855 (setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
|
|
856 (select-frame ctl-frame)
|
|
857 (if (window-dedicated-p (selected-window))
|
|
858 ()
|
|
859 (delete-other-windows)
|
|
860 (switch-to-buffer ctl-buffer))
|
|
861
|
|
862 ;; must be before ediff-setup-control-buffer
|
|
863 ;; just a precaution--we should be in ctl-buffer already
|
|
864 (ediff-eval-in-buffer ctl-buffer
|
|
865 (make-local-variable 'frame-title-format)
|
|
866 (make-local-variable 'frame-icon-title-format) ; XEmacs
|
|
867 (make-local-variable 'icon-title-format)) ; Emacs
|
|
868
|
|
869 (ediff-setup-control-buffer ctl-buffer)
|
|
870 (setq dont-iconify-ctl-frame
|
|
871 (not (string= ediff-help-message ediff-brief-help-message)))
|
|
872 (setq deiconify-ctl-frame
|
|
873 (and (eq this-command 'ediff-toggle-help)
|
|
874 dont-iconify-ctl-frame))
|
|
875
|
|
876 ;; 1 more line for the modeline
|
|
877 (setq lines (1+ (count-lines (point-min) (point-max)))
|
|
878 fheight lines
|
12
|
879 fwidth (max (+ (ediff-help-message-line-length) 2)
|
|
880 (ediff-compute-toolbar-width))
|
16
|
881 adjusted-parameters ;;(append
|
|
882 (list
|
|
883 ;; possibly change surrogate minibuffer
|
|
884 (cons 'minibuffer
|
|
885 (minibuffer-window
|
|
886 designated-minibuffer-frame))
|
|
887 (cons 'width fwidth)
|
|
888 (cons 'height fheight))
|
|
889 ;;(funcall
|
|
890 ;;ediff-control-frame-position-function
|
|
891 ;;ctl-buffer fwidth fheight)
|
|
892 ;;)
|
|
893 )
|
0
|
894 (if ediff-use-long-help-message
|
|
895 (setq adjusted-parameters
|
|
896 (cons '(auto-raise . nil) adjusted-parameters)))
|
|
897
|
|
898 ;; In XEmacs, buffer menubar needs to be killed before frame parameters
|
|
899 ;; are changed.
|
|
900 (if ediff-xemacs-p
|
|
901 (progn
|
16
|
902 (set-specifier top-toolbar-height (list ctl-frame 2))
|
|
903 (sit-for 0)
|
0
|
904 (set-specifier top-toolbar-height (list ctl-frame 0))
|
16
|
905 ;;(set-specifier bottom-toolbar-height (list ctl-frame 0))
|
0
|
906 (set-specifier left-toolbar-width (list ctl-frame 0))
|
|
907 (set-specifier right-toolbar-width (list ctl-frame 0))
|
|
908 ))
|
|
909
|
|
910 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
|
|
911 ;; to make sure that at least once we do it for non-iconified frame. If
|
|
912 ;; appears that in the OS/2 port of Emacs, one can't modify frame
|
|
913 ;; parameters of iconified frames. As a precaution, we do likewise for
|
|
914 ;; windows-nt.
|
|
915 (if (memq system-type '(emx windows-nt windows-95))
|
|
916 (modify-frame-parameters ctl-frame adjusted-parameters))
|
|
917
|
16
|
918 ;; make or zap toolbar (if not requested)
|
|
919 (ediff-make-bottom-toolbar ctl-frame)
|
|
920
|
0
|
921 (goto-char (point-min))
|
16
|
922
|
0
|
923 (modify-frame-parameters ctl-frame adjusted-parameters)
|
|
924 (make-frame-visible ctl-frame)
|
14
|
925
|
0
|
926 ;; This works around a bug in 19.25 and earlier. There, if frame gets
|
|
927 ;; iconified, the current buffer changes to that of the frame that
|
|
928 ;; becomes exposed as a result of this iconification.
|
|
929 ;; So, we make sure the current buffer doesn't change.
|
|
930 (select-frame ctl-frame)
|
|
931 (ediff-refresh-control-frame)
|
|
932
|
|
933 (cond ((and ediff-prefer-iconified-control-frame
|
|
934 (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
|
|
935 (iconify-frame ctl-frame))
|
|
936 ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
|
|
937 (raise-frame ctl-frame)))
|
|
938
|
|
939 (set-window-dedicated-p (selected-window) t)
|
16
|
940
|
|
941 ;; Now move the frame. We must do it separately due to an obscure bug in
|
|
942 ;; XEmacs
|
|
943 (modify-frame-parameters
|
|
944 ctl-frame
|
|
945 (funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
|
0
|
946
|
|
947 ;; synchronize so the cursor will move to control frame
|
|
948 ;; per RMS suggestion
|
|
949 (if (ediff-window-display-p)
|
|
950 (let ((count 7))
|
|
951 (sit-for .1)
|
|
952 (while (and (not (frame-visible-p ctl-frame)) (> count 0))
|
|
953 (setq count (1- count))
|
|
954 (sit-for .3))))
|
|
955
|
|
956 (or (ediff-frame-iconified-p ctl-frame)
|
|
957 ;; don't warp the mouse, unless ediff-grab-mouse = t
|
|
958 (ediff-reset-mouse ctl-frame
|
|
959 (or (eq this-command 'ediff-quit)
|
|
960 (not (eq ediff-grab-mouse t)))))
|
|
961
|
|
962 (if ediff-xemacs-p
|
|
963 (ediff-eval-in-buffer ctl-buffer
|
|
964 (make-local-hook 'select-frame-hook)
|
|
965 (add-hook 'select-frame-hook 'ediff-xemacs-select-frame-hook nil t)
|
|
966 ))
|
|
967
|
|
968 (ediff-eval-in-buffer ctl-buffer
|
|
969 (run-hooks 'ediff-after-setup-control-frame-hook))
|
|
970 ))
|
16
|
971
|
0
|
972
|
|
973 (defun ediff-destroy-control-frame (ctl-buffer)
|
|
974 (ediff-eval-in-buffer ctl-buffer
|
|
975 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
|
|
976 (let ((ctl-frame ediff-control-frame))
|
|
977 (if ediff-xemacs-p
|
|
978 (set-buffer-menubar default-menubar))
|
|
979 (setq ediff-control-frame nil)
|
|
980 (delete-frame ctl-frame)
|
|
981 )))
|
|
982 (ediff-skip-unsuitable-frames)
|
|
983 ;;(ediff-reset-mouse nil)
|
|
984 )
|
|
985
|
|
986
|
|
987 ;; finds a good place to clip control frame
|
|
988 (defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height)
|
|
989 (ediff-eval-in-buffer ctl-buffer
|
|
990 (let* ((frame-A (window-frame ediff-window-A))
|
|
991 (frame-A-parameters (frame-parameters frame-A))
|
|
992 (frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
|
|
993 (frame-A-left (eval (cdr (assoc 'left frame-A-parameters))))
|
|
994 (frame-A-width (frame-width frame-A))
|
|
995 (ctl-frame ediff-control-frame)
|
|
996 horizontal-adjustment upward-adjustment
|
|
997 ctl-frame-top ctl-frame-left)
|
|
998
|
|
999 ;; Multiple control frames are clipped based on the value of
|
|
1000 ;; ediff-control-buffer-number. This is done in order not to obscure
|
|
1001 ;; other active control panels.
|
|
1002 (setq horizontal-adjustment (* 2 ediff-control-buffer-number)
|
|
1003 upward-adjustment (* -14 ediff-control-buffer-number))
|
|
1004
|
|
1005 (setq ctl-frame-top
|
|
1006 (- frame-A-top upward-adjustment ediff-control-frame-upward-shift)
|
|
1007 ctl-frame-left
|
|
1008 (+ frame-A-left
|
|
1009 (if ediff-use-long-help-message
|
|
1010 (* (ediff-frame-char-width ctl-frame)
|
|
1011 (+ ediff-wide-control-frame-rightward-shift
|
|
1012 horizontal-adjustment))
|
|
1013 (- (* frame-A-width (ediff-frame-char-width frame-A))
|
|
1014 (* (ediff-frame-char-width ctl-frame)
|
|
1015 (+ ctl-frame-width
|
|
1016 ediff-narrow-control-frame-leftward-shift
|
|
1017 horizontal-adjustment))))))
|
|
1018 (setq ctl-frame-top
|
|
1019 (min ctl-frame-top
|
|
1020 (- (ediff-display-pixel-height)
|
|
1021 (* 2 ctl-frame-height
|
|
1022 (ediff-frame-char-height ctl-frame))))
|
|
1023 ctl-frame-left
|
|
1024 (min ctl-frame-left
|
|
1025 (- (ediff-display-pixel-width)
|
|
1026 (* ctl-frame-width (ediff-frame-char-width ctl-frame)))))
|
|
1027 ;; keep ctl frame within the visible bounds
|
|
1028 (setq ctl-frame-top (max ctl-frame-top 1)
|
|
1029 ctl-frame-left (max ctl-frame-left 1))
|
|
1030
|
|
1031 (list (cons 'top ctl-frame-top)
|
|
1032 (cons 'left ctl-frame-left))
|
|
1033 )))
|
|
1034
|
|
1035 (defun ediff-xemacs-select-frame-hook ()
|
|
1036 (if (and (equal (selected-frame) ediff-control-frame)
|
|
1037 (not ediff-use-long-help-message))
|
|
1038 (raise-frame ediff-control-frame)))
|
|
1039
|
|
1040 (defun ediff-make-wide-display ()
|
|
1041 "Construct an alist of parameters for the wide display.
|
|
1042 Saves the old frame parameters in `ediff-wide-display-orig-parameters'.
|
|
1043 The frame to be resized is kept in `ediff-wide-display-frame'.
|
|
1044 This function modifies only the left margin and the width of the display.
|
|
1045 It assumes that it is called from within the control buffer."
|
|
1046 (if (not (fboundp 'ediff-display-pixel-width))
|
|
1047 (error "Can't determine display width."))
|
|
1048 (let* ((frame-A (window-frame ediff-window-A))
|
|
1049 (frame-A-params (frame-parameters frame-A))
|
|
1050 (cw (ediff-frame-char-width frame-A))
|
|
1051 (wd (- (/ (ediff-display-pixel-width) cw) 5)))
|
|
1052 (setq ediff-wide-display-orig-parameters
|
|
1053 (list (cons 'left (max 0 (eval (cdr (assoc 'left frame-A-params)))))
|
|
1054 (cons 'width (cdr (assoc 'width frame-A-params))))
|
|
1055 ediff-wide-display-frame frame-A)
|
|
1056 (modify-frame-parameters frame-A (list (cons 'left cw)
|
|
1057 (cons 'width wd)))))
|
|
1058
|
|
1059
|
|
1060
|
|
1061 ;; Revise the mode line to display which difference we have selected
|
|
1062 ;; Also resets modelines of buffers A/B, since they may be clobbered by
|
|
1063 ;; anothe invocations of Ediff.
|
|
1064 (defun ediff-refresh-mode-lines ()
|
|
1065 (let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge)
|
|
1066
|
|
1067 (if (ediff-valid-difference-p)
|
|
1068 (setq
|
|
1069 buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C)
|
|
1070 buf-C-state-merge (ediff-get-state-of-merge ediff-current-difference)
|
|
1071 buf-A-state-diff (ediff-get-state-of-diff ediff-current-difference 'A)
|
|
1072 buf-B-state-diff (ediff-get-state-of-diff ediff-current-difference 'B)
|
|
1073 buf-A-state-diff (if buf-A-state-diff
|
|
1074 (format "[%s] " buf-A-state-diff)
|
|
1075 "")
|
|
1076 buf-B-state-diff (if buf-B-state-diff
|
|
1077 (format "[%s] " buf-B-state-diff)
|
|
1078 "")
|
|
1079 buf-C-state-diff (if (and (ediff-buffer-live-p ediff-buffer-C)
|
|
1080 (or buf-C-state-diff buf-C-state-merge))
|
|
1081 (format "[%s%s%s] "
|
|
1082 (or buf-C-state-diff "")
|
|
1083 (if buf-C-state-merge
|
|
1084 (concat " " buf-C-state-merge)
|
|
1085 "")
|
|
1086 (if (ediff-get-state-of-ancestor
|
|
1087 ediff-current-difference)
|
|
1088 " AncestorEmpty"
|
|
1089 "")
|
|
1090 )
|
|
1091 ""))
|
|
1092 (setq buf-A-state-diff ""
|
|
1093 buf-B-state-diff ""
|
|
1094 buf-C-state-diff ""))
|
|
1095
|
|
1096 ;; control buffer format
|
|
1097 (setq mode-line-format
|
16
|
1098 (if (ediff-narrow-control-frame-p)
|
|
1099 (list " " mode-line-buffer-identification)
|
|
1100 (list "-- " mode-line-buffer-identification " Quick Help")))
|
0
|
1101 ;; control buffer id
|
|
1102 (setq mode-line-buffer-identification
|
|
1103 (if (ediff-narrow-control-frame-p)
|
|
1104 (ediff-make-narrow-control-buffer-id 'skip-name)
|
|
1105 (ediff-make-wide-control-buffer-id)))
|
|
1106 ;; Force mode-line redisplay
|
|
1107 (force-mode-line-update)
|
|
1108
|
|
1109 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
|
|
1110 (ediff-refresh-control-frame))
|
|
1111
|
|
1112 (ediff-eval-in-buffer ediff-buffer-A
|
|
1113 (setq ediff-diff-status buf-A-state-diff)
|
|
1114 (ediff-strip-mode-line-format)
|
|
1115 (setq mode-line-format
|
|
1116 (list " A: " 'ediff-diff-status mode-line-format))
|
|
1117 (force-mode-line-update))
|
|
1118 (ediff-eval-in-buffer ediff-buffer-B
|
|
1119 (setq ediff-diff-status buf-B-state-diff)
|
|
1120 (ediff-strip-mode-line-format)
|
|
1121 (setq mode-line-format
|
|
1122 (list " B: " 'ediff-diff-status mode-line-format))
|
|
1123 (force-mode-line-update))
|
|
1124 (if ediff-3way-job
|
|
1125 (ediff-eval-in-buffer ediff-buffer-C
|
|
1126 (setq ediff-diff-status buf-C-state-diff)
|
|
1127 (ediff-strip-mode-line-format)
|
|
1128 (setq mode-line-format
|
|
1129 (list " C: " 'ediff-diff-status mode-line-format))
|
|
1130 (force-mode-line-update)))
|
|
1131 (if (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
1132 (ediff-eval-in-buffer ediff-ancestor-buffer
|
|
1133 (ediff-strip-mode-line-format)
|
|
1134 ;; we keep the second dummy string in the mode line format of the
|
|
1135 ;; ancestor, since for other buffers Ediff prepends 2 strings and
|
|
1136 ;; ediff-strip-mode-line-format expects that.
|
|
1137 (setq mode-line-format
|
|
1138 (list " Ancestor: "
|
|
1139 (cond ((not (stringp buf-C-state-merge))
|
|
1140 "")
|
|
1141 ((string-match "prefer-A" buf-C-state-merge)
|
|
1142 "[=diff(B)] ")
|
|
1143 ((string-match "prefer-B" buf-C-state-merge)
|
|
1144 "[=diff(A)] ")
|
|
1145 (t ""))
|
|
1146 mode-line-format))))
|
|
1147 ))
|
|
1148
|
|
1149
|
|
1150 (defun ediff-refresh-control-frame ()
|
|
1151 (if ediff-emacs-p
|
|
1152 ;; set frame/icon titles for Emacs
|
|
1153 (modify-frame-parameters
|
|
1154 ediff-control-frame
|
|
1155 (list (cons 'title (ediff-make-base-title))
|
|
1156 (cons 'icon-name (ediff-make-narrow-control-buffer-id))
|
|
1157 ))
|
|
1158 ;; set frame/icon titles for XEmacs
|
|
1159 (setq frame-title-format (ediff-make-base-title)
|
|
1160 frame-icon-title-format (ediff-make-narrow-control-buffer-id))
|
|
1161 ;; force an update of the frame title
|
|
1162 (modify-frame-parameters ediff-control-frame '(()))))
|
|
1163
|
|
1164
|
|
1165 (defun ediff-make-narrow-control-buffer-id (&optional skip-name)
|
|
1166 (concat
|
|
1167 (if skip-name
|
|
1168 " "
|
|
1169 (ediff-make-base-title))
|
|
1170 (cond ((< ediff-current-difference 0)
|
|
1171 (format " _/%d" ediff-number-of-differences))
|
|
1172 ((>= ediff-current-difference ediff-number-of-differences)
|
|
1173 (format " $/%d" ediff-number-of-differences))
|
|
1174 (t
|
|
1175 (format " %d/%d"
|
|
1176 (1+ ediff-current-difference)
|
|
1177 ediff-number-of-differences)))))
|
|
1178
|
|
1179 (defun ediff-make-base-title ()
|
|
1180 (concat
|
|
1181 (cdr (assoc 'name ediff-control-frame-parameters))
|
|
1182 ediff-control-buffer-suffix))
|
|
1183
|
|
1184 (defun ediff-make-wide-control-buffer-id ()
|
|
1185 (cond ((< ediff-current-difference 0)
|
|
1186 (list (format "%%b At start of %d diffs"
|
|
1187 ediff-number-of-differences)))
|
|
1188 ((>= ediff-current-difference ediff-number-of-differences)
|
|
1189 (list (format "%%b At end of %d diffs"
|
|
1190 ediff-number-of-differences)))
|
|
1191 (t
|
|
1192 (list (format "%%b diff %d of %d"
|
|
1193 (1+ ediff-current-difference)
|
|
1194 ediff-number-of-differences)))))
|
|
1195
|
|
1196
|
|
1197
|
|
1198 ;; If buff is not live, return nil
|
|
1199 (defun ediff-get-visible-buffer-window (buff)
|
|
1200 (if (ediff-buffer-live-p buff)
|
|
1201 (if ediff-xemacs-p
|
|
1202 (get-buffer-window buff t)
|
|
1203 (get-buffer-window buff 'visible))))
|
|
1204
|
|
1205
|
|
1206 ;;; Functions to decide when to redraw windows
|
|
1207
|
|
1208 (defun ediff-keep-window-config (control-buf)
|
|
1209 (and (eq control-buf (current-buffer))
|
|
1210 (/= (buffer-size) 0)
|
|
1211 (ediff-eval-in-buffer control-buf
|
|
1212 (let ((ctl-wind ediff-control-window)
|
|
1213 (A-wind ediff-window-A)
|
|
1214 (B-wind ediff-window-B)
|
|
1215 (C-wind ediff-window-C))
|
|
1216
|
|
1217 (and
|
|
1218 (ediff-window-visible-p A-wind)
|
|
1219 (ediff-window-visible-p B-wind)
|
|
1220 ;; if buffer C is defined then take it into account
|
|
1221 (or (not ediff-3way-job)
|
|
1222 (ediff-window-visible-p C-wind))
|
|
1223 (eq (window-buffer A-wind) ediff-buffer-A)
|
|
1224 (eq (window-buffer B-wind) ediff-buffer-B)
|
|
1225 (or (not ediff-3way-job)
|
|
1226 (eq (window-buffer C-wind) ediff-buffer-C))
|
|
1227 (string= ediff-window-config-saved
|
12
|
1228 (format "%S%S%S%S%S%S%S"
|
0
|
1229 ctl-wind A-wind B-wind C-wind
|
|
1230 ediff-split-window-function
|
|
1231 (ediff-multiframe-setup-p)
|
|
1232 ediff-wide-display-p)))))))
|
|
1233
|
|
1234
|
|
1235 ;;; Local Variables:
|
|
1236 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
|
|
1237 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
|
12
|
1238 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
|
0
|
1239 ;;; End:
|
|
1240
|
|
1241 ;;; ediff-wind.el ends here
|