To: vim_dev@googlegroups.com Subject: Patch 8.0.0863 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0863 Problem: A remote command starting with CTRL-\ CTRL-N does not work in the terminal window. (Christian J. Robinson) Solution: Use CTRL-\ CTRL-N as a prefix or a Normal mode command. Files: src/terminal.c, runtime/doc/terminal.txt *** ../vim-8.0.0862/src/terminal.c 2017-08-04 20:29:49.048411601 +0200 --- src/terminal.c 2017-08-05 14:03:35.897234103 +0200 *************** *** 52,57 **** --- 52,60 ---- * - make term_getcursor() return type (none/block/bar/underline) and * attributes (color, blink, etc.) * - To set BS correctly, check get_stty(); Pass the fd of the pty. + * For the GUI fill termios with default values, perhaps like pangoterm: + * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134 + * Also get the NL behavior from there. * - do not store terminal window in viminfo. Or prefix term:// ? * - add a character in :ls output * - add 't' to mode() *************** *** 64,70 **** * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? * - implement "term" for job_start(): more job options when starting a ! * terminal. * - support ":term NONE" to open a terminal with a pty but not running a job * in it. The pty can be passed to gdb to run the executable in. * - if the job in the terminal does not support the mouse, we can use the --- 67,74 ---- * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? * - implement "term" for job_start(): more job options when starting a ! * terminal. Might allow reading stdin from a file or buffer, sending stderr ! * to a file or /dev/null, but something must be connected to the terminal. * - support ":term NONE" to open a terminal with a pty but not running a job * in it. The pty can be passed to gdb to run the executable in. * - if the job in the terminal does not support the mouse, we can use the *************** *** 862,867 **** --- 866,873 ---- /* * Send keys to terminal. + * Return FAIL when the key needs to be handled in Normal mode. + * Return OK when the key was dropped or sent to the terminal. */ static int send_keys_to_term(term_T *term, int c, int typed) *************** *** 1038,1044 **** mch_stop_job(curbuf->b_term->tl_job, (char_u *)"quit"); #endif ! if (c == (termkey == 0 ? Ctrl_W : termkey)) { int prev_c = c; --- 1044,1050 ---- mch_stop_job(curbuf->b_term->tl_job, (char_u *)"quit"); #endif ! if (c == (termkey == 0 ? Ctrl_W : termkey) || c == Ctrl_BSL) { int prev_c = c; *************** *** 1054,1060 **** /* job finished while waiting for a character */ break; ! if (termkey == 0 && c == '.') { /* "CTRL-W .": send CTRL-W to the job */ c = Ctrl_W; --- 1060,1074 ---- /* job finished while waiting for a character */ break; ! if (prev_c == Ctrl_BSL) ! { ! if (c == Ctrl_N) ! /* CTRL-\ CTRL-N : execute one Normal mode command. */ ! return OK; ! /* Send both keys to the terminal. */ ! send_keys_to_term(curbuf->b_term, prev_c, TRUE); ! } ! else if (termkey == 0 && c == '.') { /* "CTRL-W .": send CTRL-W to the job */ c = Ctrl_W; *** ../vim-8.0.0862/runtime/doc/terminal.txt 2017-07-30 16:51:35.630143954 +0200 --- runtime/doc/terminal.txt 2017-08-05 14:07:41.843441746 +0200 *************** *** 1,4 **** ! *terminal.txt* For Vim version 8.0. Last change: 2017 Jul 30 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *terminal.txt* For Vim version 8.0. Last change: 2017 Aug 05 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 48,53 **** --- 48,56 ---- Special in the terminal window: *CTRL-W_.* *CTRL-W_N* CTRL-W . send a CTRL-W to the job in the terminal CTRL-W N go to Terminal Normal mode, see |Terminal-mode| + CTRL-W " {reg} paste register {reg} *CTRL-W_quote* + Also works with the = register to insert the result of + evaluating an expression. See option 'termkey' for specifying another key instead of CTRL-W that will work like CTRL-W. However, typing 'termkey' twice sends 'termkey' to *************** *** 58,63 **** --- 61,71 ---- 'termkey' . send a CTRL-W to the job in the terminal 'termkey' N go to terminal Normal mode, see below 'termkey' CTRL-N same as CTRL-W N + *t_CTRL-\_CTRL-N* + The special key combination CTRL-\ CTRL-N can be used to prefix one Normal + mode command. This is especially useful for remote commands, when you don't + know whether Vim currently has focus in a terminal window. Note that only one + Normal mode command can be used. Size ~ *************** *** 76,96 **** If [command] is not given the 'shell' option is used. A new buffer will be created, using [command] or ! 'shell' as the name. If a buffer by this name already ! exists a number is added in parenthesis. ! E.g. if "gdb" exists the second terminal buffer will ! use "gdb (1)". ! ! The window can be closed, in which case 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, using the existing ! buffer. If there are unsaved changes this fails, use ! ! to force, as usual. When the buffer associated with the terminal is wiped out the job is killed, similar to calling `job_stop(job, "kill")` Resizing ~ --- 84,115 ---- If [command] is not given the 'shell' option is used. A new buffer will be created, using [command] or ! 'shell' as the name, prefixed with a "!". If a buffer ! by this name already exists a number is added in ! parenthesis. E.g. if "gdb" exists the second terminal ! buffer will use "!gdb (1)". When the buffer associated with the terminal is 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. + *E947* + So long as the job is running, the buffer is considered modified and Vim + cannot be quit easily, see |abandon|. + + When the job has finished and no changes were made to the buffer: closing the + window will wipe out the buffer. + + Before changes can be made to a terminal buffer, the 'modifiable' option must + be set. This is only possible when the job has finished. At the first change + the buffer will become a normal buffer and the highlighting is removed. + You may want to change the buffer name with |:file| to be able to write, since + the buffer name will still be set to the command. + Resizing ~ *************** *** 138,143 **** --- 157,179 ---- On Unix a pty is used to make it possible to run all kinds of commands. You can even run Vim in the terminal! That's used for debugging, see below. + Environment variables are used to pass information to the running job: + TERM name of the terminal, 'term' + ROWS number of rows in the terminal initially + LINES same as ROWS + COLUMNS number of columns in the terminal initially + COLORS number of colors, 't_Co' (256*256*256 in the GUI) + VIM_SERVERNAME v:servername + + The |client-server| feature can be used to communicate with the Vim instance + where the job was started. This only works when v:servername is not empty. + If needed you can set it with: > + call remote_startserver('vim-server') + + In the job you can then do something like: > + vim --servername $VIM_SERVERNAME --remote +123 some_file.c + This will open the file "some_file.c" and put the cursor on line 123. + MS-Windows ~ *************** *** 191,197 **** This uses two terminal windows. To open the gdb window: > :term gdb [arguments] ! To open the terminal to run the tested program |term_open()| is used. TODO --- 227,233 ---- 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 *** ../vim-8.0.0862/src/version.c 2017-08-04 22:56:34.645851478 +0200 --- src/version.c 2017-08-05 14:09:25.194688462 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 863, /**/ -- There are three kinds of people: Those who can count & those who can't. /// 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 ///