Patch 8.0.1596
Problem:    No autocommand specifically for opening a terminal window.
Solution:   Add TerminalOpen. (?, closes #2484)
Files:      runtime/doc/autocmd.txt, src/fileio.c, src/terminal.c,
            src/testdir/test_terminal.vim, src/vim.h


*** ../vim-8.0.1595/runtime/doc/autocmd.txt     2018-03-11 14:43:53.084536821 
+0100
--- runtime/doc/autocmd.txt     2018-03-11 16:42:40.913307807 +0100
***************
*** 242,247 ****
--- 257,263 ----
  |BufCreate|           just after adding a buffer to the buffer list
  |BufDelete|           before deleting a buffer from the buffer list
  |BufWipeout|          before completely deleting a buffer
+ |TerminalOpen|                after a terminal buffer was created
  
  |BufFilePre|          before changing the name of the current buffer
  |BufFilePost|         after changing the name of the current buffer
***************
*** 309,314 ****
--- 325,334 ----
  |CmdwinEnter|         after entering the command-line window
  |CmdwinLeave|         before leaving the command-line window
  
+ |CmdlineChanged|      after a change was made to the command-line text
+ |CmdlineEnter|                after the cursor moves to the command line
+ |CmdlineLeave|                before the cursor leaves the command line
+ 
  |InsertEnter|         starting Insert mode
  |InsertChange|                when typing <Insert> while in Insert or Replace 
mode
  |InsertLeave|         when leaving Insert mode
***************
*** 947,952 ****
--- 969,979 ----
                                for re-loading the syntax file to update the
                                colors, fonts and other terminal-dependent
                                settings.  Executed for all loaded buffers.
+                                                       *TerminalOpen*
+ TerminalOpen                  Just after a terminal buffer was created, with
+                               `:terminal` or |term_start()|. This event is
+                               triggered even if the buffer is created
+                               without a window, with the ++hidden option.
                                                        *TermResponse*
  TermResponse                  After the response to |t_RV| is received from
                                the terminal.  The value of |v:termresponse|
*** ../vim-8.0.1595/src/fileio.c        2018-03-11 14:43:53.080536844 +0100
--- src/fileio.c        2018-03-11 16:33:23.188698369 +0100
***************
*** 7773,7778 ****
--- 7773,7779 ----
      {"TabEnter",      EVENT_TABENTER},
      {"TabLeave",      EVENT_TABLEAVE},
      {"TermChanged",   EVENT_TERMCHANGED},
+     {"TerminalOpen",  EVENT_TERMINALOPEN},
      {"TermResponse",  EVENT_TERMRESPONSE},
      {"TextChanged",   EVENT_TEXTCHANGED},
      {"TextChangedI",  EVENT_TEXTCHANGEDI},
*** ../vim-8.0.1595/src/terminal.c      2018-03-10 20:27:32.071757661 +0100
--- src/terminal.c      2018-03-11 16:53:13.633448022 +0100
***************
*** 38,82 ****
   * in tl_scrollback are no longer used.
   *
   * TODO:
!  * - Add a flag to kill the job when Vim is exiting.  Useful when it's showing
!  *   a logfile.  Or send keys there to make it quit: "exit\r" for a shell.
   * - When using 'termguicolors' still use the 16 ANSI colors as-is.  Helps for
   * - Adding WinBar to terminal window doesn't display, text isn't shifted 
down.
   *   a job that uses 16 colors while Vim is using > 256.
   * - in GUI vertical split causes problems.  Cursor is flickering. (Hirohito
   *   Higashi, 2017 Sep 19)
-  * - Trigger TerminalOpen event?  #2422  patch in #2484
   * - after resizing windows overlap. (Boris Staletic, #2164)
   * - Redirecting output does not work on MS-Windows, 
Test_terminal_redir_file()
   *   is disabled.
-  * - if the job in the terminal does not support the mouse, we can use the
-  *   mouse in the Terminal window for copy/paste and scrolling.
   * - cursor blinks in terminal on widows with a timer. (xtal8, #2142)
-  * - When closing gvim with an active terminal buffer, the dialog suggests
-  *   saving the buffer.  Should say something else. (Manas Thakur, #2215)
-  *   Also: #2223
   * - Termdebug does not work when Vim build with mzscheme.  gdb hangs.
   * - MS-Windows GUI: WinBar has  tearoff item
   * - MS-Windows GUI: still need to type a key after shell exits?  #1924
   * - After executing a shell command the status line isn't redraw.
-  * - implement term_setsize()
   * - add test for giving error for invalid 'termsize' value.
   * - support minimal size when 'termsize' is "rows*cols".
   * - support minimal size when 'termsize' is empty?
   * - GUI: when using tabs, focus in terminal, click on tab does not work.
-  * - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save
-  *   changes to "!shell".
-  *   (justrajdeep, 2017 Aug 22)
   * - Redrawing is slow with Athena and Motif.  Also other GUI? (Ramel Eshed)
   * - For the GUI fill termios with default values, perhaps like pangoterm:
   *   
http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
   * - when 'encoding' is not utf-8, or the job is using another encoding, setup
   *   conversions.
-  * - In the GUI use a terminal emulator for :!cmd.  Make the height the same 
as
-  *   the window and position it higher up when it gets filled, so it looks 
like
-  *   the text scrolls up.
-  * - Copy text in the vterm to the Vim buffer once in a while, so that
-  *   completion works.
   * - add an optional limit for the scrollback size.  When reaching it remove
   *   10% at the start.
   */
--- 38,73 ----
   * in tl_scrollback are no longer used.
   *
   * TODO:
!  * - if the job in the terminal does not support the mouse, we can use the
!  *   mouse in the Terminal window for copy/paste and scrolling.
   * - When using 'termguicolors' still use the 16 ANSI colors as-is.  Helps for
+  * - In the GUI use a terminal emulator for :!cmd.  Make the height the same 
as
+  *   the window and position it higher up when it gets filled, so it looks 
like
+  *   the text scrolls up.
+  * - implement term_setsize()
+  * - Copy text in the vterm to the Vim buffer once in a while, so that
+  *   completion works.
   * - Adding WinBar to terminal window doesn't display, text isn't shifted 
down.
   *   a job that uses 16 colors while Vim is using > 256.
   * - in GUI vertical split causes problems.  Cursor is flickering. (Hirohito
   *   Higashi, 2017 Sep 19)
   * - after resizing windows overlap. (Boris Staletic, #2164)
   * - Redirecting output does not work on MS-Windows, 
Test_terminal_redir_file()
   *   is disabled.
   * - cursor blinks in terminal on widows with a timer. (xtal8, #2142)
   * - Termdebug does not work when Vim build with mzscheme.  gdb hangs.
   * - MS-Windows GUI: WinBar has  tearoff item
   * - MS-Windows GUI: still need to type a key after shell exits?  #1924
   * - After executing a shell command the status line isn't redraw.
   * - add test for giving error for invalid 'termsize' value.
   * - support minimal size when 'termsize' is "rows*cols".
   * - support minimal size when 'termsize' is empty?
   * - GUI: when using tabs, focus in terminal, click on tab does not work.
   * - Redrawing is slow with Athena and Motif.  Also other GUI? (Ramel Eshed)
   * - For the GUI fill termios with default values, perhaps like pangoterm:
   *   
http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
   * - when 'encoding' is not utf-8, or the job is using another encoding, setup
   *   conversions.
   * - add an optional limit for the scrollback size.  When reaching it remove
   *   10% at the start.
   */
***************
*** 582,587 ****
--- 573,580 ----
        term_close_buffer(curbuf, old_curbuf);
        return NULL;
      }
+ 
+     apply_autocmds(EVENT_TERMINALOPEN, NULL, NULL, FALSE, curbuf);
      return newbuf;
  }
  
*** ../vim-8.0.1595/src/testdir/test_terminal.vim       2018-03-10 
20:51:21.262808421 +0100
--- src/testdir/test_terminal.vim       2018-03-11 16:53:55.081195270 +0100
***************
*** 908,910 ****
--- 908,944 ----
    " close the terminal window where Vim was running
    quit
  endfunc
+ 
+ func Test_terminalopen_autocmd()
+   augroup repro
+     au!
+     au TerminalOpen * let s:called += 1
+   augroup END
+ 
+   let s:called = 0
+ 
+   " Open a terminal window with :terminal
+   terminal
+   call assert_equal(1, s:called)
+   bwipe!
+ 
+   " Open a terminal window with term_start()
+   call term_start(&shell)
+   call assert_equal(2, s:called)
+   bwipe!
+ 
+   " Open a hidden terminal buffer with :terminal
+   terminal ++hidden
+   call assert_equal(3, s:called)
+   for buf in term_list()
+     exe buf . "bwipe!"
+   endfor
+ 
+   " Open a hidden terminal buffer with term_start()
+   let buf = term_start(&shell, {'hidden': 1})
+   call assert_equal(4, s:called)
+   exe buf . "bwipe!"
+ 
+   unlet s:called
+   au! repro
+ endfunction
*** ../vim-8.0.1595/src/vim.h   2018-03-11 14:43:53.084536821 +0100
--- src/vim.h   2018-03-11 16:44:09.912764716 +0100
***************
*** 1346,1351 ****
--- 1346,1352 ----
      EVENT_CMDUNDEFINED,               /* command undefined */
      EVENT_OPTIONSET,          /* option was set */
      EVENT_TEXTYANKPOST,               /* after some text was yanked */
+     EVENT_TERMINALOPEN,               /* after a terminal buffer was created 
*/
      NUM_EVENTS                        /* MUST be the last one */
  };
  
*** ../vim-8.0.1595/src/version.c       2018-03-11 14:43:53.088536797 +0100
--- src/version.c       2018-03-11 16:35:36.111891707 +0100
***************
*** 768,769 ****
--- 768,771 ----
  {   /* Add new patch number below this line */
+ /**/
+     1596,
  /**/

-- 
It doesn't really matter what you are able to do if you don't do it.
                                (Bram Moolenaar)

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui