diff options
| author | Richard M. Stallman | 2001-12-25 10:36:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-12-25 10:36:08 +0000 |
| commit | f95284d2b412592ad77bcd6977e07f0e17ab3892 (patch) | |
| tree | b6cd3e0dd0a66f7028f153fc35931c41839bb85c /src/window.c | |
| parent | 0d6c5d184966a74f3d44d05b63cd244d9f02b199 (diff) | |
| download | emacs-f95284d2b412592ad77bcd6977e07f0e17ab3892.tar.gz emacs-f95284d2b412592ad77bcd6977e07f0e17ab3892.zip | |
(enlarge_window): New arg PRESERVE_BEFORE. Callers changed.
(Fenlarge_window): New arg PRESERVE_BEFORE.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 91 |
1 files changed, 60 insertions, 31 deletions
diff --git a/src/window.c b/src/window.c index 36a9419c138..35694084a9b 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -79,7 +79,7 @@ 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, |
| @@ -3043,7 +3043,7 @@ displayed. */) | |||
| 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 | } |
| @@ -3269,15 +3269,20 @@ SIZE includes that window's scroll bar, or the divider column to its right. */) | |||
| 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); |
| @@ -3293,7 +3298,7 @@ Interactively, if an argument is not given, make the window one line smaller. * | |||
| 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); |
| @@ -3325,15 +3330,18 @@ window_width (window) | |||
| 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; |
| @@ -3378,16 +3386,35 @@ enlarge_window (window, delta, widthflag) | |||
| 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 |
| @@ -3405,16 +3432,17 @@ enlarge_window (window, delta, widthflag) | |||
| 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), |
| 3443 | widthflag, 0, 0); | ||
| 3416 | 3444 | ||
| 3417 | /* If we can get it all from them, do so. */ | 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; |
| @@ -3427,7 +3455,8 @@ enlarge_window (window, delta, widthflag) | |||
| 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 | { |
| @@ -3451,7 +3480,7 @@ enlarge_window (window, delta, widthflag) | |||
| 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), |
| @@ -3799,7 +3828,7 @@ shrink_mini_window (w) | |||
| 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 | ||