To: vim_dev@googlegroups.com Subject: Patch 8.0.1013 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1013 Problem: A terminal window with a running job behaves different from a window containing a changed buffer. Solution: Do not set 'bufhidden' to "hide". Fix that a buffer where a terminal used to run is listed as "[Scratch]". Files: src/terminal.c, runtime/doc/terminal.txt, src/buffer.c *** ../vim-8.0.1012/src/terminal.c 2017-08-28 22:43:00.778266633 +0200 --- src/terminal.c 2017-08-29 22:42:56.712814090 +0200 *************** *** 44,53 **** * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? - * - do not set bufhidden to "hide"? works like a buffer with changes. - * document that CTRL-W :hide can be used. * - GUI: when using tabs, focus in terminal, click on tab does not work. - * - When $HOME was set by Vim (MS-Windows), do not pass it to the job. * - GUI: when 'confirm' is set and trying to exit Vim, dialog offers to save * changes to "!shell". * (justrajdeep, 2017 Aug 22) --- 44,50 ---- *************** *** 399,408 **** * the job finished. */ curbuf->b_p_ma = FALSE; - /* Set 'bufhidden' to "hide": allow closing the window. */ - set_string_option_direct((char_u *)"bufhidden", -1, - (char_u *)"hide", OPT_FREE|OPT_LOCAL, 0); - set_term_and_win_size(term); setup_job_options(opt, term->tl_rows, term->tl_cols); --- 396,401 ---- *** ../vim-8.0.1012/runtime/doc/terminal.txt 2017-08-20 18:09:09.767276733 +0200 --- runtime/doc/terminal.txt 2017-08-29 22:43:51.060455771 +0200 *************** *** 1,4 **** ! *terminal.txt* For Vim version 8.0. Last change: 2017 Aug 20 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *terminal.txt* For Vim version 8.0. Last change: 2017 Aug 29 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 19,24 **** --- 19,27 ---- 3. Debugging |terminal-debug| {Vi does not have any of these commands} + {only available when compiled with the |+terminal| feature} + + The terminal feature requires the |+multi_byte|, |+job| and |+channel| features. ============================================================================== 1. Basic use *terminal-use* *************** *** 95,100 **** --- 98,105 ---- If [command] is provided run it as a job and connect the input and output to the terminal. If [command] is not given the 'shell' option is used. + if [command] is NONE no job is started, the pty of the + terminal can be used by a command like gdb. A new buffer will be created, using [command] or 'shell' as the name, prefixed with a "!". If a buffer *************** *** 135,145 **** When the buffer associated with the terminal is unloaded or wiped out the job is killed, similar to calling `job_stop(job, "kill")` ! By default the 'bufhidden' option of the buffer will be set to "hide". ! So long as the job is running: If the window is closed the buffer becomes ! hidden. The command will not be stopped. The `:buffer` command can be used ! to turn the current window into a terminal window. If there are unsaved ! changes this fails, use ! to force, as usual. To have a background job run without a window, and open the window when it's done, use options like this: > --- 140,156 ---- When the buffer associated with the terminal is unloaded or wiped out the job is killed, similar to calling `job_stop(job, "kill")` ! So long as the job is running the window behaves like it contains a modified ! buffer. Trying to close the window with `CTRL-W :close` or `CTRL-W :hide` ! fails, unless "!" is added, in which case the job is ended. The text in the ! window is lost. The buffer still exists, but getting it in a window with ! `:buffer` will show an ! empty buffer. ! ! You can use `CTRL-W :hide` to close the terminal window and make the buffer ! hidden, the job keeps running. The `:buffer` command can be used to turn the ! current window into a terminal window. If there are unsaved changes this ! fails, use ! to force, as usual. To have a background job run without a window, and open the window when it's done, use options like this: > *************** *** 207,212 **** --- 218,236 ---- It is not possible to enter Insert mode from Terminal-Job mode. + Cursor style ~ + + By default the cursor in the terminal window uses a not blinking block. The + normal xterm escape sequences can be used to change the blinking state and the + shape. Once focus leaves the terminal window Vim will restore the original + cursor. + + An exception is when xterm is started with the "-bc" argument, or another way + that causes the cursor to blink. This actually means that the blinking flag + is inverted. Since Vim cannot detect this, the terminal window cursor + blinking will also be inverted. + + Unix ~ On Unix a pty is used to make it possible to run all kinds of commands. You *************** *** 269,291 **** 3. Debugging *terminal-debug* The Terminal debugging plugin can be used to debug a program with gdb and view ! the source code in a Vim window. For example: > :TermDebug vim ! This opens three windows: - A terminal window in which "gdb vim" is executed. Here you can directly interact with gdb. - A terminal window for the executed program. When "run" is used in gdb the program I/O will happen in this window, so that it does not interfere with controlling gdb. ! - A normal Vim window used to show the source code. When gdb jumps to a ! source file location this window will display the code, if possible. Values ! of variables can be inspected, breakpoints set and cleared, etc. ! ! This uses two terminal windows. To open the gdb window: > ! :term gdb [arguments] ! To open the terminal to run the tested program |term_start()| is used. TODO --- 293,323 ---- 3. Debugging *terminal-debug* The Terminal debugging plugin can be used to debug a program with gdb and view ! the source code in a Vim window. ! ! Load the plugin with this command: > ! packadd termdebug + To start debugging use `:TermDebug` folowed by the command name, for example: > :TermDebug vim ! This opens two windows: - A terminal window in which "gdb vim" is executed. Here you can directly interact with gdb. - A terminal window for the executed program. When "run" is used in gdb the program I/O will happen in this window, so that it does not interfere with controlling gdb. ! The current window is used to show the source code. When gdb jumps to a ! source file location this window will display the code, if possible. Values ! of variables can be inspected, breakpoints set and cleared, etc. ! ! When the debugger ends the two opened windows are closed. ! ! ! Customizing ~ ! ! g:debugger The debugger command. Default "gdb". ! TODO *** ../vim-8.0.1012/src/buffer.c 2017-08-17 16:55:08.629414811 +0200 --- src/buffer.c 2017-08-29 22:22:18.176953401 +0200 *************** *** 5825,5832 **** if (buf->b_term != NULL) return term_get_status_text(buf->b_term); #endif ! if (buf->b_sfname != NULL) ! return buf->b_sfname; return (char_u *)_("[Scratch]"); } --- 5825,5832 ---- if (buf->b_term != NULL) return term_get_status_text(buf->b_term); #endif ! if (buf->b_fname != NULL) ! return buf->b_fname; return (char_u *)_("[Scratch]"); } *** ../vim-8.0.1012/src/version.c 2017-08-29 21:44:55.079627984 +0200 --- src/version.c 2017-08-29 22:17:11.174959536 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1013, /**/ -- If you put 7 of the most talented OSS developers in a room for a week and asked them to fix a bug in a spreadsheet program, in 1 week you'd have 2 new mail readers and a text-based web browser. /// Bram Moolenaar -- Bram@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 ///