/[emacs]/emacs/src/window.c
ViewVC logotype

Diff of /emacs/src/window.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.394 by rms, Sun Dec 16 20:01:48 2001 UTC revision 1.395 by rms, Tue Dec 25 10:36:08 2001 UTC
# Line 79  static int window_min_size P_ ((struct w Line 79  static int window_min_size P_ ((struct w
79  static void size_window P_ ((Lisp_Object, int, int, int));  static void size_window P_ ((Lisp_Object, int, int, int));
80  static int freeze_window_start P_ ((struct window *, void *));  static int freeze_window_start P_ ((struct window *, void *));
81  static int window_fixed_size_p P_ ((struct window *, int, int));  static int window_fixed_size_p P_ ((struct window *, int, int));
82  static void enlarge_window P_ ((Lisp_Object, int, int));  static void enlarge_window P_ ((Lisp_Object, int, int, int));
83  static Lisp_Object window_list P_ ((void));  static Lisp_Object window_list P_ ((void));
84  static int add_window_to_list P_ ((struct window *, void *));  static int add_window_to_list P_ ((struct window *, void *));
85  static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,  static int candidate_window_p P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
# Line 3043  displayed.  */) Line 3043  displayed.  */)
3043                             + XFASTINT (XWINDOW (window)->height));                             + XFASTINT (XWINDOW (window)->height));
3044                enlarge_window (upper,                enlarge_window (upper,
3045                                total / 2 - XFASTINT (XWINDOW (upper)->height),                                total / 2 - XFASTINT (XWINDOW (upper)->height),
3046                                0);                                0, 0);
3047              }              }
3048          }          }
3049      }      }
# Line 3269  SIZE includes that window's scroll bar, Line 3269  SIZE includes that window's scroll bar,
3269    return new;    return new;
3270  }  }
3271    
3272  DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p",  DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 3, "p",
3273         doc: /* Make current window ARG lines bigger.         doc: /* Make current window ARG lines bigger.
3274  From program, optional second arg non-nil means grow sideways ARG columns.  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.  */)  Interactively, if an argument is not given, make the window one line bigger.
3276       (arg, side)  
3277       register Lisp_Object arg, side;  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;
3282  {  {
3283    CHECK_NUMBER (arg);    CHECK_NUMBER (arg);
3284    enlarge_window (selected_window, XINT (arg), !NILP (side));    enlarge_window (selected_window, XINT (arg), !NILP (side),
3285                      !NILP (preserve_before));
3286    
3287    if (! NILP (Vwindow_configuration_change_hook))    if (! NILP (Vwindow_configuration_change_hook))
3288      call1 (Vrun_hooks, Qwindow_configuration_change_hook);      call1 (Vrun_hooks, Qwindow_configuration_change_hook);
# Line 3293  Interactively, if an argument is not giv Line 3298  Interactively, if an argument is not giv
3298       register Lisp_Object arg, side;       register Lisp_Object arg, side;
3299  {  {
3300    CHECK_NUMBER (arg);    CHECK_NUMBER (arg);
3301    enlarge_window (selected_window, -XINT (arg), !NILP (side));    enlarge_window (selected_window, -XINT (arg), !NILP (side), 0);
3302    
3303    if (! NILP (Vwindow_configuration_change_hook))    if (! NILP (Vwindow_configuration_change_hook))
3304      call1 (Vrun_hooks, Qwindow_configuration_change_hook);      call1 (Vrun_hooks, Qwindow_configuration_change_hook);
# Line 3325  window_width (window) Line 3330  window_width (window)
3330    *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height))    *(widthflag ? &(XWINDOW (w)->width) : &(XWINDOW (w)->height))
3331    
3332    
3333  /* Enlarge selected_window by DELTA.  WIDTHFLAG non-zero means  /* Enlarge WINDOW by DELTA.  WIDTHFLAG non-zero means
3334     increase its width.  Siblings of the selected window are resized to     increase its width.  Siblings of the selected window are resized to
3335     fullfil the size request.  If they become too small in the process,     fulfill the size request.  If they become too small in the process,
3336     they will be deleted.  */     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.  */
3340    
3341  static void  static void
3342  enlarge_window (window, delta, widthflag)  enlarge_window (window, delta, widthflag, preserve_before)
3343       Lisp_Object window;       Lisp_Object window;
3344       int delta, widthflag;       int delta, widthflag, preserve_before;
3345  {  {
3346    Lisp_Object parent, next, prev;    Lisp_Object parent, next, prev;
3347    struct window *p;    struct window *p;
# Line 3378  enlarge_window (window, delta, widthflag Line 3386  enlarge_window (window, delta, widthflag
3386    {    {
3387      register int maxdelta;      register int maxdelta;
3388    
3389      maxdelta = (!NILP (parent) ? (*sizefun) (parent) - XINT (*sizep)      /* Compute the maximum size increment this window can have.  */
3390                  : !NILP (p->next) ? ((*sizefun) (p->next)  
3391                                       - window_min_size (XWINDOW (p->next),      if (preserve_before)
3392                                                          widthflag, 0, 0))        {
3393                  : !NILP (p->prev) ? ((*sizefun) (p->prev)          if (!NILP (parent))
3394                                       - window_min_size (XWINDOW (p->prev),            {
3395                                                          widthflag, 0, 0))              maxdelta = (*sizefun) (parent) - XINT (*sizep);
3396                  /* This is a frame with only one window, a minibuffer-only              /* Subtract size of siblings before, since we can't take that.  */
3397                     or a minibufferless frame.  */              maxdelta -= CURBEG (window) - CURBEG (parent);
3398                  : (delta = 0));            }
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));
3418    
3419      if (delta > maxdelta)      if (delta > maxdelta)
3420        /* This case traps trying to make the minibuffer        /* This case traps trying to make the minibuffer
# Line 3405  enlarge_window (window, delta, widthflag Line 3432  enlarge_window (window, delta, widthflag
3432    if (delta == 0)    if (delta == 0)
3433      return;      return;
3434    
3435    /* Find the total we can get from other siblings.  */    /* Find the total we can get from other siblings without deleting them.  */
3436    maximum = 0;    maximum = 0;
3437    for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)    for (next = p->next; ! NILP (next); next = XWINDOW (next)->next)
3438      maximum += (*sizefun) (next) - window_min_size (XWINDOW (next),      maximum += (*sizefun) (next) - window_min_size (XWINDOW (next),
3439                                                      widthflag, 0, 0);                                                      widthflag, 0, 0);
3440    for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)    if (! preserve_before)
3441      maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev),      for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev)
3442                                                      widthflag, 0, 0);        maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev),
3443                                                          widthflag, 0, 0);
3444    
3445    /* If we can get it all from them, do so.  */    /* If we can get it all from them without deleting them, do so.  */
3446    if (delta <= maximum)    if (delta <= maximum)
3447      {      {
3448        Lisp_Object first_unaffected;        Lisp_Object first_unaffected;
# Line 3427  enlarge_window (window, delta, widthflag Line 3455  enlarge_window (window, delta, widthflag
3455        /* Look at one sibling at a time,        /* Look at one sibling at a time,
3456           moving away from this window in both directions alternately,           moving away from this window in both directions alternately,
3457           and take as much as we can get without deleting that sibling.  */           and take as much as we can get without deleting that sibling.  */
3458        while (delta != 0 && (!NILP (next) || !NILP (prev)))        while (delta != 0
3459                 && (!NILP (next) || (!preserve_before && !NILP (prev))))
3460          {          {
3461            if (! NILP (next))            if (! NILP (next))
3462              {              {
# Line 3451  enlarge_window (window, delta, widthflag Line 3480  enlarge_window (window, delta, widthflag
3480            if (delta == 0)            if (delta == 0)
3481              break;              break;
3482                        
3483            if (! NILP (prev))            if (!preserve_before && ! NILP (prev))
3484              {              {
3485                int this_one = ((*sizefun) (prev)                int this_one = ((*sizefun) (prev)
3486                                - window_min_size (XWINDOW (prev),                                - window_min_size (XWINDOW (prev),
# Line 3799  shrink_mini_window (w) Line 3828  shrink_mini_window (w)
3828           among the other windows.  */           among the other windows.  */
3829        Lisp_Object window;        Lisp_Object window;
3830        XSETWINDOW (window, w);        XSETWINDOW (window, w);
3831        enlarge_window (window, 1 - XFASTINT (w->height), 0);        enlarge_window (window, 1 - XFASTINT (w->height), 0, 0);
3832      }      }
3833  }  }
3834    

Legend:
Removed from v.1.394  
changed lines
  Added in v.1.395

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26