comparison src/window.c @ 67328:97a5b7b69235

(enlarge_window): Eliminate arg preserve_before. Assume it is 0. All callers changed. (Fenlarge_window, Fshrink_window): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Tue, 06 Dec 2005 02:03:23 +0000
parents f1564d57f6a1
children 36ac94b7246c 37d0562504bf 7beb78bc1f8e
comparison
equal deleted inserted replaced
67327:8e9343dc7c39 67328:97a5b7b69235
63 static int window_min_size_1 P_ ((struct window *, int)); 63 static int window_min_size_1 P_ ((struct window *, int));
64 static int window_min_size P_ ((struct window *, int, int, int *)); 64 static int window_min_size P_ ((struct window *, int, int, int *));
65 static void size_window P_ ((Lisp_Object, int, int, int)); 65 static void size_window P_ ((Lisp_Object, int, int, int));
66 static int freeze_window_start P_ ((struct window *, void *)); 66 static int freeze_window_start P_ ((struct window *, void *));
67 static int window_fixed_size_p P_ ((struct window *, int, int)); 67 static int window_fixed_size_p P_ ((struct window *, int, int));
68 static void enlarge_window P_ ((Lisp_Object, int, int, int)); 68 static void enlarge_window P_ ((Lisp_Object, int, int));
69 static Lisp_Object window_list P_ ((void)); 69 static Lisp_Object window_list P_ ((void));
70 static int add_window_to_list P_ ((struct window *, void *)); 70 static int add_window_to_list P_ ((struct window *, void *));
71 static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object, 71 static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
72 Lisp_Object)); 72 Lisp_Object));
73 static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object, 73 static Lisp_Object next_window P_ ((Lisp_Object, Lisp_Object,
3588 { 3588 {
3589 int total = (XFASTINT (XWINDOW (other)->total_lines) 3589 int total = (XFASTINT (XWINDOW (other)->total_lines)
3590 + XFASTINT (XWINDOW (window)->total_lines)); 3590 + XFASTINT (XWINDOW (window)->total_lines));
3591 enlarge_window (upper, 3591 enlarge_window (upper,
3592 total / 2 - XFASTINT (XWINDOW (upper)->total_lines), 3592 total / 2 - XFASTINT (XWINDOW (upper)->total_lines),
3593 0, 0); 3593 0);
3594 } 3594 }
3595 } 3595 }
3596 } 3596 }
3597 else 3597 else
3598 window = Fget_lru_window (Qnil, Qnil); 3598 window = Fget_lru_window (Qnil, Qnil);
3879 3879
3880 Fset_window_buffer (new, o->buffer, Qt); 3880 Fset_window_buffer (new, o->buffer, Qt);
3881 return new; 3881 return new;
3882 } 3882 }
3883 3883
3884 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 3, "p", 3884 DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p",
3885 doc: /* Make current window ARG lines bigger. 3885 doc: /* Make current window ARG lines bigger.
3886 From program, optional second arg non-nil means grow sideways ARG columns. 3886 From program, optional second arg non-nil means grow sideways ARG columns.
3887 Interactively, if an argument is not given, make the window one line bigger. 3887 Interactively, if an argument is not given, make the window one line bigger.
3888 If HORIZONTAL is non-nil, enlarge horizontally instead of vertically. 3888 If HORIZONTAL is non-nil, enlarge horizontally instead of vertically.
3889 3889 This function can delete windows, even the second window, if they get
3890 Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size 3890 too small. */)
3891 of the siblings above or to the left of the selected window. Only 3891 (arg, horizontal)
3892 siblings to the right or below are changed. */) 3892 Lisp_Object arg, horizontal;
3893 (arg, horizontal, preserve_before)
3894 register Lisp_Object arg, horizontal, preserve_before;
3895 { 3893 {
3896 CHECK_NUMBER (arg); 3894 CHECK_NUMBER (arg);
3897 enlarge_window (selected_window, XINT (arg), !NILP (horizontal), 3895 enlarge_window (selected_window, XINT (arg), !NILP (horizontal));
3898 !NILP (preserve_before));
3899 3896
3900 if (! NILP (Vwindow_configuration_change_hook)) 3897 if (! NILP (Vwindow_configuration_change_hook))
3901 call1 (Vrun_hooks, Qwindow_configuration_change_hook); 3898 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
3902 3899
3903 return Qnil; 3900 return Qnil;
3904 } 3901 }
3905 3902
3906 DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 3, "p", 3903 DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 2, "p",
3907 doc: /* Make current window ARG lines smaller. 3904 doc: /* Make current window ARG lines smaller.
3908 From program, optional second arg non-nil means shrink sideways arg columns. 3905 From program, optional second arg non-nil means shrink sideways arg columns.
3909 Interactively, if an argument is not given, make the window one line smaller. 3906 Interactively, if an argument is not given, make the window one line smaller. Only
3910
3911 Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size
3912 of the siblings above or to the left of the selected window. Only
3913 siblings to the right or below are changed. */) 3907 siblings to the right or below are changed. */)
3914 (arg, side, preserve_before) 3908 (arg, side)
3915 register Lisp_Object arg, side, preserve_before; 3909 Lisp_Object arg, side;
3916 { 3910 {
3917 CHECK_NUMBER (arg); 3911 CHECK_NUMBER (arg);
3918 enlarge_window (selected_window, -XINT (arg), !NILP (side), 3912 enlarge_window (selected_window, -XINT (arg), !NILP (side));
3919 !NILP (preserve_before));
3920 3913
3921 if (! NILP (Vwindow_configuration_change_hook)) 3914 if (! NILP (Vwindow_configuration_change_hook))
3922 call1 (Vrun_hooks, Qwindow_configuration_change_hook); 3915 call1 (Vrun_hooks, Qwindow_configuration_change_hook);
3923 3916
3924 return Qnil; 3917 return Qnil;
3952 HORIZ_FLAG nonzero means enlarge it horizontally; 3945 HORIZ_FLAG nonzero means enlarge it horizontally;
3953 zero means do it vertically. 3946 zero means do it vertically.
3954 3947
3955 Siblings of the selected window are resized to fulfill the size 3948 Siblings of the selected window are resized to fulfill the size
3956 request. If they become too small in the process, they will be 3949 request. If they become too small in the process, they will be
3957 deleted. 3950 deleted. */
3958
3959 If PRESERVE_BEFORE is nonzero, that means don't alter
3960 the siblings to the left or above WINDOW. */
3961 3951
3962 static void 3952 static void
3963 enlarge_window (window, delta, horiz_flag, preserve_before) 3953 enlarge_window (window, delta, horiz_flag)
3964 Lisp_Object window; 3954 Lisp_Object window;
3965 int delta, horiz_flag, preserve_before; 3955 int delta, horiz_flag;
3966 { 3956 {
3967 Lisp_Object parent, next, prev; 3957 Lisp_Object parent, next, prev;
3968 struct window *p; 3958 struct window *p;
3969 Lisp_Object *sizep; 3959 Lisp_Object *sizep;
3970 int maximum; 3960 int maximum;
4007 { 3997 {
4008 register int maxdelta; 3998 register int maxdelta;
4009 3999
4010 /* Compute the maximum size increment this window can have. */ 4000 /* Compute the maximum size increment this window can have. */
4011 4001
4012 if (preserve_before) 4002 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - XINT (*sizep)
4013 { 4003 /* This is a main window followed by a minibuffer. */
4014 if (!NILP (parent)) 4004 : !NILP (p->next) ? ((*sizefun) (p->next)
4015 { 4005 - window_min_size (XWINDOW (p->next),
4016 maxdelta = (*sizefun) (parent) - XINT (*sizep); 4006 horiz_flag, 0, 0))
4017 /* Subtract size of siblings before, since we can't take that. */ 4007 /* This is a minibuffer following a main window. */
4018 maxdelta -= XINT (CURBEG (window)) - XINT (CURBEG (parent)); 4008 : !NILP (p->prev) ? ((*sizefun) (p->prev)
4019 } 4009 - window_min_size (XWINDOW (p->prev),
4020 else 4010 horiz_flag, 0, 0))
4021 maxdelta = (!NILP (p->next) ? ((*sizefun) (p->next) 4011 /* This is a frame with only one window, a minibuffer-only
4022 - window_min_size (XWINDOW (p->next), 4012 or a minibufferless frame. */
4023 horiz_flag, 0, 0)) 4013 : (delta = 0));
4024 : (delta = 0));
4025 }
4026 else
4027 maxdelta = (!NILP (parent) ? (*sizefun) (parent) - XINT (*sizep)
4028 /* This is a main window followed by a minibuffer. */
4029 : !NILP (p->next) ? ((*sizefun) (p->next)
4030 - window_min_size (XWINDOW (p->next),
4031 horiz_flag, 0, 0))
4032 /* This is a minibuffer following a main window. */
4033 : !NILP (p->prev) ? ((*sizefun) (p->prev)
4034 - window_min_size (XWINDOW (p->prev),
4035 horiz_flag, 0, 0))
4036 /* This is a frame with only one window, a minibuffer-only
4037 or a minibufferless frame. */
4038 : (delta = 0));
4039 4014
4040 if (delta > maxdelta) 4015 if (delta > maxdelta)
4041 /* This case traps trying to make the minibuffer 4016 /* This case traps trying to make the minibuffer
4042 the full frame, or make the only window aside from the 4017 the full frame, or make the only window aside from the
4043 minibuffer the full frame. */ 4018 minibuffer the full frame. */
4056 /* Find the total we can get from other siblings without deleting them. */ 4031 /* Find the total we can get from other siblings without deleting them. */
4057 maximum = 0; 4032 maximum = 0;
4058 for (next = p->next; ! NILP (next); next = XWINDOW (next)->next) 4033 for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)
4059 maximum += (*sizefun) (next) - window_min_size (XWINDOW (next), 4034 maximum += (*sizefun) (next) - window_min_size (XWINDOW (next),
4060 horiz_flag, 0, 0); 4035 horiz_flag, 0, 0);
4061 if (! preserve_before) 4036 for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)
4062 for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev) 4037 maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev),
4063 maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev), 4038 horiz_flag, 0, 0);
4064 horiz_flag, 0, 0);
4065 4039
4066 /* If we can get it all from them without deleting them, do so. */ 4040 /* If we can get it all from them without deleting them, do so. */
4067 if (delta <= maximum) 4041 if (delta <= maximum)
4068 { 4042 {
4069 Lisp_Object first_unaffected; 4043 Lisp_Object first_unaffected;
4075 first_affected = window; 4049 first_affected = window;
4076 /* Look at one sibling at a time, 4050 /* Look at one sibling at a time,
4077 moving away from this window in both directions alternately, 4051 moving away from this window in both directions alternately,
4078 and take as much as we can get without deleting that sibling. */ 4052 and take as much as we can get without deleting that sibling. */
4079 while (delta != 0 4053 while (delta != 0
4080 && (!NILP (next) || (!preserve_before && !NILP (prev)))) 4054 && (!NILP (next) || !NILP (prev)))
4081 { 4055 {
4082 if (! NILP (next)) 4056 if (! NILP (next))
4083 { 4057 {
4084 int this_one = ((*sizefun) (next) 4058 int this_one = ((*sizefun) (next)
4085 - window_min_size (XWINDOW (next), 4059 - window_min_size (XWINDOW (next),
4099 } 4073 }
4100 4074
4101 if (delta == 0) 4075 if (delta == 0)
4102 break; 4076 break;
4103 4077
4104 if (!preserve_before && ! NILP (prev)) 4078 if (! NILP (prev))
4105 { 4079 {
4106 int this_one = ((*sizefun) (prev) 4080 int this_one = ((*sizefun) (prev)
4107 - window_min_size (XWINDOW (prev), 4081 - window_min_size (XWINDOW (prev),
4108 horiz_flag, 0, &fixed_p)); 4082 horiz_flag, 0, &fixed_p));
4109 if (!fixed_p) 4083 if (!fixed_p)
4348 #undef CURSIZE 4322 #undef CURSIZE
4349 4323
4350 DEFUN ("adjust-window-trailing-edge", Fadjust_window_trailing_edge, 4324 DEFUN ("adjust-window-trailing-edge", Fadjust_window_trailing_edge,
4351 Sadjust_window_trailing_edge, 3, 3, 0, 4325 Sadjust_window_trailing_edge, 3, 3, 0,
4352 doc: /* Adjust the bottom or right edge of WINDOW by DELTA. 4326 doc: /* Adjust the bottom or right edge of WINDOW by DELTA.
4353 If HORIZ_FLAG is t, that means adjust the width, moving the right edge. 4327 If HORIZONTAL is non-nil, that means adjust the width, moving the right edge.
4354 Otherwise, adjust the height, moving the bottom edge. 4328 Otherwise, adjust the height, moving the bottom edge.
4355 4329
4356 Following siblings of the selected window are resized to fulfill 4330 Following siblings of the selected window are resized to fulfill
4357 the size request. If they become too small in the process, they 4331 the size request. If they become too small in the process, they
4358 are not deleted; instead, we signal an error. */) 4332 are not deleted; instead, we signal an error. */)
4600 { 4574 {
4601 /* Distribute the additional lines of the mini-window 4575 /* Distribute the additional lines of the mini-window
4602 among the other windows. */ 4576 among the other windows. */
4603 Lisp_Object window; 4577 Lisp_Object window;
4604 XSETWINDOW (window, w); 4578 XSETWINDOW (window, w);
4605 enlarge_window (window, 1 - XFASTINT (w->total_lines), 0, 0); 4579 enlarge_window (window, 1 - XFASTINT (w->total_lines), 0);
4606 } 4580 }
4607 } 4581 }
4608 4582
4609 4583
4610 4584