Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.203
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.203
Karsten Hopp 81c285
Problem:    When reloading a buffer or doing anything else with a buffer that
Karsten Hopp 81c285
	    is not displayed in a visible window, autocommands may be applied
Karsten Hopp 81c285
	    to the current window, folds messed up, etc.
Karsten Hopp 81c285
Solution:   Instead of using the current window for the hidden buffer use a
Karsten Hopp 81c285
	    special window, splitting the current one temporarily.
Karsten Hopp 81c285
Files:	    src/fileio.c, src/globals.h, src/gui.c, src/if_perl.xs,
Karsten Hopp 81c285
	    src/proto/gui.pro, src/proto/window.pro, src/screen.c,
Karsten Hopp 81c285
	    src/structs.h, src/window.c
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.202/src/fileio.c	2009-06-16 15:35:46.000000000 +0200
Karsten Hopp 81c285
--- src/fileio.c	2009-06-11 21:22:37.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8365,8371 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* Execute the modeline settings, but don't set window-local
Karsten Hopp 81c285
  	     * options if we are using the current window for another buffer. */
Karsten Hopp 81c285
! 	    do_modelines(aco.save_curwin == NULL ? OPT_NOWIN : 0);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* restore the current window */
Karsten Hopp 81c285
  	    aucmd_restbuf(&aco;;
Karsten Hopp 81c285
--- 8365,8371 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* Execute the modeline settings, but don't set window-local
Karsten Hopp 81c285
  	     * options if we are using the current window for another buffer. */
Karsten Hopp 81c285
! 	    do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	    /* restore the current window */
Karsten Hopp 81c285
  	    aucmd_restbuf(&aco;;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8381,8388 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Prepare for executing autocommands for (hidden) buffer "buf".
Karsten Hopp 81c285
!  * Search a window for the current buffer.  Save the cursor position and
Karsten Hopp 81c285
!  * screen offset.
Karsten Hopp 81c285
   * Set "curbuf" and "curwin" to match "buf".
Karsten Hopp 81c285
   * When FEAT_AUTOCMD is not defined another version is used, see below.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
--- 8381,8388 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Prepare for executing autocommands for (hidden) buffer "buf".
Karsten Hopp 81c285
!  * Search for a visible window containing the current buffer.  If there isn't
Karsten Hopp 81c285
!  * one then use "aucmd_win".
Karsten Hopp 81c285
   * Set "curbuf" and "curwin" to match "buf".
Karsten Hopp 81c285
   * When FEAT_AUTOCMD is not defined another version is used, see below.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8392,8399 ****
Karsten Hopp 81c285
      buf_T	*buf;		/* new curbuf */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*win;
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     aco->new_curbuf = buf;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* Find a window that is for the new buffer */
Karsten Hopp 81c285
      if (buf == curbuf)		/* be quick when buf is curbuf */
Karsten Hopp 81c285
--- 8392,8400 ----
Karsten Hopp 81c285
      buf_T	*buf;		/* new curbuf */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*win;
Karsten Hopp 81c285
! #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
!     int		save_ea;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      /* Find a window that is for the new buffer */
Karsten Hopp 81c285
      if (buf == curbuf)		/* be quick when buf is curbuf */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8407,8448 ****
Karsten Hopp 81c285
  	win = NULL;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /*
Karsten Hopp 81c285
!      * Prefer to use an existing window for the buffer, it has the least side
Karsten Hopp 81c285
!      * effects (esp. if "buf" is curbuf).
Karsten Hopp 81c285
!      * Otherwise, use curwin for "buf".  It might make some items in the
Karsten Hopp 81c285
!      * window invalid.  At least save the cursor and topline.
Karsten Hopp 81c285
!      */
Karsten Hopp 81c285
      if (win != NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	/* there is a window for "buf", make it the curwin */
Karsten Hopp 81c285
! 	aco->save_curwin = curwin;
Karsten Hopp 81c285
  	curwin = win;
Karsten Hopp 81c285
- 	aco->save_buf = win->w_buffer;
Karsten Hopp 81c285
- 	aco->new_curwin = win;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	/* there is no window for "buf", use curwin */
Karsten Hopp 81c285
! 	aco->save_curwin = NULL;
Karsten Hopp 81c285
! 	aco->save_buf = curbuf;
Karsten Hopp 81c285
! 	--curbuf->b_nwindows;
Karsten Hopp 81c285
  	curwin->w_buffer = buf;
Karsten Hopp 81c285
  	++buf->b_nwindows;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	/* save cursor and topline, set them to safe values */
Karsten Hopp 81c285
! 	aco->save_cursor = curwin->w_cursor;
Karsten Hopp 81c285
! 	curwin->w_cursor.lnum = 1;
Karsten Hopp 81c285
! 	curwin->w_cursor.col = 0;
Karsten Hopp 81c285
! 	aco->save_topline = curwin->w_topline;
Karsten Hopp 81c285
! 	curwin->w_topline = 1;
Karsten Hopp 81c285
! #ifdef FEAT_DIFF
Karsten Hopp 81c285
! 	aco->save_topfill = curwin->w_topfill;
Karsten Hopp 81c285
! 	curwin->w_topfill = 0;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
--- 8408,8460 ----
Karsten Hopp 81c285
  	win = NULL;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* Allocate "aucmd_win" when needed.  If this fails (out of memory) fall
Karsten Hopp 81c285
!      * back to using the current window. */
Karsten Hopp 81c285
!     if (win == NULL && aucmd_win == NULL)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	win_alloc_aucmd_win();
Karsten Hopp 81c285
! 	if (aucmd_win == NULL)
Karsten Hopp 81c285
! 	    win = curwin;
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     aco->save_curwin = curwin;
Karsten Hopp 81c285
!     aco->save_curbuf = curbuf;
Karsten Hopp 81c285
      if (win != NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	/* There is a window for "buf" in the current tab page, make it the
Karsten Hopp 81c285
! 	 * curwin.  This is preferred, it has the least side effects (esp. if
Karsten Hopp 81c285
! 	 * "buf" is curbuf). */
Karsten Hopp 81c285
  	curwin = win;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	/* There is no window for "buf", use "aucmd_win".  To minimize the side
Karsten Hopp 81c285
! 	 * effects, insert it in a the current tab page.
Karsten Hopp 81c285
! 	 * Anything related to a window (e.g., setting folds) may have
Karsten Hopp 81c285
! 	 * unexpected results. */
Karsten Hopp 81c285
! 	curwin = aucmd_win;
Karsten Hopp 81c285
  	curwin->w_buffer = buf;
Karsten Hopp 81c285
  	++buf->b_nwindows;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
! 	/* Split the current window, put the aucmd_win in the upper half. */
Karsten Hopp 81c285
! 	make_snapshot(SNAP_AUCMD_IDX);
Karsten Hopp 81c285
! 	save_ea = p_ea;
Karsten Hopp 81c285
! 	p_ea = FALSE;
Karsten Hopp 81c285
! 	(void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
Karsten Hopp 81c285
! 	(void)win_comp_pos();   /* recompute window positions */
Karsten Hopp 81c285
! 	p_ea = save_ea;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
! 	/* set cursor and topline to safe values */
Karsten Hopp 81c285
! 	curwin_init();
Karsten Hopp 81c285
! #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
! 	curwin->w_wincol = 0;
Karsten Hopp 81c285
! 	curwin->w_width = Columns;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
+     aco->new_curwin = curwin;
Karsten Hopp 81c285
+     aco->new_curbuf = curbuf;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8454,8474 ****
Karsten Hopp 81c285
  aucmd_restbuf(aco)
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure holding saved values */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     if (aco->save_curwin != NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* restore curwin */
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
  	if (win_valid(aco->save_curwin))
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    /* restore the buffer which was previously edited by curwin, if
Karsten Hopp 81c285
! 	     * it's still the same window and it's valid */
Karsten Hopp 81c285
  	    if (curwin == aco->new_curwin
Karsten Hopp 81c285
! 		    && buf_valid(aco->save_buf)
Karsten Hopp 81c285
! 		    && aco->save_buf->b_ml.ml_mfp != NULL)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		--curbuf->b_nwindows;
Karsten Hopp 81c285
! 		curbuf = aco->save_buf;
Karsten Hopp 81c285
  		curwin->w_buffer = curbuf;
Karsten Hopp 81c285
  		++curbuf->b_nwindows;
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
--- 8466,8551 ----
Karsten Hopp 81c285
  aucmd_restbuf(aco)
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure holding saved values */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
!     int dummy;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     if (aco->new_curwin == aucmd_win)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	--curbuf->b_nwindows;
Karsten Hopp 81c285
! #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
! 	/* Find "aucmd_win", it can't be closed, but it may be in another tab
Karsten Hopp 81c285
! 	 * page. */
Karsten Hopp 81c285
! 	if (curwin != aucmd_win)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    tabpage_T	*tp;
Karsten Hopp 81c285
! 	    win_T	*wp;
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
! 	    FOR_ALL_TAB_WINDOWS(tp, wp)
Karsten Hopp 81c285
! 	    {
Karsten Hopp 81c285
! 		if (wp == aucmd_win)
Karsten Hopp 81c285
! 		{
Karsten Hopp 81c285
! 		    if (tp != curtab)
Karsten Hopp 81c285
! 			goto_tabpage_tp(tp);
Karsten Hopp 81c285
! 		    win_goto(aucmd_win);
Karsten Hopp 81c285
! 		    break;
Karsten Hopp 81c285
! 		}
Karsten Hopp 81c285
! 	    }
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
! 	/* Remove the window and frame from the tree of frames. */
Karsten Hopp 81c285
! 	(void)winframe_remove(curwin, &dummy, NULL);
Karsten Hopp 81c285
! 	win_remove(curwin, NULL);
Karsten Hopp 81c285
! 	last_status(FALSE);	    /* may need to remove last status line */
Karsten Hopp 81c285
! 	restore_snapshot(SNAP_AUCMD_IDX, FALSE);
Karsten Hopp 81c285
! 	(void)win_comp_pos();   /* recompute window positions */
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
! 	if (win_valid(aco->save_curwin))
Karsten Hopp 81c285
! 	    curwin = aco->save_curwin;
Karsten Hopp 81c285
! 	else
Karsten Hopp 81c285
! 	    /* Hmm, original window disappeared.  Just use the first one. */
Karsten Hopp 81c285
! 	    curwin = firstwin;
Karsten Hopp 81c285
! # ifdef FEAT_EVAL
Karsten Hopp 81c285
! 	vars_clear(&aucmd_win->w_vars.dv_hashtab);  /* free all w: variables */
Karsten Hopp 81c285
! # endif
Karsten Hopp 81c285
! #else
Karsten Hopp 81c285
! 	curwin = aco->save_curwin;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
! 	curbuf = curwin->w_buffer;
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
! 	/* the buffer contents may have changed */
Karsten Hopp 81c285
! 	check_cursor();
Karsten Hopp 81c285
! 	if (curwin->w_topline > curbuf->b_ml.ml_line_count)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    curwin->w_topline = curbuf->b_ml.ml_line_count;
Karsten Hopp 81c285
! #ifdef FEAT_DIFF
Karsten Hopp 81c285
! 	    curwin->w_topfill = 0;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! #if defined(FEAT_GUI)
Karsten Hopp 81c285
! 	/* Hide the scrollbars from the aucmd_win and update. */
Karsten Hopp 81c285
! 	gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_LEFT], FALSE);
Karsten Hopp 81c285
! 	gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_RIGHT], FALSE);
Karsten Hopp 81c285
! 	gui_may_update_scrollbars();
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
!     else
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* restore curwin */
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
  	if (win_valid(aco->save_curwin))
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 	    /* Restore the buffer which was previously edited by curwin, if
Karsten Hopp 81c285
! 	     * it was chagned, we are still the same window and the buffer is
Karsten Hopp 81c285
! 	     * valid. */
Karsten Hopp 81c285
  	    if (curwin == aco->new_curwin
Karsten Hopp 81c285
! 		    && curbuf != aco->new_curbuf
Karsten Hopp 81c285
! 		    && buf_valid(aco->new_curbuf)
Karsten Hopp 81c285
! 		    && aco->new_curbuf->b_ml.ml_mfp != NULL)
Karsten Hopp 81c285
  	    {
Karsten Hopp 81c285
  		--curbuf->b_nwindows;
Karsten Hopp 81c285
! 		curbuf = aco->new_curbuf;
Karsten Hopp 81c285
  		curwin->w_buffer = curbuf;
Karsten Hopp 81c285
  		++curbuf->b_nwindows;
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8477,8510 ****
Karsten Hopp 81c285
  	    curbuf = curwin->w_buffer;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
-     else
Karsten Hopp 81c285
-     {
Karsten Hopp 81c285
- 	/* restore buffer for curwin if it still exists and is loaded */
Karsten Hopp 81c285
- 	if (buf_valid(aco->save_buf) && aco->save_buf->b_ml.ml_mfp != NULL)
Karsten Hopp 81c285
- 	{
Karsten Hopp 81c285
- 	    --curbuf->b_nwindows;
Karsten Hopp 81c285
- 	    curbuf = aco->save_buf;
Karsten Hopp 81c285
- 	    curwin->w_buffer = curbuf;
Karsten Hopp 81c285
- 	    ++curbuf->b_nwindows;
Karsten Hopp 81c285
- 	    curwin->w_cursor = aco->save_cursor;
Karsten Hopp 81c285
- 	    check_cursor();
Karsten Hopp 81c285
- 	    /* check topline < line_count, in case lines got deleted */
Karsten Hopp 81c285
- 	    if (aco->save_topline <= curbuf->b_ml.ml_line_count)
Karsten Hopp 81c285
- 	    {
Karsten Hopp 81c285
- 		curwin->w_topline = aco->save_topline;
Karsten Hopp 81c285
- #ifdef FEAT_DIFF
Karsten Hopp 81c285
- 		curwin->w_topfill = aco->save_topfill;
Karsten Hopp 81c285
- #endif
Karsten Hopp 81c285
- 	    }
Karsten Hopp 81c285
- 	    else
Karsten Hopp 81c285
- 	    {
Karsten Hopp 81c285
- 		curwin->w_topline = curbuf->b_ml.ml_line_count;
Karsten Hopp 81c285
- #ifdef FEAT_DIFF
Karsten Hopp 81c285
- 		curwin->w_topfill = 0;
Karsten Hopp 81c285
- #endif
Karsten Hopp 81c285
- 	    }
Karsten Hopp 81c285
- 	}
Karsten Hopp 81c285
-     }
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static int	autocmd_nested = FALSE;
Karsten Hopp 81c285
--- 8554,8559 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 9419,9427 ****
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure to save values in */
Karsten Hopp 81c285
      buf_T	*buf;		/* new curbuf */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     aco->save_buf = curbuf;
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
      curwin->w_buffer = buf;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
--- 9468,9478 ----
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure to save values in */
Karsten Hopp 81c285
      buf_T	*buf;		/* new curbuf */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     aco->save_curbuf = curbuf;
Karsten Hopp 81c285
!     --curbuf->b_nwindows;
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
      curwin->w_buffer = buf;
Karsten Hopp 81c285
+     ++curbuf->b_nwindows;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 9432,9439 ****
Karsten Hopp 81c285
  aucmd_restbuf(aco)
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure holding saved values */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     curbuf = aco->save_buf;
Karsten Hopp 81c285
      curwin->w_buffer = curbuf;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif	/* FEAT_AUTOCMD */
Karsten Hopp 81c285
--- 9483,9492 ----
Karsten Hopp 81c285
  aucmd_restbuf(aco)
Karsten Hopp 81c285
      aco_save_T	*aco;		/* structure holding saved values */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     --curbuf->b_nwindows;
Karsten Hopp 81c285
!     curbuf = aco->save_curbuf;
Karsten Hopp 81c285
      curwin->w_buffer = curbuf;
Karsten Hopp 81c285
+     ++curbuf->b_nwindows;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif	/* FEAT_AUTOCMD */
Karsten Hopp 81c285
*** ../vim-7.2.202/src/globals.h	2009-06-16 15:23:07.000000000 +0200
Karsten Hopp 81c285
--- src/globals.h	2009-06-12 21:10:30.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 539,544 ****
Karsten Hopp 81c285
--- 539,548 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  EXTERN win_T	*curwin;	/* currently active window */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+ EXTERN win_T	*aucmd_win;	/* window used in aucmd_prepbuf() */
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * The window layout is kept in a tree of frames.  topframe points to the top
Karsten Hopp 81c285
   * of the tree.
Karsten Hopp 81c285
*** ../vim-7.2.202/src/gui.c	2009-05-21 23:25:38.000000000 +0200
Karsten Hopp 81c285
--- src/gui.c	2009-06-11 20:58:05.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3879,3884 ****
Karsten Hopp 81c285
--- 3879,3899 ----
Karsten Hopp 81c285
   * Scrollbar stuff:
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ /*
Karsten Hopp 81c285
+  * Called when something in the window layout has changed.
Karsten Hopp 81c285
+  */
Karsten Hopp 81c285
+     void
Karsten Hopp 81c285
+ gui_may_update_scrollbars()
Karsten Hopp 81c285
+ {
Karsten Hopp 81c285
+     if (gui.in_use && starting == 0)
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	out_flush();
Karsten Hopp 81c285
+ 	gui_init_which_components(NULL);
Karsten Hopp 81c285
+ 	gui_update_scrollbars(TRUE);
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+     need_mouse_correct = TRUE;
Karsten Hopp 81c285
+ }
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
  gui_update_scrollbars(force)
Karsten Hopp 81c285
      int		force;	    /* Force all scrollbars to get updated */
Karsten Hopp 81c285
*** ../vim-7.2.202/src/if_perl.xs	2008-12-03 13:18:16.000000000 +0100
Karsten Hopp 81c285
--- src/if_perl.xs	2009-06-03 17:52:51.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1234,1240 ****
Karsten Hopp 81c285
  		    {
Karsten Hopp 81c285
  			ml_delete(lnum, 0);
Karsten Hopp 81c285
  			deleted_lines_mark(lnum, 1L);
Karsten Hopp 81c285
! 			if (aco.save_buf == curbuf)
Karsten Hopp 81c285
  			    check_cursor();
Karsten Hopp 81c285
  		    }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 1236,1242 ----
Karsten Hopp 81c285
  		    {
Karsten Hopp 81c285
  			ml_delete(lnum, 0);
Karsten Hopp 81c285
  			deleted_lines_mark(lnum, 1L);
Karsten Hopp 81c285
! 			if (aco.save_curbuf == curbuf)
Karsten Hopp 81c285
  			    check_cursor();
Karsten Hopp 81c285
  		    }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
*** ../vim-7.2.202/src/proto/gui.pro	2007-05-05 19:42:19.000000000 +0200
Karsten Hopp 81c285
--- src/proto/gui.pro	2009-06-11 20:58:08.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 43,48 ****
Karsten Hopp 81c285
--- 43,49 ----
Karsten Hopp 81c285
  void gui_create_scrollbar __ARGS((scrollbar_T *sb, int type, win_T *wp));
Karsten Hopp 81c285
  scrollbar_T *gui_find_scrollbar __ARGS((long ident));
Karsten Hopp 81c285
  void gui_drag_scrollbar __ARGS((scrollbar_T *sb, long value, int still_dragging));
Karsten Hopp 81c285
+ void gui_may_update_scrollbars __ARGS((void));
Karsten Hopp 81c285
  void gui_update_scrollbars __ARGS((int force));
Karsten Hopp 81c285
  int gui_do_scroll __ARGS((void));
Karsten Hopp 81c285
  int gui_do_horiz_scroll __ARGS((void));
Karsten Hopp 81c285
*** ../vim-7.2.202/src/proto/window.pro	2007-07-26 22:57:45.000000000 +0200
Karsten Hopp 81c285
--- src/proto/window.pro	2009-06-10 21:20:39.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1,6 ****
Karsten Hopp 81c285
--- 1,7 ----
Karsten Hopp 81c285
  /* window.c */
Karsten Hopp 81c285
  void do_window __ARGS((int nchar, long Prenum, int xchar));
Karsten Hopp 81c285
  int win_split __ARGS((int size, int flags));
Karsten Hopp 81c285
+ int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
Karsten Hopp 81c285
  int win_valid __ARGS((win_T *win));
Karsten Hopp 81c285
  int win_count __ARGS((void));
Karsten Hopp 81c285
  int make_windows __ARGS((int count, int vertical));
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 10,18 ****
Karsten Hopp 81c285
--- 11,21 ----
Karsten Hopp 81c285
  void win_close __ARGS((win_T *win, int free_buf));
Karsten Hopp 81c285
  void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
Karsten Hopp 81c285
  void win_free_all __ARGS((void));
Karsten Hopp 81c285
+ win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
Karsten Hopp 81c285
  void close_others __ARGS((int message, int forceit));
Karsten Hopp 81c285
  void curwin_init __ARGS((void));
Karsten Hopp 81c285
  int win_alloc_first __ARGS((void));
Karsten Hopp 81c285
+ void win_alloc_aucmd_win __ARGS((void));
Karsten Hopp 81c285
  void win_init_size __ARGS((void));
Karsten Hopp 81c285
  void free_tabpage __ARGS((tabpage_T *tp));
Karsten Hopp 81c285
  int win_new_tabpage __ARGS((int after));
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 30,35 ****
Karsten Hopp 81c285
--- 33,40 ----
Karsten Hopp 81c285
  void win_enter __ARGS((win_T *wp, int undo_sync));
Karsten Hopp 81c285
  win_T *buf_jump_open_win __ARGS((buf_T *buf));
Karsten Hopp 81c285
  win_T *buf_jump_open_tab __ARGS((buf_T *buf));
Karsten Hopp 81c285
+ void win_append __ARGS((win_T *after, win_T *wp));
Karsten Hopp 81c285
+ void win_remove __ARGS((win_T *wp, tabpage_T *tp));
Karsten Hopp 81c285
  int win_alloc_lines __ARGS((win_T *wp));
Karsten Hopp 81c285
  void win_free_lsize __ARGS((win_T *wp));
Karsten Hopp 81c285
  void shell_new_rows __ARGS((void));
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 58,63 ****
Karsten Hopp 81c285
--- 63,70 ----
Karsten Hopp 81c285
  int min_rows __ARGS((void));
Karsten Hopp 81c285
  int only_one_window __ARGS((void));
Karsten Hopp 81c285
  void check_lnums __ARGS((int do_curwin));
Karsten Hopp 81c285
+ void make_snapshot __ARGS((int idx));
Karsten Hopp 81c285
+ void restore_snapshot __ARGS((int idx, int close_curwin));
Karsten Hopp 81c285
  int win_hasvertsplit __ARGS((void));
Karsten Hopp 81c285
  int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
Karsten Hopp 81c285
  int match_delete __ARGS((win_T *wp, int id, int perr));
Karsten Hopp 81c285
*** ../vim-7.2.202/src/screen.c	2009-05-17 13:30:58.000000000 +0200
Karsten Hopp 81c285
--- src/screen.c	2009-06-10 16:41:45.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 7495,7500 ****
Karsten Hopp 81c285
--- 7495,7504 ----
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+     if (aucmd_win != NULL && win_alloc_lines(aucmd_win) == FAIL)
Karsten Hopp 81c285
+ 	outofmem = TRUE;
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
  give_up:
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
*** ../vim-7.2.202/src/structs.h	2009-05-16 16:36:25.000000000 +0200
Karsten Hopp 81c285
--- src/structs.h	2009-06-13 12:51:56.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1621,1626 ****
Karsten Hopp 81c285
--- 1621,1634 ----
Karsten Hopp 81c285
  };
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ #define SNAP_HELP_IDX	0
Karsten Hopp 81c285
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+ # define SNAP_AUCMD_IDX 1
Karsten Hopp 81c285
+ # define SNAP_COUNT	2
Karsten Hopp 81c285
+ #else
Karsten Hopp 81c285
+ # define SNAP_COUNT	1
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Tab pages point to the top frame of each tab page.
Karsten Hopp 81c285
   * Note: Most values are NOT valid for the current tab page!  Use "curwin",
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1649,1655 ****
Karsten Hopp 81c285
      buf_T	    *(tp_diffbuf[DB_COUNT]);
Karsten Hopp 81c285
      int		    tp_diff_invalid;	/* list of diffs is outdated */
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     frame_T	    *tp_snapshot;    /* window layout snapshot */
Karsten Hopp 81c285
  #ifdef FEAT_EVAL
Karsten Hopp 81c285
      dictitem_T	    tp_winvar;	    /* variable for "t:" Dictionary */
Karsten Hopp 81c285
      dict_T	    tp_vars;	    /* internal variables, local to tab page */
Karsten Hopp 81c285
--- 1657,1663 ----
Karsten Hopp 81c285
      buf_T	    *(tp_diffbuf[DB_COUNT]);
Karsten Hopp 81c285
      int		    tp_diff_invalid;	/* list of diffs is outdated */
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     frame_T	    *(tp_snapshot[SNAP_COUNT]);  /* window layout snapshots */
Karsten Hopp 81c285
  #ifdef FEAT_EVAL
Karsten Hopp 81c285
      dictitem_T	    tp_winvar;	    /* variable for "t:" Dictionary */
Karsten Hopp 81c285
      dict_T	    tp_vars;	    /* internal variables, local to tab page */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2276,2291 ****
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
  typedef struct
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     buf_T	*save_buf;	/* saved curbuf */
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
!     buf_T	*new_curbuf;	/* buffer to be used */
Karsten Hopp 81c285
!     win_T	*save_curwin;	/* saved curwin, NULL if it didn't change */
Karsten Hopp 81c285
!     win_T	*new_curwin;	/* new curwin if save_curwin != NULL */
Karsten Hopp 81c285
!     pos_T	save_cursor;	/* saved cursor pos of save_curwin */
Karsten Hopp 81c285
!     linenr_T	save_topline;	/* saved topline of save_curwin */
Karsten Hopp 81c285
! # ifdef FEAT_DIFF
Karsten Hopp 81c285
!     int		save_topfill;	/* saved topfill of save_curwin */
Karsten Hopp 81c285
! # endif
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  } aco_save_T;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 2284,2294 ----
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
  typedef struct
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     buf_T	*save_curbuf;	/* saved curbuf */
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
!     win_T	*save_curwin;	/* saved curwin */
Karsten Hopp 81c285
!     win_T	*new_curwin;	/* new curwin */
Karsten Hopp 81c285
!     buf_T	*new_curbuf;	/* new curbuf */
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  } aco_save_T;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
*** ../vim-7.2.202/src/window.c	2009-05-21 23:25:38.000000000 +0200
Karsten Hopp 81c285
--- src/window.c	2009-06-12 22:29:33.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 11,18 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static int path_is_url __ARGS((char_u *p));
Karsten Hopp 81c285
  #if defined(FEAT_WINDOWS) || defined(PROTO)
