/[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.527 by monnier, Fri Nov 4 21:37:02 2005 UTC revision 1.528 by rms, Sun Nov 27 19:16:28 2005 UTC
# Line 210  Lisp_Object Vwindow_configuration_change Line 210  Lisp_Object Vwindow_configuration_change
210    
211  Lisp_Object Vscroll_preserve_screen_position;  Lisp_Object Vscroll_preserve_screen_position;
212    
213    /* Incremented by 1 whenever a window is deleted.  */
214    
215    int window_deletion_count;
216    
217  #if 0 /* This isn't used anywhere.  */  #if 0 /* This isn't used anywhere.  */
218  /* Nonzero means we can split a frame even if it is "unsplittable".  */  /* Nonzero means we can split a frame even if it is "unsplittable".  */
219  static int inhibit_frame_unsplittable;  static int inhibit_frame_unsplittable;
# Line 1333  delete_window (window) Line 1337  delete_window (window)
1337      CHECK_WINDOW (window);      CHECK_WINDOW (window);
1338    p = XWINDOW (window);    p = XWINDOW (window);
1339    
1340    /* It's okay to delete an already-deleted window.  */    /* It's a no-op to delete an already-deleted window.  */
1341    if (NILP (p->buffer)    if (NILP (p->buffer)
1342        && NILP (p->hchild)        && NILP (p->hchild)
1343        && NILP (p->vchild))        && NILP (p->vchild))
# Line 1397  delete_window (window) Line 1401  delete_window (window)
1401        }        }
1402    }    }
1403    
1404      /* Now we know we can delete this one.  */
1405      window_deletion_count++;
1406    
1407    tem = p->buffer;    tem = p->buffer;
1408    /* tem is null for dummy parent windows    /* tem is null for dummy parent windows
1409       (which have inferiors but not any contents themselves) */       (which have inferiors but not any contents themselves) */
# Line 4231  enlarge_window (window, delta, horiz_fla Line 4238  enlarge_window (window, delta, horiz_fla
4238    adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window))));    adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window))));
4239  }  }
4240    
4241    
4242    /* Adjust the size of WINDOW by DELTA, moving only its trailing edge.
4243       HORIZ_FLAG nonzero means adjust the width, moving the right edge.
4244       zero means adjust the height, moving the bottom edge.
4245    
4246       Following siblings of the selected window are resized to fulfill
4247       the size request.  If they become too small in the process, they
4248       are not deleted; instead, we signal an error.  */
4249    
4250    static void
4251    adjust_window_trailing_edge (window, delta, horiz_flag)
4252         Lisp_Object window;
4253         int delta, horiz_flag;
4254    {
4255      Lisp_Object parent, child;
4256      struct window *p;
4257      Lisp_Object old_config = Fcurrent_window_configuration (Qnil);
4258      int delcount = window_deletion_count;
4259    
4260      /* Check values of window_min_width and window_min_height for
4261         validity.  */
4262      check_min_window_sizes ();
4263    
4264      if (NILP (window))
4265        window = Fselected_window ();
4266    
4267      CHECK_WINDOW (window);
4268    
4269      /* Give up if this window cannot be resized.  */
4270      if (window_fixed_size_p (XWINDOW (window), horiz_flag, 1))
4271        error ("Window is not resizable");
4272    
4273      while (1)
4274        {
4275          p = XWINDOW (window);
4276          parent = p->parent;
4277    
4278          /* Make sure there is a following window.  */
4279          if (NILP (parent)
4280              && (horiz_flag ? 1
4281                  : NILP (XWINDOW (window)->next)))
4282            {
4283              Fset_window_configuration (old_config);
4284              error ("No other window following this one");
4285            }
4286    
4287          /* Don't make this window too small.  */
4288          if (XINT (CURSIZE (window)) + delta
4289              < (horiz_flag ? window_min_width : window_min_height))
4290            {
4291              Fset_window_configuration (old_config);
4292              error ("Cannot adjust window size as specified");
4293            }
4294    
4295          /* Clear out some redisplay caches.  */
4296          XSETFASTINT (p->last_modified, 0);
4297          XSETFASTINT (p->last_overlay_modified, 0);
4298    
4299          /* Adjust this window's edge.  */
4300          XSETINT (CURSIZE (window),
4301                   XINT (CURSIZE (window)) + delta);
4302    
4303          /* If this window has following siblings in the desired dimension,
4304             make them smaller.
4305             (If we reach the top of the tree and can never do this,
4306             we will fail and report an error, above.)  */
4307          if (horiz_flag
4308              ? !NILP (XWINDOW (parent)->hchild)
4309              : !NILP (XWINDOW (parent)->vchild))
4310            {
4311              if (!NILP (XWINDOW (window)->next))
4312                {
4313                  XSETINT (CURBEG (p->next),
4314                           XINT (CURBEG (p->next)) + delta);
4315                  size_window (p->next, XINT (CURSIZE (p->next)) - delta,
4316                               horiz_flag, 0);
4317                  break;
4318                }
4319            }
4320          else
4321            /* Here we have a chain of parallel siblings, in the other dimension.
4322               Change the size of the other siblings.  */
4323            for (child = (horiz_flag
4324                          ? XWINDOW (parent)->vchild
4325                          : XWINDOW (parent)->hchild);
4326                 ! NILP (child);
4327                 child = XWINDOW (child)->next)
4328              if (! EQ (child, window))
4329                size_window (child, XINT (CURSIZE (child)) + delta,
4330                             horiz_flag, 0);
4331    
4332          window = parent;
4333        }
4334    
4335      /* If we made a window so small it got deleted,
4336         we failed.  Report failure.  */
4337      if (delcount != window_deletion_count)
4338        {
4339          Fset_window_configuration (old_config);
4340          error ("Cannot adjust window size as specified");
4341        }
4342    
4343      /* Adjust glyph matrices. */
4344      adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window))));
4345    }
4346    
4347  #undef CURBEG  #undef CURBEG
4348  #undef CURSIZE  #undef CURSIZE
4349    
4350    DEFUN ("adjust-window-trailing-edge", Fadjust_window_trailing_edge,
4351           Sadjust_window_trailing_edge, 3, 3, 0,
4352           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.
4354    Otherwise, adjust the height, moving the bottom edge.
4355    
4356    Following siblings of the selected window are resized to fulfill
4357    the size request.  If they become too small in the process, they
4358    are not deleted; instead, we signal an error.  */)
4359      (window, delta, horizontal)
4360      Lisp_Object window, delta, horizontal;
4361    {
4362      CHECK_NUMBER (delta);
4363      adjust_window_trailing_edge (window, XINT (delta), !NILP (horizontal));
4364    
4365      if (! NILP (Vwindow_configuration_change_hook))
4366        call1 (Vrun_hooks, Qwindow_configuration_change_hook);
4367    
4368      return Qnil;
4369    }
4370    
4371    
4372    
4373  /***********************************************************************  /***********************************************************************
# Line 7114  The selected frame is the one whose conf Line 7248  The selected frame is the one whose conf
7248    defsubr (&Ssplit_window);    defsubr (&Ssplit_window);
7249    defsubr (&Senlarge_window);    defsubr (&Senlarge_window);
7250    defsubr (&Sshrink_window);    defsubr (&Sshrink_window);
7251      defsubr (&Sadjust_window_trailing_edge);
7252    defsubr (&Sscroll_up);    defsubr (&Sscroll_up);
7253    defsubr (&Sscroll_down);    defsubr (&Sscroll_down);
7254    defsubr (&Sscroll_left);    defsubr (&Sscroll_left);

Legend:
Removed from v.1.527  
changed lines
  Added in v.1.528

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