4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When reloading a buffer or doing anything else with a buffer that
12 is not displayed in a visible window, autocommands may be applied
13 to the current window, folds messed up, etc.
14 Solution: Instead of using the current window for the hidden buffer use a
15 special window, splitting the current one temporarily.
16 Files: src/fileio.c, src/globals.h, src/gui.c, src/if_perl.xs,
17 src/proto/gui.pro, src/proto/window.pro, src/screen.c,
18 src/structs.h, src/window.c
21 *** ../vim-7.2.202/src/fileio.c 2009-06-16 15:35:46.000000000 +0200
22 --- src/fileio.c 2009-06-11 21:22:37.000000000 +0200
26 /* Execute the modeline settings, but don't set window-local
27 * options if we are using the current window for another buffer. */
28 ! do_modelines(aco.save_curwin == NULL ? OPT_NOWIN : 0);
30 /* restore the current window */
34 /* Execute the modeline settings, but don't set window-local
35 * options if we are using the current window for another buffer. */
36 ! do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
38 /* restore the current window */
44 * Prepare for executing autocommands for (hidden) buffer "buf".
45 ! * Search a window for the current buffer. Save the cursor position and
47 * Set "curbuf" and "curwin" to match "buf".
48 * When FEAT_AUTOCMD is not defined another version is used, see below.
53 * Prepare for executing autocommands for (hidden) buffer "buf".
54 ! * Search for a visible window containing the current buffer. If there isn't
55 ! * one then use "aucmd_win".
56 * Set "curbuf" and "curwin" to match "buf".
57 * When FEAT_AUTOCMD is not defined another version is used, see below.
61 buf_T *buf; /* new curbuf */
65 ! aco->new_curbuf = buf;
67 /* Find a window that is for the new buffer */
68 if (buf == curbuf) /* be quick when buf is curbuf */
70 buf_T *buf; /* new curbuf */
77 /* Find a window that is for the new buffer */
78 if (buf == curbuf) /* be quick when buf is curbuf */
85 ! * Prefer to use an existing window for the buffer, it has the least side
86 ! * effects (esp. if "buf" is curbuf).
87 ! * Otherwise, use curwin for "buf". It might make some items in the
88 ! * window invalid. At least save the cursor and topline.
92 ! /* there is a window for "buf", make it the curwin */
93 ! aco->save_curwin = curwin;
95 - aco->save_buf = win->w_buffer;
96 - aco->new_curwin = win;
100 ! /* there is no window for "buf", use curwin */
101 ! aco->save_curwin = NULL;
102 ! aco->save_buf = curbuf;
103 ! --curbuf->b_nwindows;
104 curwin->w_buffer = buf;
107 ! /* save cursor and topline, set them to safe values */
108 ! aco->save_cursor = curwin->w_cursor;
109 ! curwin->w_cursor.lnum = 1;
110 ! curwin->w_cursor.col = 0;
111 ! aco->save_topline = curwin->w_topline;
112 ! curwin->w_topline = 1;
114 ! aco->save_topfill = curwin->w_topfill;
115 ! curwin->w_topfill = 0;
127 ! /* Allocate "aucmd_win" when needed. If this fails (out of memory) fall
128 ! * back to using the current window. */
129 ! if (win == NULL && aucmd_win == NULL)
131 ! win_alloc_aucmd_win();
132 ! if (aucmd_win == NULL)
136 ! aco->save_curwin = curwin;
137 ! aco->save_curbuf = curbuf;
140 ! /* There is a window for "buf" in the current tab page, make it the
141 ! * curwin. This is preferred, it has the least side effects (esp. if
142 ! * "buf" is curbuf). */
147 ! /* There is no window for "buf", use "aucmd_win". To minimize the side
148 ! * effects, insert it in a the current tab page.
149 ! * Anything related to a window (e.g., setting folds) may have
150 ! * unexpected results. */
151 ! curwin = aucmd_win;
152 curwin->w_buffer = buf;
155 ! #ifdef FEAT_WINDOWS
156 ! /* Split the current window, put the aucmd_win in the upper half. */
157 ! make_snapshot(SNAP_AUCMD_IDX);
160 ! (void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
161 ! (void)win_comp_pos(); /* recompute window positions */
164 ! /* set cursor and topline to safe values */
166 ! #ifdef FEAT_VERTSPLIT
167 ! curwin->w_wincol = 0;
168 ! curwin->w_width = Columns;
172 + aco->new_curwin = curwin;
173 + aco->new_curbuf = curbuf;
180 aco_save_T *aco; /* structure holding saved values */
182 ! if (aco->save_curwin != NULL)
186 if (win_valid(aco->save_curwin))
189 ! /* restore the buffer which was previously edited by curwin, if
190 ! * it's still the same window and it's valid */
191 if (curwin == aco->new_curwin
192 ! && buf_valid(aco->save_buf)
193 ! && aco->save_buf->b_ml.ml_mfp != NULL)
195 --curbuf->b_nwindows;
196 ! curbuf = aco->save_buf;
197 curwin->w_buffer = curbuf;
198 ++curbuf->b_nwindows;
202 aco_save_T *aco; /* structure holding saved values */
204 ! #ifdef FEAT_WINDOWS
208 ! if (aco->new_curwin == aucmd_win)
210 ! --curbuf->b_nwindows;
211 ! #ifdef FEAT_WINDOWS
212 ! /* Find "aucmd_win", it can't be closed, but it may be in another tab
214 ! if (curwin != aucmd_win)
219 ! FOR_ALL_TAB_WINDOWS(tp, wp)
221 ! if (wp == aucmd_win)
224 ! goto_tabpage_tp(tp);
225 ! win_goto(aucmd_win);
231 ! /* Remove the window and frame from the tree of frames. */
232 ! (void)winframe_remove(curwin, &dummy, NULL);
233 ! win_remove(curwin, NULL);
234 ! last_status(FALSE); /* may need to remove last status line */
235 ! restore_snapshot(SNAP_AUCMD_IDX, FALSE);
236 ! (void)win_comp_pos(); /* recompute window positions */
238 ! if (win_valid(aco->save_curwin))
239 ! curwin = aco->save_curwin;
241 ! /* Hmm, original window disappeared. Just use the first one. */
244 ! vars_clear(&aucmd_win->w_vars.dv_hashtab); /* free all w: variables */
247 ! curwin = aco->save_curwin;
249 ! curbuf = curwin->w_buffer;
251 ! /* the buffer contents may have changed */
253 ! if (curwin->w_topline > curbuf->b_ml.ml_line_count)
255 ! curwin->w_topline = curbuf->b_ml.ml_line_count;
257 ! curwin->w_topfill = 0;
260 ! #if defined(FEAT_GUI)
261 ! /* Hide the scrollbars from the aucmd_win and update. */
262 ! gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_LEFT], FALSE);
263 ! gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_RIGHT], FALSE);
264 ! gui_may_update_scrollbars();
271 if (win_valid(aco->save_curwin))
274 ! /* Restore the buffer which was previously edited by curwin, if
275 ! * it was chagned, we are still the same window and the buffer is
277 if (curwin == aco->new_curwin
278 ! && curbuf != aco->new_curbuf
279 ! && buf_valid(aco->new_curbuf)
280 ! && aco->new_curbuf->b_ml.ml_mfp != NULL)
282 --curbuf->b_nwindows;
283 ! curbuf = aco->new_curbuf;
284 curwin->w_buffer = curbuf;
285 ++curbuf->b_nwindows;
289 curbuf = curwin->w_buffer;
294 - /* restore buffer for curwin if it still exists and is loaded */
295 - if (buf_valid(aco->save_buf) && aco->save_buf->b_ml.ml_mfp != NULL)
297 - --curbuf->b_nwindows;
298 - curbuf = aco->save_buf;
299 - curwin->w_buffer = curbuf;
300 - ++curbuf->b_nwindows;
301 - curwin->w_cursor = aco->save_cursor;
303 - /* check topline < line_count, in case lines got deleted */
304 - if (aco->save_topline <= curbuf->b_ml.ml_line_count)
306 - curwin->w_topline = aco->save_topline;
308 - curwin->w_topfill = aco->save_topfill;
313 - curwin->w_topline = curbuf->b_ml.ml_line_count;
315 - curwin->w_topfill = 0;
322 static int autocmd_nested = FALSE;
326 aco_save_T *aco; /* structure to save values in */
327 buf_T *buf; /* new curbuf */
329 ! aco->save_buf = curbuf;
331 curwin->w_buffer = buf;
336 aco_save_T *aco; /* structure to save values in */
337 buf_T *buf; /* new curbuf */
339 ! aco->save_curbuf = curbuf;
340 ! --curbuf->b_nwindows;
342 curwin->w_buffer = buf;
343 + ++curbuf->b_nwindows;
350 aco_save_T *aco; /* structure holding saved values */
352 ! curbuf = aco->save_buf;
353 curwin->w_buffer = curbuf;
356 #endif /* FEAT_AUTOCMD */
359 aco_save_T *aco; /* structure holding saved values */
361 ! --curbuf->b_nwindows;
362 ! curbuf = aco->save_curbuf;
363 curwin->w_buffer = curbuf;
364 + ++curbuf->b_nwindows;
367 #endif /* FEAT_AUTOCMD */
368 *** ../vim-7.2.202/src/globals.h 2009-06-16 15:23:07.000000000 +0200
369 --- src/globals.h 2009-06-12 21:10:30.000000000 +0200
374 EXTERN win_T *curwin; /* currently active window */
376 + #ifdef FEAT_AUTOCMD
377 + EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */
381 * The window layout is kept in a tree of frames. topframe points to the top
383 *** ../vim-7.2.202/src/gui.c 2009-05-21 23:25:38.000000000 +0200
384 --- src/gui.c 2009-06-11 20:58:05.000000000 +0200
392 + * Called when something in the window layout has changed.
395 + gui_may_update_scrollbars()
397 + if (gui.in_use && starting == 0)
400 + gui_init_which_components(NULL);
401 + gui_update_scrollbars(TRUE);
403 + need_mouse_correct = TRUE;
407 gui_update_scrollbars(force)
408 int force; /* Force all scrollbars to get updated */
409 *** ../vim-7.2.202/src/if_perl.xs 2008-12-03 13:18:16.000000000 +0100
410 --- src/if_perl.xs 2009-06-03 17:52:51.000000000 +0200
415 deleted_lines_mark(lnum, 1L);
416 ! if (aco.save_buf == curbuf)
423 deleted_lines_mark(lnum, 1L);
424 ! if (aco.save_curbuf == curbuf)
428 *** ../vim-7.2.202/src/proto/gui.pro 2007-05-05 19:42:19.000000000 +0200
429 --- src/proto/gui.pro 2009-06-11 20:58:08.000000000 +0200
433 void gui_create_scrollbar __ARGS((scrollbar_T *sb, int type, win_T *wp));
434 scrollbar_T *gui_find_scrollbar __ARGS((long ident));
435 void gui_drag_scrollbar __ARGS((scrollbar_T *sb, long value, int still_dragging));
436 + void gui_may_update_scrollbars __ARGS((void));
437 void gui_update_scrollbars __ARGS((int force));
438 int gui_do_scroll __ARGS((void));
439 int gui_do_horiz_scroll __ARGS((void));
440 *** ../vim-7.2.202/src/proto/window.pro 2007-07-26 22:57:45.000000000 +0200
441 --- src/proto/window.pro 2009-06-10 21:20:39.000000000 +0200
446 void do_window __ARGS((int nchar, long Prenum, int xchar));
447 int win_split __ARGS((int size, int flags));
448 + int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
449 int win_valid __ARGS((win_T *win));
450 int win_count __ARGS((void));
451 int make_windows __ARGS((int count, int vertical));
455 void win_close __ARGS((win_T *win, int free_buf));
456 void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
457 void win_free_all __ARGS((void));
458 + win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
459 void close_others __ARGS((int message, int forceit));
460 void curwin_init __ARGS((void));
461 int win_alloc_first __ARGS((void));
462 + void win_alloc_aucmd_win __ARGS((void));
463 void win_init_size __ARGS((void));
464 void free_tabpage __ARGS((tabpage_T *tp));
465 int win_new_tabpage __ARGS((int after));
469 void win_enter __ARGS((win_T *wp, int undo_sync));
470 win_T *buf_jump_open_win __ARGS((buf_T *buf));
471 win_T *buf_jump_open_tab __ARGS((buf_T *buf));
472 + void win_append __ARGS((win_T *after, win_T *wp));
473 + void win_remove __ARGS((win_T *wp, tabpage_T *tp));
474 int win_alloc_lines __ARGS((win_T *wp));
475 void win_free_lsize __ARGS((win_T *wp));
476 void shell_new_rows __ARGS((void));
480 int min_rows __ARGS((void));
481 int only_one_window __ARGS((void));
482 void check_lnums __ARGS((int do_curwin));
483 + void make_snapshot __ARGS((int idx));
484 + void restore_snapshot __ARGS((int idx, int close_curwin));
485 int win_hasvertsplit __ARGS((void));
486 int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
487 int match_delete __ARGS((win_T *wp, int id, int perr));
488 *** ../vim-7.2.202/src/screen.c 2009-05-17 13:30:58.000000000 +0200
489 --- src/screen.c 2009-06-10 16:41:45.000000000 +0200
496 + #ifdef FEAT_AUTOCMD
497 + if (aucmd_win != NULL && win_alloc_lines(aucmd_win) == FAIL)
503 *** ../vim-7.2.202/src/structs.h 2009-05-16 16:36:25.000000000 +0200
504 --- src/structs.h 2009-06-13 12:51:56.000000000 +0200
511 + #define SNAP_HELP_IDX 0
512 + #ifdef FEAT_AUTOCMD
513 + # define SNAP_AUCMD_IDX 1
514 + # define SNAP_COUNT 2
516 + # define SNAP_COUNT 1
520 * Tab pages point to the top frame of each tab page.
521 * Note: Most values are NOT valid for the current tab page! Use "curwin",
524 buf_T *(tp_diffbuf[DB_COUNT]);
525 int tp_diff_invalid; /* list of diffs is outdated */
527 ! frame_T *tp_snapshot; /* window layout snapshot */
529 dictitem_T tp_winvar; /* variable for "t:" Dictionary */
530 dict_T tp_vars; /* internal variables, local to tab page */
532 buf_T *(tp_diffbuf[DB_COUNT]);
533 int tp_diff_invalid; /* list of diffs is outdated */
535 ! frame_T *(tp_snapshot[SNAP_COUNT]); /* window layout snapshots */
537 dictitem_T tp_winvar; /* variable for "t:" Dictionary */
538 dict_T tp_vars; /* internal variables, local to tab page */
544 ! buf_T *save_buf; /* saved curbuf */
546 ! buf_T *new_curbuf; /* buffer to be used */
547 ! win_T *save_curwin; /* saved curwin, NULL if it didn't change */
548 ! win_T *new_curwin; /* new curwin if save_curwin != NULL */
549 ! pos_T save_cursor; /* saved cursor pos of save_curwin */
550 ! linenr_T save_topline; /* saved topline of save_curwin */
552 ! int save_topfill; /* saved topfill of save_curwin */
561 ! buf_T *save_curbuf; /* saved curbuf */
563 ! win_T *save_curwin; /* saved curwin */
564 ! win_T *new_curwin; /* new curwin */
565 ! buf_T *new_curbuf; /* new curbuf */
569 *** ../vim-7.2.202/src/window.c 2009-05-21 23:25:38.000000000 +0200
570 --- src/window.c 2009-06-12 22:29:33.000000000 +0200
574 static int path_is_url __ARGS((char_u *p));
575 #if defined(FEAT_WINDOWS) || defined(PROTO)
576 - static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
577 static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
578 static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
579 static void frame_setheight __ARGS((frame_T *curfrp, int height));
580 #ifdef FEAT_VERTSPLIT
583 static int path_is_url __ARGS((char_u *p));
584 #if defined(FEAT_WINDOWS) || defined(PROTO)
585 static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
586 + static void win_init_some __ARGS((win_T *newp, win_T *oldp));
587 static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
588 static void frame_setheight __ARGS((frame_T *curfrp, int height));
589 #ifdef FEAT_VERTSPLIT
592 static void win_totop __ARGS((int size, int flags));
593 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));
594 static int last_window __ARGS((void));
595 static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
596 - static win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
597 static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
598 static tabpage_T *alt_tabpage __ARGS((void));
599 static win_T *frame2win __ARGS((frame_T *frp));
601 static void win_totop __ARGS((int size, int flags));
602 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));
603 static int last_window __ARGS((void));
604 + static int one_window __ARGS((void));
605 static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
606 static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
607 static tabpage_T *alt_tabpage __ARGS((void));
608 static win_T *frame2win __ARGS((frame_T *frp));
614 static int win_alloc_firstwin __ARGS((win_T *oldwin));
615 + static void new_frame __ARGS((win_T *wp));
616 #if defined(FEAT_WINDOWS) || defined(PROTO)
617 static tabpage_T *alloc_tabpage __ARGS((void));
618 static int leave_tabpage __ARGS((buf_T *new_curbuf));
621 static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
622 static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
623 static void win_free __ARGS((win_T *wp, tabpage_T *tp));
624 - static void win_append __ARGS((win_T *, win_T *));
625 - static void win_remove __ARGS((win_T *, tabpage_T *tp));
626 static void frame_append __ARGS((frame_T *after, frame_T *frp));
627 static void frame_insert __ARGS((frame_T *before, frame_T *frp));
628 static void frame_remove __ARGS((frame_T *frp));
632 static void frame_add_height __ARGS((frame_T *frp, int n));
633 static void last_status_rec __ARGS((frame_T *fr, int statusline));
635 - static void make_snapshot __ARGS((void));
636 static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
637 ! static void clear_snapshot __ARGS((tabpage_T *tp));
638 static void clear_snapshot_rec __ARGS((frame_T *fr));
639 - static void restore_snapshot __ARGS((int close_curwin));
640 static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
641 static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
643 #endif /* FEAT_WINDOWS */
645 ! static win_T *win_alloc __ARGS((win_T *after));
646 static void win_new_height __ARGS((win_T *, int));
648 #define URL_SLASH 1 /* path_is_url() has found "://" */
650 static void frame_add_height __ARGS((frame_T *frp, int n));
651 static void last_status_rec __ARGS((frame_T *fr, int statusline));
653 static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
654 ! static void clear_snapshot __ARGS((tabpage_T *tp, int idx));
655 static void clear_snapshot_rec __ARGS((frame_T *fr));
656 static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
657 static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
659 #endif /* FEAT_WINDOWS */
661 ! static win_T *win_alloc __ARGS((win_T *after, int hidden));
662 static void win_new_height __ARGS((win_T *, int));
664 #define URL_SLASH 1 /* path_is_url() has found "://" */
667 /* cursor to previous window with wrap around */
670 ! if (lastwin == firstwin && Prenum != 1) /* just one window */
675 /* cursor to previous window with wrap around */
678 ! if (firstwin == lastwin && Prenum != 1) /* just one window */
685 /* move window to new tab page */
687 ! if (firstwin == lastwin)
693 /* move window to new tab page */
701 /* When creating the help window make a snapshot of the window layout.
702 * Otherwise clear the snapshot, it's now invalid. */
703 if (flags & WSP_HELP)
706 ! clear_snapshot(curtab);
708 return win_split_ins(size, flags, NULL, 0);
711 /* When creating the help window make a snapshot of the window layout.
712 * Otherwise clear the snapshot, it's now invalid. */
713 if (flags & WSP_HELP)
714 ! make_snapshot(SNAP_HELP_IDX);
716 ! clear_snapshot(curtab, SNAP_HELP_IDX);
718 return win_split_ins(size, flags, NULL, 0);
722 * top/left/right/bottom.
723 * return FAIL for failure, OK otherwise
726 win_split_ins(size, flags, newwin, dir)
730 * top/left/right/bottom.
731 * return FAIL for failure, OK otherwise
734 win_split_ins(size, flags, newwin, dir)
740 /* new window below/right of current one */
742 ! wp = win_alloc(oldwin);
744 win_append(oldwin, wp);
749 ! wp = win_alloc(oldwin->w_prev);
751 win_append(oldwin->w_prev, wp);
755 /* new window below/right of current one */
757 ! wp = win_alloc(oldwin, FALSE);
759 win_append(oldwin, wp);
764 ! wp = win_alloc(oldwin->w_prev, FALSE);
766 win_append(oldwin->w_prev, wp);
775 + if (wp->w_frame == NULL)
777 + win_free(wp, NULL);
781 /* make the contents of the new window the same as the current one */
782 win_init(wp, curwin, flags);
790 ! /* Create a frame for the new window. */
791 ! frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
792 ! frp->fr_layout = FR_LEAF;
797 frp = newwin->w_frame;
798 frp->fr_parent = curfrp->fr_parent;
805 frp = newwin->w_frame;
806 frp->fr_parent = curfrp->fr_parent;
815 * Initialize window "newp" from window "oldp".
816 * Used when splitting a window and when creating a new tab page.
819 if (oldp->w_localdir != NULL)
820 newp->w_localdir = vim_strsave(oldp->w_localdir);
822 ! /* Use the same argument list. */
823 ! newp->w_alist = oldp->w_alist;
824 ! ++newp->w_alist->al_refcount;
825 ! newp->w_arg_idx = oldp->w_arg_idx;
828 ! * copy tagstack and options from existing window
830 for (i = 0; i < oldp->w_tagstacklen; i++)
832 newp->w_tagstack[i] = oldp->w_tagstack[i];
834 if (oldp->w_localdir != NULL)
835 newp->w_localdir = vim_strsave(oldp->w_localdir);
837 ! /* copy tagstack and folds */
838 for (i = 0; i < oldp->w_tagstacklen; i++)
840 newp->w_tagstack[i] = oldp->w_tagstack[i];
844 newp->w_tagstackidx = oldp->w_tagstackidx;
845 newp->w_tagstacklen = oldp->w_tagstacklen;
846 - win_copy_options(oldp, newp);
848 copyFoldingState(oldp, newp);
852 #endif /* FEAT_WINDOWS */
855 newp->w_tagstackidx = oldp->w_tagstackidx;
856 newp->w_tagstacklen = oldp->w_tagstacklen;
858 copyFoldingState(oldp, newp);
861 + win_init_some(newp, oldp);
865 + * Initialize window "newp" from window"old".
866 + * Only the essential things are copied.
869 + win_init_some(newp, oldp)
873 + /* Use the same argument list. */
874 + newp->w_alist = oldp->w_alist;
875 + ++newp->w_alist->al_refcount;
876 + newp->w_arg_idx = oldp->w_arg_idx;
878 + /* copy options from existing window */
879 + win_copy_options(oldp, newp);
882 #endif /* FEAT_WINDOWS */
885 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
886 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
887 * scrollbars. Have to update them anyway. */
891 ! gui_init_which_components(NULL);
892 ! gui_update_scrollbars(TRUE);
894 ! need_mouse_correct = TRUE;
901 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
902 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
903 * scrollbars. Have to update them anyway. */
904 ! gui_may_update_scrollbars();
914 ! * Return TRUE if the current window is the only window that exists.
915 * Returns FALSE if there is a window, possibly in another tab page.
920 ! return (lastwin == firstwin && first_tabpage->tp_next == NULL);
928 ! * Return TRUE if the current window is the only window that exists (ignoring
930 * Returns FALSE if there is a window, possibly in another tab page.
935 ! return (one_window() && first_tabpage->tp_next == NULL);
939 ! * Return TRUE if there is only one window other than "aucmd_win" in the
940 ! * current tab page.
945 ! #ifdef FEAT_AUTOCMD
947 ! int seen_one = FALSE;
949 ! FOR_ALL_WINDOWS(wp)
951 ! if (wp != aucmd_win)
960 ! return firstwin == lastwin;
971 + #ifdef FEAT_AUTOCMD
972 + if (win == aucmd_win)
974 + EMSG(_("E813: Cannot close autocmd window"));
977 + if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
979 + EMSG(_("E814: Cannot close window, only autocmd window would remain"));
985 * When closing the last window in a tab page first go to another tab
986 * page and then close the window and the tab page. This avoids that
989 if (win->w_buffer->b_help)
992 ! clear_snapshot(curtab);
997 if (win->w_buffer->b_help)
1000 ! clear_snapshot(curtab, SNAP_HELP_IDX);
1006 /* After closing the help window, try restoring the window layout from
1007 * before it was opened. */
1009 ! restore_snapshot(close_curwin);
1011 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
1012 /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
1014 /* After closing the help window, try restoring the window layout from
1015 * before it was opened. */
1017 ! restore_snapshot(SNAP_HELP_IDX, close_curwin);
1019 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
1020 /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
1025 while (firstwin != NULL)
1026 (void)win_free_mem(firstwin, &dummy, NULL);
1028 + # ifdef FEAT_AUTOCMD
1029 + if (aucmd_win != NULL)
1031 + (void)win_free_mem(aucmd_win, &dummy, NULL);
1040 * Remove a window and its frame from the tree of frames.
1041 * Returns a pointer to the window that got the freed up space.
1044 winframe_remove(win, dirp, tp)
1046 int *dirp UNUSED; /* set to 'v' or 'h' for direction if 'ea' */
1048 * Remove a window and its frame from the tree of frames.
1049 * Returns a pointer to the window that got the freed up space.
1052 winframe_remove(win, dirp, tp)
1054 int *dirp UNUSED; /* set to 'v' or 'h' for direction if 'ea' */
1060 ! if (lastwin == firstwin)
1075 first_tabpage->tp_topframe = topframe;
1076 curtab = first_tabpage;
1082 + #if defined(FEAT_AUTOCMD) || defined(PROTO)
1084 + * Init "aucmd_win". This can only be done after the first
1085 + * window is fully initialized, thus it can't be in win_alloc_first().
1088 + win_alloc_aucmd_win()
1090 + aucmd_win = win_alloc(NULL, TRUE);
1091 + if (aucmd_win != NULL)
1093 + win_init_some(aucmd_win, curwin);
1094 + # ifdef FEAT_SCROLLBIND
1095 + aucmd_win->w_p_scb = FALSE;
1097 + new_frame(aucmd_win);
1103 * Allocate the first window or the first window in a new tab page.
1104 * When "oldwin" is NULL create an empty buffer for it.
1107 win_alloc_firstwin(oldwin)
1110 ! curwin = win_alloc(NULL);
1113 /* Very first window, need to create an empty buffer for it and
1115 win_alloc_firstwin(oldwin)
1118 ! curwin = win_alloc(NULL, FALSE);
1121 /* Very first window, need to create an empty buffer for it and
1127 ! topframe = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
1128 ! if (topframe == NULL)
1130 ! topframe->fr_layout = FR_LEAF;
1131 #ifdef FEAT_VERTSPLIT
1132 topframe->fr_width = Columns;
1134 topframe->fr_height = Rows - p_ch;
1135 topframe->fr_win = curwin;
1136 - curwin->w_frame = topframe;
1142 * Initialize the window and frame size to the maximum.
1149 ! new_frame(curwin);
1150 ! if (curwin->w_frame == NULL)
1152 ! topframe = curwin->w_frame;
1153 #ifdef FEAT_VERTSPLIT
1154 topframe->fr_width = Columns;
1156 topframe->fr_height = Rows - p_ch;
1157 topframe->fr_win = curwin;
1163 + * Create a frame for window "wp".
1166 + new_frame(win_T *wp)
1168 + frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
1170 + wp->w_frame = frp;
1173 + frp->fr_layout = FR_LEAF;
1179 * Initialize the window and frame size to the maximum.
1190 ! clear_snapshot(tp);
1192 vars_clear(&tp->tp_vars.dv_hashtab); /* free all t: variables */
1203 ! for (idx = 0; idx < SNAP_COUNT; ++idx)
1204 ! clear_snapshot(tp, idx);
1206 vars_clear(&tp->tp_vars.dv_hashtab); /* free all t: variables */
1210 #if defined(FEAT_GUI)
1211 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
1212 * scrollbars. Have to update them anyway. */
1213 ! if (gui.in_use && starting == 0)
1215 ! gui_init_which_components(NULL);
1216 ! gui_update_scrollbars(TRUE);
1218 ! need_mouse_correct = TRUE;
1221 redraw_all_later(CLEAR);
1223 #if defined(FEAT_GUI)
1224 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
1225 * scrollbars. Have to update them anyway. */
1226 ! gui_may_update_scrollbars();
1229 redraw_all_later(CLEAR);
1232 #if defined(FEAT_GUI)
1233 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
1234 * scrollbars. Have to update them anyway. */
1235 ! if (gui.in_use && starting == 0)
1237 ! gui_init_which_components(NULL);
1238 ! gui_update_scrollbars(TRUE);
1240 ! need_mouse_correct = TRUE;
1243 redraw_all_later(CLEAR);
1245 #if defined(FEAT_GUI)
1246 /* When 'guioptions' includes 'L' or 'R' may have to remove or add
1247 * scrollbars. Have to update them anyway. */
1248 ! gui_may_update_scrollbars();
1251 redraw_all_later(CLEAR);
1257 ! * allocate a window structure and link it in the window list
1261 win_T *after UNUSED;
1269 ! * Allocate a window structure and link it in the window list when "hidden" is
1273 ! win_alloc(after, hidden)
1274 win_T *after UNUSED;
1275 + int hidden UNUSED;
1281 * link the window in the window list
1284 ! win_append(after, newwin);
1286 #ifdef FEAT_VERTSPLIT
1287 newwin->w_wincol = 0;
1289 * link the window in the window list
1293 ! win_append(after, newwin);
1295 #ifdef FEAT_VERTSPLIT
1296 newwin->w_wincol = 0;
1300 * Append window "wp" in the window list after window "after".
1303 win_append(after, wp)
1308 * Append window "wp" in the window list after window "after".
1311 win_append(after, wp)
1317 * Remove a window from the window list.
1322 tabpage_T *tp; /* tab page "win" is in, NULL for current */
1325 * Remove a window from the window list.
1330 tabpage_T *tp; /* tab page "win" is in, NULL for current */
1335 * Return TRUE if there is only one window (in the current tab page), not
1336 * counting a help or preview window, unless it is the current window.
1337 + * Does not count "aucmd_win".
1345 for (wp = firstwin; wp != NULL; wp = wp->w_next)
1346 ! if (!((wp->w_buffer->b_help && !curbuf->b_help)
1347 # ifdef FEAT_QUICKFIX
1352 return (count <= 1);
1357 for (wp = firstwin; wp != NULL; wp = wp->w_next)
1358 ! if ((!((wp->w_buffer->b_help && !curbuf->b_help)
1359 # ifdef FEAT_QUICKFIX
1363 + # ifdef FEAT_AUTOCMD
1364 + && wp != aucmd_win
1368 return (count <= 1);
1373 * Create a snapshot of the current frame sizes.
1378 ! clear_snapshot(curtab);
1379 ! make_snapshot_rec(topframe, &curtab->tp_snapshot);
1385 * Create a snapshot of the current frame sizes.
1388 ! make_snapshot(idx)
1391 ! clear_snapshot(curtab, idx);
1392 ! make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
1398 * Remove any existing snapshot.
1401 ! clear_snapshot(tp)
1404 ! clear_snapshot_rec(tp->tp_snapshot);
1405 ! tp->tp_snapshot = NULL;
1410 * Remove any existing snapshot.
1413 ! clear_snapshot(tp, idx)
1417 ! clear_snapshot_rec(tp->tp_snapshot[idx]);
1418 ! tp->tp_snapshot[idx] = NULL;
1424 * This is only done if the screen size didn't change and the window layout is
1428 ! restore_snapshot(close_curwin)
1429 int close_curwin; /* closing current window */
1433 ! if (curtab->tp_snapshot != NULL
1434 # ifdef FEAT_VERTSPLIT
1435 ! && curtab->tp_snapshot->fr_width == topframe->fr_width
1437 ! && curtab->tp_snapshot->fr_height == topframe->fr_height
1438 ! && check_snapshot_rec(curtab->tp_snapshot, topframe) == OK)
1440 ! wp = restore_snapshot_rec(curtab->tp_snapshot, topframe);
1442 if (wp != NULL && close_curwin)
1444 redraw_all_later(CLEAR);
1446 ! clear_snapshot(curtab);
1451 * This is only done if the screen size didn't change and the window layout is
1455 ! restore_snapshot(idx, close_curwin)
1457 int close_curwin; /* closing current window */
1461 ! if (curtab->tp_snapshot[idx] != NULL
1462 # ifdef FEAT_VERTSPLIT
1463 ! && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width
1465 ! && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
1466 ! && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK)
1468 ! wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
1470 if (wp != NULL && close_curwin)
1472 redraw_all_later(CLEAR);
1474 ! clear_snapshot(curtab, idx);
1478 *** ../vim-7.2.202/src/version.c 2009-06-16 15:35:46.000000000 +0200
1479 --- src/version.c 2009-06-16 15:37:16.000000000 +0200
1483 { /* Add new patch number below this line */
1489 How To Keep A Healthy Level Of Insanity:
1490 15. Five days in advance, tell your friends you can't attend their
1491 party because you're not in the mood.
1493 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
1494 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1495 \\\ download, build and distribute -- http://www.A-A-P.org ///
1496 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///