Karsten Hopp 81c285
- static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
Karsten Hopp 81c285
  static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
Karsten Hopp 81c285
  static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
Karsten Hopp 81c285
  static void frame_setheight __ARGS((frame_T *curfrp, int height));
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
--- 11,18 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static int path_is_url __ARGS((char_u *p));
Karsten Hopp 81c285
  #if defined(FEAT_WINDOWS) || defined(PROTO)
Karsten Hopp 81c285
  static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
Karsten Hopp 81c285
+ static void win_init_some __ARGS((win_T *newp, win_T *oldp));
Karsten Hopp 81c285
  static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
Karsten Hopp 81c285
  static void frame_setheight __ARGS((frame_T *curfrp, int height));
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 23,30 ****
Karsten Hopp 81c285
  static void win_totop __ARGS((int size, int flags));
Karsten Hopp 81c285
  static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
Karsten Hopp 81c285
  static int last_window __ARGS((void));
Karsten Hopp 81c285
  static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
Karsten Hopp 81c285
- static win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
Karsten Hopp 81c285
  static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
Karsten Hopp 81c285
  static tabpage_T *alt_tabpage __ARGS((void));
Karsten Hopp 81c285
  static win_T *frame2win __ARGS((frame_T *frp));
Karsten Hopp 81c285
--- 23,30 ----
Karsten Hopp 81c285
  static void win_totop __ARGS((int size, int flags));
