comparison src/window.c @ 856:8cd729851562 v7.0g

updated for version 7.0g
author vimboss
date Sun, 30 Apr 2006 18:54:39 +0000
parents d58e3db4a7d1
children b933657f7c9d
comparison
equal deleted inserted replaced
855:d2a4f08396fe 856:8cd729851562
1993 win_close(win, free_buf) 1993 win_close(win, free_buf)
1994 win_T *win; 1994 win_T *win;
1995 int free_buf; 1995 int free_buf;
1996 { 1996 {
1997 win_T *wp; 1997 win_T *wp;
1998 buf_T *old_curbuf = curbuf;
1999 #ifdef FEAT_AUTOCMD 1998 #ifdef FEAT_AUTOCMD
2000 int other_buffer = FALSE; 1999 int other_buffer = FALSE;
2001 #endif 2000 #endif
2002 int close_curwin = FALSE; 2001 int close_curwin = FALSE;
2003 int dir; 2002 int dir;
2005 tabpage_T *prev_curtab = curtab; 2004 tabpage_T *prev_curtab = curtab;
2006 2005
2007 if (last_window()) 2006 if (last_window())
2008 { 2007 {
2009 EMSG(_("E444: Cannot close last window")); 2008 EMSG(_("E444: Cannot close last window"));
2009 return;
2010 }
2011
2012 /*
2013 * When closing the last window in a tab page first go to another tab
2014 * page and then close the window and the tab page. This avoids that
2015 * curwin and curtab are not invalid while we are freeing memory, they may
2016 * be used in GUI events.
2017 */
2018 if (firstwin == lastwin)
2019 {
2020 goto_tabpage_tp(alt_tabpage());
2021 redraw_tabline = TRUE;
2022
2023 /* Safety check: Autocommands may have closed the window when jumping
2024 * to the other tab page. */
2025 if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win)
2026 {
2027 int h = tabline_height();
2028
2029 win_close_othertab(win, free_buf, prev_curtab);
2030 if (h != tabline_height())
2031 shell_new_rows();
2032 }
2010 return; 2033 return;
2011 } 2034 }
2012 2035
2013 /* When closing the help window, try restoring a snapshot after closing 2036 /* When closing the help window, try restoring a snapshot after closing
2014 * the window. Otherwise clear the snapshot, it's now invalid. */ 2037 * the window. Otherwise clear the snapshot, it's now invalid. */
2054 2077
2055 /* Autocommands may have closed the window already, or closed the only 2078 /* Autocommands may have closed the window already, or closed the only
2056 * other window or moved to another tab page. */ 2079 * other window or moved to another tab page. */
2057 if (!win_valid(win) || last_window() || curtab != prev_curtab) 2080 if (!win_valid(win) || last_window() || curtab != prev_curtab)
2058 return; 2081 return;
2059
2060 /* When closing the last window in a tab page go to another tab page. This
2061 * must be done before freeing memory to avoid that "topframe" becomes
2062 * invalid (it may be used in GUI events). */
2063 if (firstwin == lastwin)
2064 {
2065 tabpage_T *ptp = NULL;
2066 tabpage_T *tp;
2067 tabpage_T *atp = alt_tabpage();
2068
2069 /* We don't do the window resizing stuff, let enter_tabpage() take
2070 * care of entering a window in another tab page. */
2071 enter_tabpage(atp, old_curbuf);
2072
2073 for (tp = first_tabpage; tp != NULL && tp != prev_curtab;
2074 tp = tp->tp_next)
2075 ptp = tp;
2076 if (tp != prev_curtab || tp->tp_firstwin != win)
2077 {
2078 /* Autocommands must have closed it when jumping to the other tab
2079 * page. */
2080 return;
2081 }
2082
2083 (void)win_free_mem(win, &dir, tp);
2084
2085 if (ptp == NULL)
2086 first_tabpage = tp->tp_next;
2087 else
2088 ptp->tp_next = tp->tp_next;
2089 free_tabpage(tp);
2090
2091 return;
2092 }
2093 2082
2094 /* Free the memory used for the window. */ 2083 /* Free the memory used for the window. */
2095 wp = win_free_mem(win, &dir, NULL); 2084 wp = win_free_mem(win, &dir, NULL);
2096 2085
2097 /* Make sure curwin isn't invalid. It can cause severe trouble when 2086 /* Make sure curwin isn't invalid. It can cause severe trouble when
2172 2161
2173 /* 2162 /*
2174 * Close window "win" in tab page "tp", which is not the current tab page. 2163 * Close window "win" in tab page "tp", which is not the current tab page.
2175 * This may be the last window ih that tab page and result in closing the tab, 2164 * This may be the last window ih that tab page and result in closing the tab,
2176 * thus "tp" may become invalid! 2165 * thus "tp" may become invalid!
2177 * Called must check if buffer is hidden. 2166 * Caller must check if buffer is hidden and whether the tabline needs to be
2167 * updated.
2178 */ 2168 */
2179 void 2169 void
2180 win_close_othertab(win, free_buf, tp) 2170 win_close_othertab(win, free_buf, tp)
2181 win_T *win; 2171 win_T *win;
2182 int free_buf; 2172 int free_buf;