Charles E Campbell Jr wrote:


Just a suggestion -- I'd appreciate a WinClose event. BufWinLeave would almost do, but if two or more windows are open on the same buffer, then no event. WinLeave fires whenever one changes windows, which isn't what I want, either. Unless I'm misunderstanding the help for these two events.


I've attached a patch. It implements WinClose and WinResize. However, I didn't find where the resizing occurs when a mouse is used to drag a window frame, so that's a "known bug". I'd do the documentation up but I'd like to find out if Bram is receptive first.

Regards,
Chip Campbell

*** old_fileio.cc       2006-09-25 15:28:48.000000000 -0400
--- fileio.c    2006-09-25 15:28:51.000000000 -0400
***************
*** 7008,7015 ****
--- 7008,7017 ----
      {"VimEnter",      EVENT_VIMENTER},
      {"VimLeave",      EVENT_VIMLEAVE},
      {"VimLeavePre",   EVENT_VIMLEAVEPRE},
+     {"WinClose",      EVENT_WINCLOSE},
      {"WinEnter",      EVENT_WINENTER},
      {"WinLeave",      EVENT_WINLEAVE},
+     {"WinResize",     EVENT_WINRESIZE},
      {"VimResized",    EVENT_VIMRESIZED},
      {NULL,            (event_T)0}
  };
*** old_window.cc       2006-09-25 15:00:05.000000000 -0400
--- window.c    2006-09-25 15:48:15.000000000 -0400
***************
*** 1587,1592 ****
--- 1587,1595 ----
      win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current,
                      topframe, dir, 0, tabline_height(),
                                           (int)Columns, topframe->fr_height);
+ #ifdef FEAT_AUTOCMD
+     apply_autocmds(EVENT_WINRESIZE, NULL, NULL, FALSE, curbuf);
+ #endif
  }
  
  /*
***************
*** 2068,2073 ****
--- 2071,2077 ----
            return;
  # endif
      }
+     apply_autocmds(EVENT_WINCLOSE, NULL, NULL, FALSE, curbuf);
  #endif
  
      /*
***************
*** 4534,4539 ****
--- 4538,4546 ----
      msg_row = row;
      msg_col = 0;
  
+ #ifdef FEAT_AUTOCMD
+     apply_autocmds(EVENT_WINRESIZE, NULL, NULL, FALSE, curbuf);
+ #endif
      redraw_all_later(NOT_VALID);
  }
  
*** old_vim.hh  2006-09-25 14:55:08.000000000 -0400
--- vim.h       2006-09-25 15:27:47.000000000 -0400
***************
*** 1138,1145 ****
--- 1138,1147 ----
      EVENT_VIMLEAVE,           /* before exiting Vim */
      EVENT_VIMLEAVEPRE,                /* before exiting Vim and writing 
.viminfo */
      EVENT_VIMRESIZED,         /* after Vim window was resized */
+     EVENT_WINCLOSE,           /* after closing a window */
      EVENT_WINENTER,           /* after entering a window */
      EVENT_WINLEAVE,           /* before leaving a window */
+     EVENT_WINRESIZE,          /* after resizing a window */
      EVENT_ENCODINGCHANGED,    /* after changing the 'encoding' option */
      EVENT_CURSORHOLD,         /* cursor in same position for a while */
      EVENT_CURSORHOLDI,                /* idem, in Insert mode */

Reply via email to