To: vim_dev@googlegroups.com Subject: Patch 8.0.1712 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1712 Problem: Terminal scrollback is not limited. Solution: Add the 'terminalscroll' option. Files: src/terminal.c, src/option.h, src/option.c, runtime/doc/options.txt, runtime/doc/terminal.txt *** ../vim-8.0.1711/src/terminal.c 2018-04-14 17:05:29.787581114 +0200 --- src/terminal.c 2018-04-14 18:12:37.831585340 +0200 *************** *** 40,47 **** * TODO: * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for * redirection. Probably in call to channel_set_pipes(). - * - add an optional limit for the scrollback size. When reaching it remove - * 10% at the start. * - Copy text in the vterm to the Vim buffer once in a while, so that * completion works. * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito --- 40,45 ---- *************** *** 2518,2524 **** { term_T *term = (term_T *)user; ! /* TODO: Limit the number of lines that are stored. */ if (ga_grow(&term->tl_scrollback, 1) == OK) { cellattr_T *p = NULL; --- 2516,2542 ---- { term_T *term = (term_T *)user; ! /* If the number of lines that are stored goes over 'termscrollback' then ! * delete the first 10%. */ ! if (term->tl_scrollback.ga_len > p_tlsl) ! { ! int todo = p_tlsl / 10; ! int i; ! ! curbuf = term->tl_buffer; ! for (i = 0; i < todo; ++i) ! { ! vim_free(((sb_line_T *)term->tl_scrollback.ga_data + i)->sb_cells); ! ml_delete(1, FALSE); ! } ! curbuf = curwin->w_buffer; ! ! term->tl_scrollback.ga_len -= todo; ! mch_memmove(term->tl_scrollback.ga_data, ! (sb_line_T *)term->tl_scrollback.ga_data + todo, ! sizeof(sb_line_T) * term->tl_scrollback.ga_len); ! } ! if (ga_grow(&term->tl_scrollback, 1) == OK) { cellattr_T *p = NULL; *** ../vim-8.0.1711/src/option.h 2018-03-16 20:46:52.666190006 +0100 --- src/option.h 2018-04-14 17:29:08.209530156 +0200 *************** *** 849,854 **** --- 849,857 ---- #ifdef FEAT_ARABIC EXTERN int p_tbidi; /* 'termbidi' */ #endif + #ifdef FEAT_TERMINAL + EXTERN long p_tlsl; /* 'terminalscroll' */ + #endif #ifdef FEAT_MBYTE EXTERN char_u *p_tenc; /* 'termencoding' */ #endif *** ../vim-8.0.1711/src/option.c 2018-04-12 21:37:28.618561305 +0200 --- src/option.c 2018-04-14 17:30:36.296815632 +0200 *************** *** 2750,2755 **** --- 2750,2764 ---- {(char_u *)FALSE, (char_u *)FALSE} #endif SCRIPTID_INIT}, + {"terminalscroll", "tlsl", P_NUM|P_VI_DEF|P_VIM|P_RBUF, + #ifdef FEAT_TERMINAL + (char_u *)&p_tlsl, PV_NONE, + {(char_u *)10000L, (char_u *)10000L} + #else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} + #endif + SCRIPTID_INIT}, {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, #ifdef FEAT_TERMINAL (char_u *)VAR_WIN, PV_TK, *** ../vim-8.0.1711/runtime/doc/options.txt 2018-04-12 21:37:28.618561305 +0200 --- runtime/doc/options.txt 2018-04-14 17:27:13.698481735 +0200 *************** *** 7817,7826 **** For Win32 console, Windows 10 version 1703 (Creators Update) or later is required. Use this check to find out: > if has('vcon') ! < Note that the "cterm" attributes are still used, not the "gui" ones. NOTE: This option is reset when 'compatible' is set. *'termkey'* *'tk'* 'termkey' 'tk' string (default "") local to window --- 7928,7948 ---- For Win32 console, Windows 10 version 1703 (Creators Update) or later is required. Use this check to find out: > if has('vcon') ! < This requires Vim to be built with the |+vtp| feature. ! Note that the "cterm" attributes are still used, not the "gui" ones. NOTE: This option is reset when 'compatible' is set. + *'terminalscroll'* *'tlsl'* + 'terminalscroll' 'tlsl' number (default 10000) + global + {not in Vi} + {not available when compiled without the + |+terminal| feature} + Number of scrollback lines to keep. When going over this limit the + first 10% of the scrollback lines are deleted. This is just to reduce + the memory usage. See |Terminal-Normal|. + *'termkey'* *'tk'* 'termkey' 'tk' string (default "") local to window *** ../vim-8.0.1711/runtime/doc/terminal.txt 2018-04-13 22:11:52.740902329 +0200 --- runtime/doc/terminal.txt 2018-04-14 17:27:04.230561731 +0200 *************** *** 288,294 **** Terminal-Job and Terminal-Normal mode ~ ! *Terminal-mode* When the job is running the contents of the terminal is under control of the job. That includes the cursor position. Typed keys are sent to the job. The terminal contents can change at any time. This is called Terminal-Job --- 288,294 ---- Terminal-Job and Terminal-Normal mode ~ ! *Terminal-mode* *Terminal-Job* When the job is running the contents of the terminal is under control of the job. That includes the cursor position. Typed keys are sent to the job. The terminal contents can change at any time. This is called Terminal-Job *************** *** 301,307 **** Terminal-Job mode is where |:tmap| mappings are applied. Keys sent by |term_sendkeys()| are not subject to tmap, but keys from |feedkeys()| are. ! *E946* In Terminal-Normal mode you can move the cursor around with the usual Vim commands, Visually mark text, yank text, etc. But you cannot change the contents of the buffer. The commands that would start insert mode, such as --- 301,309 ---- Terminal-Job mode is where |:tmap| mappings are applied. Keys sent by |term_sendkeys()| are not subject to tmap, but keys from |feedkeys()| are. ! It is not possible to enter Insert mode from Terminal-Job mode. ! ! *Terminal-Normal* *E946* In Terminal-Normal mode you can move the cursor around with the usual Vim commands, Visually mark text, yank text, etc. But you cannot change the contents of the buffer. The commands that would start insert mode, such as *************** *** 312,318 **** the job ends while in Terminal-Normal mode this changes to "(Terminal-finished)". ! It is not possible to enter Insert mode from Terminal-Job mode. Cursor style ~ --- 314,323 ---- the job ends while in Terminal-Normal mode this changes to "(Terminal-finished)". ! When the job outputs lines in the terminal, such that the contents scrolls off ! the top, those lines are remembered and can be seen in Terminal-Normal mode. ! The number of lines is limited by the 'terminalscroll' option. When going over ! this limit, the first 10% of the scrolled lins are deleted and are lost. Cursor style ~ *** ../vim-8.0.1711/src/version.c 2018-04-14 17:05:29.791581088 +0200 --- src/version.c 2018-04-14 17:28:07.154034009 +0200 *************** *** 764,765 **** --- 764,767 ---- { /* Add new patch number below this line */ + /**/ + 1712, /**/ -- The CIA drives around in cars with the "Intel inside" logo. /// 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 ///