comparison src/window.c @ 42308:c931d7a1b0df

(enlarge_window): New arg PRESERVE_BEFORE. Callers changed. (Fenlarge_window): New arg PRESERVE_BEFORE.
author Richard M. Stallman <rms@gnu.org>
date Tue, 25 Dec 2001 10:36:08 +0000
parents ca7101bea5ee
children 29b74fa42a55
comparison
equal deleted inserted replaced
42307:922f0ef2951b 42308:c931d7a1b0df
77 static int window_min_size_1 P_ ((struct window *, int)); 77 static int window_min_size_1 P_ ((struct window *, int));
78 static int window_min_size P_ ((struct window *, int, int, int *)); 78 static int window_min_size P_ ((struct window *, int, int, int *));
79 static void size_window P_ ((Lisp_Object, int, int, int)); 79 static void size_window P_ ((Lisp_Object, int, int, int));
80 static int freeze_window_start P_ ((struct window *, void *)); 80 static int freeze_window_start P_ ((struct window *, void *));
81 static int window_fixed_size_p P_ ((struct window *, int, int)); 81 static int window_fixed_size_p P_ ((struct window *, int, int));
82 static void enlarge_window P_ ((Lisp_Object, int, int)); 82 static void enlarge_window P_ ((Lisp_Object, int, int, int));
83 static Lisp_Object window_list P_ ((void)); 83 static Lisp_Object window_list P_ ((void));
84 static int add_window_to_list P_ ((struct window *, void *)); 84 static int add_window_to_list P_ ((struct window *, void *));
85 static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 85 static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
86 Lisp_Object)); 86 Lisp_Object));
87 static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object, 87 static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object,
3041 { 3041 {
3042 int total = (XFASTINT (XWINDOW (other)->height) 3042 int total = (XFASTINT (XWINDOW (other)->height)
3043 + XFASTINT (XWINDOW (window)->height)); 3043 + XFASTINT (XWINDOW (window)->height));
3044 enlarge_window (upper, 3044 enlarge_window (upper,
3045 total / 2 - XFASTINT (XWINDOW (upper)->height), 3045 total / 2 - XFASTINT (XWINDOW (upper)->height),
3046 0); 3046 0, 0);
3047 } 3047 }
3048 } 3048 }
3049 } 3049 }
3050 else 3050 else
3051 window = Fget_lru_window (Qnil); 3051 window = Fget_lru_window (Qnil);
3267 adjust_glyphs (fo); 3267 adjust_glyphs (fo);
3268 Fset_window_buffer (new, o->buffer); 3268 Fset_window_buffer (new, o->buffer);
3269 return new; 3269 return new;
3270 } 3270 }
3271 3271
3272 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p", 3272 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 3, "p",
3273 doc: /* Make current window ARG lines bigger. 3273 doc: /* Make current window ARG lines bigger.
3274 From program, optional second arg non-nil means grow sideways ARG columns. 3274 From program, optional second arg non-nil means grow sideways ARG columns.
3275 Interactively, if an argument is not given, make the window one line bigger. */) 3275 Interactively, if an argument is not given, make the window one line bigger.
3276 (arg, side) 3276
3277 register Lisp_Object arg, side; 3277 Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size
3278 of the siblings above or to the left of the selected window. Only
3279 siblings to the right or below are changed. */)
3280 (arg, side, preserve_before)
3281 register Lisp_Object arg, side, preserve_before;
3278 { 3282 {
3279 CHECK_NUMBER (arg); 3283 CHECK_NUMBER (arg);
3280 enlarge_window (selected_window, XINT (arg), !NILP (side)); 3284 enlarge_window (selected_window, XINT (arg), !NILP (side),
3285 !NILP (preserve_before));
3281 3286
3282 if (! NILP (Vwindow_configuration_change_hook)) 3287 if (! NILP (Vwindow_configuration_change_hook))
3283 call1 (Vrun_hooks, Qwindow_configuration_change_hook); 3288 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
3284 3289
3285 return Qnil; 3290 return Qnil;
3291 Interactively, if an argument is not given, make the window one line smaller. */) 3296 Interactively, if an argument is not given, make the window one line smaller. */)
3292 (arg, side) 3297 (arg, side)
3293 register Lisp_Object arg, side; 3298 register Lisp_Object arg, side;
3294 { 3299 {
3295 CHECK_NUMBER (arg); 3300 CHECK_NUMBER (arg);
3296 enlarge_window (selected_window, -XINT (arg), !NILP (side)); 3301 enlarge_window (selected_window, -XINT (arg), !NILP (side), 0);
3297 3302
3298 if (! NILP (Vwindow_configuration_change_hook)) 3303 if (! NILP (Vwindow_configuration_change_hook))
3299 call1 (Vrun_hooks, Qwindow_configuration_change_hook); 3304 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
3300 3305
3301 return Qnil; 3306 return Qnil;
3323 3328
3324 #define CURSIZE(w) \ 3329 #define CURSIZE(w) \
3325 *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height)) 3330 *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height))
3326 3331
3327 3332
3328 /* Enlarge selected_window by DELTA. WIDTHFLAG non-zero means 3333 /* Enlarge WINDOW by DELTA. WIDTHFLAG non-zero means
3329 increase its width. Siblings of the selected window are resized to 3334 increase its width. Siblings of the selected window are resized to
3330 fullfil the size request. If they become too small in the process, 3335 fulfill the size request. If they become too small in the process,
3331 they will be deleted. */ 3336 they will be deleted.
3337
3338 If PRESERVE_BEFORE is nonzero, that means don't alter
3339 the siblings to the left or above WINDOW. */
3332 3340
3333 static void 3341 static void
3334 enlarge_window (window, delta, widthflag) 3342 enlarge_window (window, delta, widthflag, preserve_before)
3335 Lisp_Object window; 3343 Lisp_Object window;
3336 int delta, widthflag; 3344 int delta, widthflag, preserve_before;
3337 { 3345 {
3338 Lisp_Object parent, next, prev; 3346 Lisp_Object parent, next, prev;
3339 struct window *p; 3347 struct window *p;
3340 Lisp_Object *sizep; 3348 Lisp_Object *sizep;
3341 int maximum; 3349 int maximum;
3376 sizep = &CURSIZE (window); 3384 sizep = &CURSIZE (window);
3377 3385
3378 { 3386 {
3379 register int maxdelta; 3387 register int maxdelta;
3380 3388
3381 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - XINT (*sizep) 3389 /* Compute the maximum size increment this window can have. */
3382 : !NILP (p->next) ? ((*sizefun) (p->next) 3390
3383 - window_min_size (XWINDOW (p->next), 3391 if (preserve_before)
3384 widthflag, 0, 0)) 3392 {
3385 : !NILP (p->prev) ? ((*sizefun) (p->prev) 3393 if (!NILP (parent))
3386 - window_min_size (XWINDOW (p->prev), 3394 {
3387 widthflag, 0, 0)) 3395 maxdelta = (*sizefun) (parent) - XINT (*sizep);
3388 /* This is a frame with only one window, a minibuffer-only 3396 /* Subtract size of siblings before, since we can't take that. */
3389 or a minibufferless frame. */ 3397 maxdelta -= CURBEG (window) - CURBEG (parent);
3390 : (delta = 0)); 3398 }
3399 else
3400 maxdelta = (!NILP (p->next) ? ((*sizefun) (p->next)
3401 - window_min_size (XWINDOW (p->next),
3402 widthflag, 0, 0))
3403 : (delta = 0));
3404 }
3405 else
3406 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - XINT (*sizep)
3407 /* This is a main window followed by a minibuffer. */
3408 : !NILP (p->next) ? ((*sizefun) (p->next)
3409 - window_min_size (XWINDOW (p->next),
3410 widthflag, 0, 0))
3411 /* This is a minibuffer following a main window. */
3412 : !NILP (p->prev) ? ((*sizefun) (p->prev)
3413 - window_min_size (XWINDOW (p->prev),
3414 widthflag, 0, 0))
3415 /* This is a frame with only one window, a minibuffer-only
3416 or a minibufferless frame. */
3417 : (delta = 0));
3391 3418
3392 if (delta > maxdelta) 3419 if (delta > maxdelta)
3393 /* This case traps trying to make the minibuffer 3420 /* This case traps trying to make the minibuffer
3394 the full frame, or make the only window aside from the 3421 the full frame, or make the only window aside from the
3395 minibuffer the full frame. */ 3422 minibuffer the full frame. */
3403 } 3430 }
3404 3431
3405 if (delta == 0) 3432 if (delta == 0)
3406 return; 3433 return;
3407 3434
3408 /* Find the total we can get from other siblings. */ 3435 /* Find the total we can get from other siblings without deleting them. */
3409 maximum = 0; 3436 maximum = 0;
3410 for (next = p->next; ! NILP (next); next = XWINDOW (next)->next) 3437 for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)
3411 maximum += (*sizefun) (next) - window_min_size (XWINDOW (next), 3438 maximum += (*sizefun) (next) - window_min_size (XWINDOW (next),
3412 widthflag, 0, 0); 3439 widthflag, 0, 0);
3413 for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev) 3440 if (! preserve_before)
3414 maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev), 3441 for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)
3415 widthflag, 0, 0); 3442 maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev),
3416 3443 widthflag, 0, 0);
3417 /* If we can get it all from them, do so. */ 3444
3445 /* If we can get it all from them without deleting them, do so. */
3418 if (delta <= maximum) 3446 if (delta <= maximum)
3419 { 3447 {
3420 Lisp_Object first_unaffected; 3448 Lisp_Object first_unaffected;
3421 Lisp_Object first_affected; 3449 Lisp_Object first_affected;
3422 int fixed_p; 3450 int fixed_p;
3425 prev = p->prev; 3453 prev = p->prev;
3426 first_affected = window; 3454 first_affected = window;
3427 /* Look at one sibling at a time, 3455 /* Look at one sibling at a time,
3428 moving away from this window in both directions alternately, 3456 moving away from this window in both directions alternately,
3429 and take as much as we can get without deleting that sibling. */ 3457 and take as much as we can get without deleting that sibling. */
3430 while (delta != 0 && (!NILP (next) || !NILP (prev))) 3458 while (delta != 0
3459 && (!NILP (next) || (!preserve_before && !NILP (prev))))
3431 { 3460 {
3432 if (! NILP (next)) 3461 if (! NILP (next))
3433 { 3462 {
3434 int this_one = ((*sizefun) (next) 3463 int this_one = ((*sizefun) (next)
3435 - window_min_size (XWINDOW (next), 3464 - window_min_size (XWINDOW (next),
3449 } 3478 }
3450 3479
3451 if (delta == 0) 3480 if (delta == 0)
3452 break; 3481 break;
3453 3482
3454 if (! NILP (prev)) 3483 if (!preserve_before && ! NILP (prev))
3455 { 3484 {
3456 int this_one = ((*sizefun) (prev) 3485 int this_one = ((*sizefun) (prev)
3457 - window_min_size (XWINDOW (prev), 3486 - window_min_size (XWINDOW (prev),
3458 widthflag, 0, &fixed_p)); 3487 widthflag, 0, &fixed_p));
3459 if (!fixed_p) 3488 if (!fixed_p)
3797 { 3826 {
3798 /* Distribute the additional lines of the mini-window 3827 /* Distribute the additional lines of the mini-window
3799 among the other windows. */ 3828 among the other windows. */
3800 Lisp_Object window; 3829 Lisp_Object window;
3801 XSETWINDOW (window, w); 3830 XSETWINDOW (window, w);
3802 enlarge_window (window, 1 - XFASTINT (w->height), 0); 3831 enlarge_window (window, 1 - XFASTINT (w->height), 0, 0);
3803 } 3832 }
3804 } 3833 }
3805 3834
3806 3835
3807 3836