Karsten Hopp 81c285
  static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
Karsten Hopp 81c285
  static int last_window __ARGS((void));
Karsten Hopp 81c285
+ static int one_window __ARGS((void));
Karsten Hopp 81c285
  static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
Karsten Hopp 81c285
  static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
Karsten Hopp 81c285
  static tabpage_T *alt_tabpage __ARGS((void));
Karsten Hopp 81c285
  static win_T *frame2win __ARGS((frame_T *frp));
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 41,46 ****
Karsten Hopp 81c285
--- 41,47 ----
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  static int win_alloc_firstwin __ARGS((win_T *oldwin));
Karsten Hopp 81c285
+ static void new_frame __ARGS((win_T *wp));
Karsten Hopp 81c285
  #if defined(FEAT_WINDOWS) || defined(PROTO)
Karsten Hopp 81c285
  static tabpage_T *alloc_tabpage __ARGS((void));
Karsten Hopp 81c285
  static int leave_tabpage __ARGS((buf_T *new_curbuf));
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 49,56 ****
Karsten Hopp 81c285
  static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
Karsten Hopp 81c285
  static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
Karsten Hopp 81c285
  static void win_free __ARGS((win_T *wp, tabpage_T *tp));
Karsten Hopp 81c285
- static void win_append __ARGS((win_T *, win_T *));
Karsten Hopp 81c285
- static void win_remove __ARGS((win_T *, tabpage_T *tp));
Karsten Hopp 81c285
  static void frame_append __ARGS((frame_T *after, frame_T *frp));
