302 |
(split-window-horizontally |
(split-window-horizontally |
303 |
(min (max new-width first-col) last-col)))))) |
(min (max new-width first-col) last-col)))))) |
304 |
|
|
305 |
|
(defun mouse-drag-window-above (window) |
306 |
|
"Return the (or a) window directly above WINDOW. |
307 |
|
That means one whose bottom edge is at the same height as WINDOW's top edge." |
308 |
|
(let ((top (nth 1 (window-edges window))) |
309 |
|
(start-window window) |
310 |
|
above-window) |
311 |
|
(setq window (previous-window window 0)) |
312 |
|
(while (and (not above-window) (not (eq window start-window))) |
313 |
|
(if (= (+ (window-height window) (nth 1 (window-edges window))) |
314 |
|
top) |
315 |
|
(setq above-window window)) |
316 |
|
(setq window (previous-window window))) |
317 |
|
above-window)) |
318 |
|
|
319 |
|
(defun mouse-drag-move-window-bottom (window growth) |
320 |
|
"Move the bottom of WINDOW up or down by GROWTH lines. |
321 |
|
Move it down if GROWTH is positive, or up if GROWTH is negative. |
322 |
|
If this would make WINDOW too short, |
323 |
|
shrink the window or windows above it to make room." |
324 |
|
(let ((excess (- window-min-height (+ (window-height window) growth)))) |
325 |
|
;; EXCESS is the number of lines we need to take from windows above. |
326 |
|
(if (> excess 0) |
327 |
|
;; This can recursively shrink windows all the way up. |
328 |
|
(let ((window-above (mouse-drag-window-above window))) |
329 |
|
(if window-above |
330 |
|
(mouse-drag-move-window-bottom window-above (- excess)))))) |
331 |
|
(save-selected-window |
332 |
|
(select-window window) |
333 |
|
(enlarge-window growth nil (> growth 0)))) |
334 |
|
|
335 |
(defun mouse-drag-mode-line-1 (start-event mode-line-p) |
(defun mouse-drag-mode-line-1 (start-event mode-line-p) |
336 |
"Change the height of a window by dragging on the mode or header line. |
"Change the height of a window by dragging on the mode or header line. |
337 |
START-EVENT is the starting mouse-event of the drag action. |
START-EVENT is the starting mouse-event of the drag action. |
338 |
MODE-LINE-P non-nil means a mode line is dragged." |
MODE-LINE-P non-nil means dragging a mode line; nil means a header line." |
339 |
;; Give temporary modes such as isearch a chance to turn off. |
;; Give temporary modes such as isearch a chance to turn off. |
340 |
(run-hooks 'mouse-leave-buffer-hook) |
(run-hooks 'mouse-leave-buffer-hook) |
341 |
(let* ((done nil) |
(let* ((done nil) |
405 |
|
|
406 |
;; compute size change needed |
;; compute size change needed |
407 |
(cond (mode-line-p |
(cond (mode-line-p |
|
;; Scale back a move that would make the |
|
|
;; window too short. |
|
|
(when (< (- y top -1) window-min-height) |
|
|
(setq y (+ top window-min-height -1))) |
|
408 |
(setq growth (- y bot -1))) |
(setq growth (- y bot -1))) |
409 |
(t ; header line |
(t ; header line |
410 |
(when (< (- bot y) window-min-height) |
(when (< (- bot y) window-min-height) |
438 |
(select-window start-event-window)) |
(select-window start-event-window)) |
439 |
;; no. grow/shrink the selected window |
;; no. grow/shrink the selected window |
440 |
;(message "growth = %d" growth) |
;(message "growth = %d" growth) |
441 |
(enlarge-window growth)) |
(mouse-drag-move-window-bottom start-event-window growth)) |
442 |
|
|
443 |
;; if this window's growth caused another |
;; if this window's growth caused another |
444 |
;; window to be deleted because it was too |
;; window to be deleted because it was too |
452 |
;; around it. |
;; around it. |
453 |
(when (or (/= start-nwindows (count-windows t)) |
(when (or (/= start-nwindows (count-windows t)) |
454 |
(and (not should-enlarge-minibuffer) |
(and (not should-enlarge-minibuffer) |
455 |
|
(> growth 0) |
456 |
mode-line-p |
mode-line-p |
457 |
(/= top (nth 1 (window-edges))))) |
(/= top (nth 1 (window-edges))))) |
458 |
(set-window-configuration wconfig))))))))) |
(set-window-configuration wconfig))))))))) |