Karsten Hopp 81c285
  static void frame_insert __ARGS((frame_T *before, frame_T *frp));
Karsten Hopp 81c285
  static void frame_remove __ARGS((frame_T *frp));
Karsten Hopp 81c285
--- 50,55 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 62,78 ****
Karsten Hopp 81c285
  static void frame_add_height __ARGS((frame_T *frp, int n));
Karsten Hopp 81c285
  static void last_status_rec __ARGS((frame_T *fr, int statusline));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
- static void make_snapshot __ARGS((void));
Karsten Hopp 81c285
  static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
Karsten Hopp 81c285
! static void clear_snapshot __ARGS((tabpage_T *tp));
Karsten Hopp 81c285
  static void clear_snapshot_rec __ARGS((frame_T *fr));
Karsten Hopp 81c285
- static void restore_snapshot __ARGS((int close_curwin));
Karsten Hopp 81c285
  static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
Karsten Hopp 81c285
  static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif /* FEAT_WINDOWS */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static win_T *win_alloc __ARGS((win_T *after));
Karsten Hopp 81c285
  static void win_new_height __ARGS((win_T *, int));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #define URL_SLASH	1		/* path_is_url() has found "://" */
Karsten Hopp 81c285
--- 61,75 ----
Karsten Hopp 81c285
  static void frame_add_height __ARGS((frame_T *frp, int n));
Karsten Hopp 81c285
  static void last_status_rec __ARGS((frame_T *fr, int statusline));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
Karsten Hopp 81c285
! static void clear_snapshot __ARGS((tabpage_T *tp, int idx));
Karsten Hopp 81c285
  static void clear_snapshot_rec __ARGS((frame_T *fr));
Karsten Hopp 81c285
  static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
Karsten Hopp 81c285
  static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif /* FEAT_WINDOWS */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static win_T *win_alloc __ARGS((win_T *after, int hidden));
Karsten Hopp 81c285
  static void win_new_height __ARGS((win_T *, int));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #define URL_SLASH	1		/* path_is_url() has found "://" */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 259,265 ****
Karsten Hopp 81c285
  /* cursor to previous window with wrap around */
Karsten Hopp 81c285
      case 'W':
Karsten Hopp 81c285
  		CHECK_CMDWIN
Karsten Hopp 81c285
! 		if (lastwin == firstwin && Prenum != 1)	/* just one window */
Karsten Hopp 81c285
  		    beep_flush();
Karsten Hopp 81c285
  		else
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
--- 256,262 ----
Karsten Hopp 81c285
  /* cursor to previous window with wrap around */
Karsten Hopp 81c285
      case 'W':
Karsten Hopp 81c285
  		CHECK_CMDWIN
Karsten Hopp 81c285
! 		if (firstwin == lastwin && Prenum != 1)	/* just one window */
Karsten Hopp 81c285
  		    beep_flush();
Karsten Hopp 81c285
  		else
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 343,349 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /* move window to new tab page */
Karsten Hopp 81c285
      case 'T':
Karsten Hopp 81c285
! 		if (firstwin == lastwin)
Karsten Hopp 81c285
  		    MSG(_(m_onlyone));
Karsten Hopp 81c285
  		else
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
--- 340,346 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /* move window to new tab page */
Karsten Hopp 81c285
      case 'T':
Karsten Hopp 81c285
! 		if (one_window())
Karsten Hopp 81c285
  		    MSG(_(m_onlyone));
Karsten Hopp 81c285
  		else
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 679,687 ****
Karsten Hopp 81c285
      /* When creating the help window make a snapshot of the window layout.
Karsten Hopp 81c285
       * Otherwise clear the snapshot, it's now invalid. */
Karsten Hopp 81c285
      if (flags & WSP_HELP)
Karsten Hopp 81c285
! 	make_snapshot();
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	clear_snapshot(curtab);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      return win_split_ins(size, flags, NULL, 0);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
--- 676,684 ----
Karsten Hopp 81c285
      /* When creating the help window make a snapshot of the window layout.
Karsten Hopp 81c285
       * Otherwise clear the snapshot, it's now invalid. */
Karsten Hopp 81c285
      if (flags & WSP_HELP)
Karsten Hopp 81c285
! 	make_snapshot(SNAP_HELP_IDX);
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	clear_snapshot(curtab, SNAP_HELP_IDX);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      return win_split_ins(size, flags, NULL, 0);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 692,698 ****
Karsten Hopp 81c285
   * top/left/right/bottom.
Karsten Hopp 81c285
   * return FAIL for failure, OK otherwise
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static int
Karsten Hopp 81c285
  win_split_ins(size, flags, newwin, dir)
Karsten Hopp 81c285
      int		size;
Karsten Hopp 81c285
      int		flags;
Karsten Hopp 81c285
--- 689,695 ----
Karsten Hopp 81c285
   * top/left/right/bottom.
Karsten Hopp 81c285
   * return FAIL for failure, OK otherwise
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     int
Karsten Hopp 81c285
  win_split_ins(size, flags, newwin, dir)
Karsten Hopp 81c285
      int		size;
Karsten Hopp 81c285
      int		flags;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 893,906 ****
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* new window below/right of current one */
Karsten Hopp 81c285
  	if (newwin == NULL)
Karsten Hopp 81c285
! 	    wp = win_alloc(oldwin);
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
  	    win_append(oldwin, wp);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (newwin == NULL)
Karsten Hopp 81c285
! 	    wp = win_alloc(oldwin->w_prev);
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
  	    win_append(oldwin->w_prev, wp);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
--- 890,903 ----
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* new window below/right of current one */
Karsten Hopp 81c285
  	if (newwin == NULL)
Karsten Hopp 81c285
! 	    wp = win_alloc(oldwin, FALSE);
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
  	    win_append(oldwin, wp);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (newwin == NULL)
Karsten Hopp 81c285
! 	    wp = win_alloc(oldwin->w_prev, FALSE);
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
  	    win_append(oldwin->w_prev, wp);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 910,915 ****
Karsten Hopp 81c285
--- 907,919 ----
Karsten Hopp 81c285
  	if (wp == NULL)
Karsten Hopp 81c285
  	    return FAIL;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ 	new_frame(wp);
Karsten Hopp 81c285
+ 	if (wp->w_frame == NULL)
Karsten Hopp 81c285
+ 	{
Karsten Hopp 81c285
+ 	    win_free(wp, NULL);
Karsten Hopp 81c285
+ 	    return FAIL;
Karsten Hopp 81c285
+ 	}
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  	/* make the contents of the new window the same as the current one */
Karsten Hopp 81c285
  	win_init(wp, curwin, flags);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 970,982 ****
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (newwin == NULL)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	/* Create a frame for the new window. */
Karsten Hopp 81c285
! 	frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
Karsten Hopp 81c285
! 	frp->fr_layout = FR_LEAF;
Karsten Hopp 81c285
! 	frp->fr_win = wp;
Karsten Hopp 81c285
! 	wp->w_frame = frp;
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
  	frp = newwin->w_frame;
Karsten Hopp 81c285
      frp->fr_parent = curfrp->fr_parent;
Karsten Hopp 81c285
--- 974,980 ----
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (newwin == NULL)
Karsten Hopp 81c285
! 	frp = wp->w_frame;
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
  	frp = newwin->w_frame;
Karsten Hopp 81c285
      frp->fr_parent = curfrp->fr_parent;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1156,1161 ****
Karsten Hopp 81c285
--- 1154,1160 ----
Karsten Hopp 81c285
      return OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Initialize window "newp" from window "oldp".
Karsten Hopp 81c285
   * Used when splitting a window and when creating a new tab page.
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1204,1217 ****
Karsten Hopp 81c285
      if (oldp->w_localdir != NULL)
Karsten Hopp 81c285
  	newp->w_localdir = vim_strsave(oldp->w_localdir);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* Use the same argument list. */
Karsten Hopp 81c285
!     newp->w_alist = oldp->w_alist;
Karsten Hopp 81c285
!     ++newp->w_alist->al_refcount;
Karsten Hopp 81c285
!     newp->w_arg_idx = oldp->w_arg_idx;
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     /*
Karsten Hopp 81c285
!      * copy tagstack and options from existing window
Karsten Hopp 81c285
!      */
Karsten Hopp 81c285
      for (i = 0; i < oldp->w_tagstacklen; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	newp->w_tagstack[i] = oldp->w_tagstack[i];
Karsten Hopp 81c285
--- 1203,1209 ----
Karsten Hopp 81c285
      if (oldp->w_localdir != NULL)
Karsten Hopp 81c285
  	newp->w_localdir = vim_strsave(oldp->w_localdir);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* copy tagstack and folds */
Karsten Hopp 81c285
      for (i = 0; i < oldp->w_tagstacklen; i++)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	newp->w_tagstack[i] = oldp->w_tagstack[i];
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1221,1230 ****
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      newp->w_tagstackidx = oldp->w_tagstackidx;
Karsten Hopp 81c285
      newp->w_tagstacklen = oldp->w_tagstacklen;
Karsten Hopp 81c285
-     win_copy_options(oldp, newp);
Karsten Hopp 81c285
  # ifdef FEAT_FOLDING
Karsten Hopp 81c285
      copyFoldingState(oldp, newp);
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif /* FEAT_WINDOWS */
Karsten Hopp 81c285
--- 1213,1241 ----
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      newp->w_tagstackidx = oldp->w_tagstackidx;
Karsten Hopp 81c285
      newp->w_tagstacklen = oldp->w_tagstacklen;
Karsten Hopp 81c285
  # ifdef FEAT_FOLDING
Karsten Hopp 81c285
      copyFoldingState(oldp, newp);
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     win_init_some(newp, oldp);
Karsten Hopp 81c285
+ }
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+ /*
Karsten Hopp 81c285
+  * Initialize window "newp" from window"old".
Karsten Hopp 81c285
+  * Only the essential things are copied.
Karsten Hopp 81c285
+  */
Karsten Hopp 81c285
+     static void
Karsten Hopp 81c285
+ win_init_some(newp, oldp)
Karsten Hopp 81c285
+     win_T	*newp;
Karsten Hopp 81c285
+     win_T	*oldp;
Karsten Hopp 81c285
+ {
Karsten Hopp 81c285
+     /* Use the same argument list. */
Karsten Hopp 81c285
+     newp->w_alist = oldp->w_alist;
Karsten Hopp 81c285
+     ++newp->w_alist->al_refcount;
Karsten Hopp 81c285
+     newp->w_arg_idx = oldp->w_arg_idx;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     /* copy options from existing window */
Karsten Hopp 81c285
+     win_copy_options(oldp, newp);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #endif /* FEAT_WINDOWS */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 1565,1579 ****
Karsten Hopp 81c285
  #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
       * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
!     if (gui.in_use)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	out_flush();
Karsten Hopp 81c285
! 	gui_init_which_components(NULL);
Karsten Hopp 81c285
! 	gui_update_scrollbars(TRUE);
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
!     need_mouse_correct = TRUE;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
--- 1576,1583 ----
Karsten Hopp 81c285
  #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
       * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
!     gui_may_update_scrollbars();
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2048,2060 ****
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
!  * Return TRUE if the current window is the only window that exists.
Karsten Hopp 81c285
   * Returns FALSE if there is a window, possibly in another tab page.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static int
Karsten Hopp 81c285
  last_window()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     return (lastwin == firstwin && first_tabpage->tp_next == NULL);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
--- 2052,2091 ----
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
!  * Return TRUE if the current window is the only window that exists (ignoring
Karsten Hopp 81c285
!  * "aucmd_win").
Karsten Hopp 81c285
   * Returns FALSE if there is a window, possibly in another tab page.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static int
Karsten Hopp 81c285
  last_window()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     return (one_window() && first_tabpage->tp_next == NULL);
Karsten Hopp 81c285
! }
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
! /*
Karsten Hopp 81c285
!  * Return TRUE if there is only one window other than "aucmd_win" in the
Karsten Hopp 81c285
!  * current tab page.
Karsten Hopp 81c285
!  */
Karsten Hopp 81c285
!     static int
Karsten Hopp 81c285
! one_window()
Karsten Hopp 81c285
! {
Karsten Hopp 81c285
! #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
!     win_T	*wp;
Karsten Hopp 81c285
!     int		seen_one = FALSE;
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     FOR_ALL_WINDOWS(wp)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	if (wp != aucmd_win)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    if (seen_one)
Karsten Hopp 81c285
! 		return FALSE;
Karsten Hopp 81c285
! 	    seen_one = TRUE;
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
!     return TRUE;
Karsten Hopp 81c285
! #else
Karsten Hopp 81c285
!     return firstwin == lastwin;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2083,2088 ****
Karsten Hopp 81c285
--- 2114,2132 ----
Karsten Hopp 81c285
  	return;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+     if (win == aucmd_win)
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	EMSG(_("E813: Cannot close autocmd window"));
Karsten Hopp 81c285
+ 	return;
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+     if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	EMSG(_("E814: Cannot close window, only autocmd window would remain"));
Karsten Hopp 81c285
+ 	return;
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      /*
Karsten Hopp 81c285
       * When closing the last window in a tab page first go to another tab
Karsten Hopp 81c285
       * page and then close the window and the tab page.  This avoids that
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2112,2118 ****
Karsten Hopp 81c285
      if (win->w_buffer->b_help)
Karsten Hopp 81c285
  	help_window = TRUE;
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	clear_snapshot(curtab);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
      if (win == curwin)
Karsten Hopp 81c285
--- 2156,2162 ----
Karsten Hopp 81c285
      if (win->w_buffer->b_help)
Karsten Hopp 81c285
  	help_window = TRUE;
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	clear_snapshot(curtab, SNAP_HELP_IDX);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
      if (win == curwin)
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2229,2235 ****
Karsten Hopp 81c285
      /* After closing the help window, try restoring the window layout from
Karsten Hopp 81c285
       * before it was opened. */
Karsten Hopp 81c285
      if (help_window)
Karsten Hopp 81c285
! 	restore_snapshot(close_curwin);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
Karsten Hopp 81c285
--- 2273,2279 ----
Karsten Hopp 81c285
      /* After closing the help window, try restoring the window layout from
Karsten Hopp 81c285
       * before it was opened. */
Karsten Hopp 81c285
      if (help_window)
Karsten Hopp 81c285
! 	restore_snapshot(SNAP_HELP_IDX, close_curwin);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2344,2349 ****
Karsten Hopp 81c285
--- 2388,2401 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      while (firstwin != NULL)
Karsten Hopp 81c285
  	(void)win_free_mem(firstwin, &dummy, NULL);
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+ # ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+     if (aucmd_win != NULL)
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	(void)win_free_mem(aucmd_win, &dummy, NULL);
Karsten Hopp 81c285
+ 	aucmd_win = NULL;
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+ # endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2351,2357 ****
Karsten Hopp 81c285
   * Remove a window and its frame from the tree of frames.
Karsten Hopp 81c285
   * Returns a pointer to the window that got the freed up space.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static win_T *
Karsten Hopp 81c285
  winframe_remove(win, dirp, tp)
Karsten Hopp 81c285
      win_T	*win;
Karsten Hopp 81c285
      int		*dirp UNUSED;	/* set to 'v' or 'h' for direction if 'ea' */
Karsten Hopp 81c285
--- 2403,2409 ----
Karsten Hopp 81c285
   * Remove a window and its frame from the tree of frames.
Karsten Hopp 81c285
   * Returns a pointer to the window that got the freed up space.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     win_T *
Karsten Hopp 81c285
  winframe_remove(win, dirp, tp)
Karsten Hopp 81c285
      win_T	*win;
Karsten Hopp 81c285
      int		*dirp UNUSED;	/* set to 'v' or 'h' for direction if 'ea' */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3090,3096 ****
Karsten Hopp 81c285
      win_T	*nextwp;
Karsten Hopp 81c285
      int		r;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if (lastwin == firstwin)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (message
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
--- 3142,3148 ----
Karsten Hopp 81c285
      win_T	*nextwp;
Karsten Hopp 81c285
      int		r;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if (one_window())
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	if (message
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3194,3202 ****
Karsten Hopp 81c285
--- 3246,3275 ----
Karsten Hopp 81c285
      first_tabpage->tp_topframe = topframe;
Karsten Hopp 81c285
      curtab = first_tabpage;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
      return OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ #if defined(FEAT_AUTOCMD) || defined(PROTO)
Karsten Hopp 81c285
+ /*
Karsten Hopp 81c285
+  * Init "aucmd_win".  This can only be done after the first
Karsten Hopp 81c285
+  * window is fully initialized, thus it can't be in win_alloc_first().
Karsten Hopp 81c285
+  */
Karsten Hopp 81c285
+     void
Karsten Hopp 81c285
+ win_alloc_aucmd_win()
Karsten Hopp 81c285
+ {
Karsten Hopp 81c285
+     aucmd_win = win_alloc(NULL, TRUE);
Karsten Hopp 81c285
+     if (aucmd_win != NULL)
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	win_init_some(aucmd_win, curwin);
Karsten Hopp 81c285
+ # ifdef FEAT_SCROLLBIND
Karsten Hopp 81c285
+ 	aucmd_win->w_p_scb = FALSE;
Karsten Hopp 81c285
+ # endif
Karsten Hopp 81c285
+ 	new_frame(aucmd_win);
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+ }
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Allocate the first window or the first window in a new tab page.
Karsten Hopp 81c285
   * When "oldwin" is NULL create an empty buffer for it.
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3208,3214 ****
Karsten Hopp 81c285
  win_alloc_firstwin(oldwin)
Karsten Hopp 81c285
      win_T	*oldwin;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     curwin = win_alloc(NULL);
Karsten Hopp 81c285
      if (oldwin == NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* Very first window, need to create an empty buffer for it and
Karsten Hopp 81c285
--- 3281,3287 ----
Karsten Hopp 81c285
  win_alloc_firstwin(oldwin)
Karsten Hopp 81c285
      win_T	*oldwin;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     curwin = win_alloc(NULL, FALSE);
Karsten Hopp 81c285
      if (oldwin == NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
  	/* Very first window, need to create an empty buffer for it and
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3236,3256 ****
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     topframe = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
Karsten Hopp 81c285
!     if (topframe == NULL)
Karsten Hopp 81c285
  	return FAIL;
Karsten Hopp 81c285
!     topframe->fr_layout = FR_LEAF;
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
      topframe->fr_width = Columns;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      topframe->fr_height = Rows - p_ch;
Karsten Hopp 81c285
      topframe->fr_win = curwin;
Karsten Hopp 81c285
-     curwin->w_frame = topframe;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      return OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Initialize the window and frame size to the maximum.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
--- 3309,3344 ----
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     new_frame(curwin);
Karsten Hopp 81c285
!     if (curwin->w_frame == NULL)
Karsten Hopp 81c285
  	return FAIL;
Karsten Hopp 81c285
!     topframe = curwin->w_frame;
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
      topframe->fr_width = Columns;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      topframe->fr_height = Rows - p_ch;
Karsten Hopp 81c285
      topframe->fr_win = curwin;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      return OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
+  * Create a frame for window "wp".
Karsten Hopp 81c285
+  */
Karsten Hopp 81c285
+     static void
Karsten Hopp 81c285
+ new_frame(win_T *wp)
Karsten Hopp 81c285
+ {
Karsten Hopp 81c285
+     frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     wp->w_frame = frp;
Karsten Hopp 81c285
+     if (frp != NULL)
Karsten Hopp 81c285
+     {
Karsten Hopp 81c285
+ 	frp->fr_layout = FR_LEAF;
Karsten Hopp 81c285
+ 	frp->fr_win = wp;
Karsten Hopp 81c285
+     }
Karsten Hopp 81c285
+ }
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+ /*
Karsten Hopp 81c285
   * Initialize the window and frame size to the maximum.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3300,3309 ****
Karsten Hopp 81c285
  free_tabpage(tp)
Karsten Hopp 81c285
      tabpage_T	*tp;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  # ifdef FEAT_DIFF
Karsten Hopp 81c285
      diff_clear(tp);
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
!     clear_snapshot(tp);
Karsten Hopp 81c285
  #ifdef FEAT_EVAL
Karsten Hopp 81c285
      vars_clear(&tp->tp_vars.dv_hashtab);	/* free all t: variables */
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
--- 3388,3400 ----
Karsten Hopp 81c285
  free_tabpage(tp)
Karsten Hopp 81c285
      tabpage_T	*tp;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
+     int idx;
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  # ifdef FEAT_DIFF
Karsten Hopp 81c285
      diff_clear(tp);
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
!     for (idx = 0; idx < SNAP_COUNT; ++idx)
Karsten Hopp 81c285
! 	clear_snapshot(tp, idx);
Karsten Hopp 81c285
  #ifdef FEAT_EVAL
Karsten Hopp 81c285
      vars_clear(&tp->tp_vars.dv_hashtab);	/* free all t: variables */
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3370,3381 ****
Karsten Hopp 81c285
  #if defined(FEAT_GUI)
Karsten Hopp 81c285
  	/* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
  	 * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
! 	if (gui.in_use && starting == 0)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 	    gui_init_which_components(NULL);
Karsten Hopp 81c285
! 	    gui_update_scrollbars(TRUE);
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! 	need_mouse_correct = TRUE;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	redraw_all_later(CLEAR);
Karsten Hopp 81c285
--- 3461,3467 ----
Karsten Hopp 81c285
  #if defined(FEAT_GUI)
Karsten Hopp 81c285
  	/* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
  	 * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
! 	gui_may_update_scrollbars();
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	redraw_all_later(CLEAR);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3593,3604 ****
Karsten Hopp 81c285
  #if defined(FEAT_GUI)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
       * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
!     if (gui.in_use && starting == 0)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	gui_init_which_components(NULL);
Karsten Hopp 81c285
! 	gui_update_scrollbars(TRUE);
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
!     need_mouse_correct = TRUE;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      redraw_all_later(CLEAR);
Karsten Hopp 81c285
--- 3679,3685 ----
Karsten Hopp 81c285
  #if defined(FEAT_GUI)
Karsten Hopp 81c285
      /* When 'guioptions' includes 'L' or 'R' may have to remove or add
Karsten Hopp 81c285
       * scrollbars.  Have to update them anyway. */
Karsten Hopp 81c285
!     gui_may_update_scrollbars();
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      redraw_all_later(CLEAR);
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4150,4160 ****
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
!  * allocate a window structure and link it in the window list
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static win_T *
Karsten Hopp 81c285
! win_alloc(after)
Karsten Hopp 81c285
      win_T	*after UNUSED;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*newwin;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 4231,4243 ----
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
!  * Allocate a window structure and link it in the window list when "hidden" is
Karsten Hopp 81c285
!  * FALSE.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static win_T *
Karsten Hopp 81c285
! win_alloc(after, hidden)
Karsten Hopp 81c285
      win_T	*after UNUSED;
Karsten Hopp 81c285
+     int		hidden UNUSED;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*newwin;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4180,4186 ****
Karsten Hopp 81c285
  	 * link the window in the window list
Karsten Hopp 81c285
  	 */
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
! 	win_append(after, newwin);
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
  	newwin->w_wincol = 0;
Karsten Hopp 81c285
--- 4263,4270 ----
Karsten Hopp 81c285
  	 * link the window in the window list
Karsten Hopp 81c285
  	 */
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
! 	if (!hidden)
Karsten Hopp 81c285
! 	    win_append(after, newwin);
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
  	newwin->w_wincol = 0;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4314,4320 ****
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Append window "wp" in the window list after window "after".
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static void
Karsten Hopp 81c285
  win_append(after, wp)
Karsten Hopp 81c285
      win_T	*after, *wp;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
--- 4398,4404 ----
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Append window "wp" in the window list after window "after".
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     void
Karsten Hopp 81c285
  win_append(after, wp)
Karsten Hopp 81c285
      win_T	*after, *wp;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4340,4346 ****
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Remove a window from the window list.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static void
Karsten Hopp 81c285
  win_remove(wp, tp)
Karsten Hopp 81c285
      win_T	*wp;
Karsten Hopp 81c285
      tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
Karsten Hopp 81c285
--- 4424,4430 ----
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Remove a window from the window list.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     void
Karsten Hopp 81c285
  win_remove(wp, tp)
Karsten Hopp 81c285
      win_T	*wp;
Karsten Hopp 81c285
      tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 6040,6045 ****
Karsten Hopp 81c285
--- 6124,6130 ----
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Return TRUE if there is only one window (in the current tab page), not
Karsten Hopp 81c285
   * counting a help or preview window, unless it is the current window.
Karsten Hopp 81c285
+  * Does not count "aucmd_win".
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      int
Karsten Hopp 81c285
  only_one_window()
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 6053,6063 ****
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      for (wp = firstwin; wp != NULL; wp = wp->w_next)
Karsten Hopp 81c285
! 	if (!((wp->w_buffer->b_help && !curbuf->b_help)
Karsten Hopp 81c285
  # ifdef FEAT_QUICKFIX
Karsten Hopp 81c285
  		    || wp->w_p_pvw
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
  	     ) || wp == curwin)
Karsten Hopp 81c285
  	    ++count;
Karsten Hopp 81c285
      return (count <= 1);
Karsten Hopp 81c285
  #else
Karsten Hopp 81c285
--- 6138,6152 ----
Karsten Hopp 81c285
  	return FALSE;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      for (wp = firstwin; wp != NULL; wp = wp->w_next)
Karsten Hopp 81c285
! 	if ((!((wp->w_buffer->b_help && !curbuf->b_help)
Karsten Hopp 81c285
  # ifdef FEAT_QUICKFIX
Karsten Hopp 81c285
  		    || wp->w_p_pvw
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
  	     ) || wp == curwin)
Karsten Hopp 81c285
+ # ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
+ 		&& wp != aucmd_win
Karsten Hopp 81c285
+ # endif
Karsten Hopp 81c285
+ 	   )
Karsten Hopp 81c285
  	    ++count;
Karsten Hopp 81c285
      return (count <= 1);
Karsten Hopp 81c285
  #else
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 6112,6122 ****
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Create a snapshot of the current frame sizes.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static void
Karsten Hopp 81c285
! make_snapshot()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     clear_snapshot(curtab);
Karsten Hopp 81c285
!     make_snapshot_rec(topframe, &curtab->tp_snapshot);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
--- 6201,6212 ----
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
   * Create a snapshot of the current frame sizes.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     void
Karsten Hopp 81c285
! make_snapshot(idx)
Karsten Hopp 81c285
!     int idx;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     clear_snapshot(curtab, idx);
Karsten Hopp 81c285
!     make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 6144,6154 ****
Karsten Hopp 81c285
   * Remove any existing snapshot.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
! clear_snapshot(tp)
Karsten Hopp 81c285
      tabpage_T	*tp;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     clear_snapshot_rec(tp->tp_snapshot);
Karsten Hopp 81c285
!     tp->tp_snapshot = NULL;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
--- 6234,6245 ----
Karsten Hopp 81c285
   * Remove any existing snapshot.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
! clear_snapshot(tp, idx)
Karsten Hopp 81c285
      tabpage_T	*tp;
Karsten Hopp 81c285
+     int		idx;
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     clear_snapshot_rec(tp->tp_snapshot[idx]);
Karsten Hopp 81c285
!     tp->tp_snapshot[idx] = NULL;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      static void
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 6168,6193 ****
Karsten Hopp 81c285
   * This is only done if the screen size didn't change and the window layout is
Karsten Hopp 81c285
   * still the same.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     static void
Karsten Hopp 81c285
! restore_snapshot(close_curwin)
Karsten Hopp 81c285
      int		close_curwin;	    /* closing current window */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*wp;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if (curtab->tp_snapshot != NULL
Karsten Hopp 81c285
  # ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
! 	    && curtab->tp_snapshot->fr_width == topframe->fr_width
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
! 	    && curtab->tp_snapshot->fr_height == topframe->fr_height
Karsten Hopp 81c285
! 	    && check_snapshot_rec(curtab->tp_snapshot, topframe) == OK)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	wp = restore_snapshot_rec(curtab->tp_snapshot, topframe);
Karsten Hopp 81c285
  	win_comp_pos();
Karsten Hopp 81c285
  	if (wp != NULL && close_curwin)
Karsten Hopp 81c285
  	    win_goto(wp);
Karsten Hopp 81c285
  	redraw_all_later(CLEAR);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
!     clear_snapshot(curtab);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
--- 6259,6285 ----
Karsten Hopp 81c285
   * This is only done if the screen size didn't change and the window layout is
Karsten Hopp 81c285
   * still the same.
Karsten Hopp 81c285
   */
Karsten Hopp 81c285
!     void
Karsten Hopp 81c285
! restore_snapshot(idx, close_curwin)
Karsten Hopp 81c285
!     int		idx;
Karsten Hopp 81c285
      int		close_curwin;	    /* closing current window */
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      win_T	*wp;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     if (curtab->tp_snapshot[idx] != NULL
Karsten Hopp 81c285
  # ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
! 	    && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
! 	    && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
Karsten Hopp 81c285
! 	    && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
! 	wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
Karsten Hopp 81c285
  	win_comp_pos();
Karsten Hopp 81c285
  	if (wp != NULL && close_curwin)
Karsten Hopp 81c285
  	    win_goto(wp);
Karsten Hopp 81c285
  	redraw_all_later(CLEAR);
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
!     clear_snapshot(curtab, idx);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /*
Karsten Hopp 81c285
*** ../vim-7.2.202/src/version.c	2009-06-16 15:35:46.000000000 +0200
Karsten Hopp 81c285
--- src/version.c	2009-06-16 15:37:16.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     203,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
How To Keep A Healthy Level Of Insanity:
Karsten Hopp 81c285
15. Five days in advance, tell your friends you can't attend their
Karsten Hopp 81c285
    party because you're not in the mood.
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///