Skip to content

Commit 6d150f7

Browse files
committed
patch 8.0.1743: terminal window options are named inconsistently
Problem: Terminal window options are named inconsistently. Solution: prefix terminal window options with "termwin". Keep the old names for now as an alias.
1 parent e1fc515 commit 6d150f7

File tree

8 files changed

+108
-56
lines changed

8 files changed

+108
-56
lines changed

runtime/doc/options.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 8.0. Last change: 2018 Apr 18
1+
*options.txt* For Vim version 8.0. Last change: 2018 Apr 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -7444,7 +7444,9 @@ A jump table for the options with a short description can be found at |Q_op|.
74447444
a S Argument list status as in default title. ({current} of {max})
74457445
Empty if the argument file count is zero or one.
74467446
{ NF Evaluate expression between '%{' and '}' and substitute result.
7447-
Note that there is no '%' before the closing '}'.
7447+
Note that there is no '%' before the closing '}'. The
7448+
expression cannot contain a '}' character, call a function to
7449+
work around that.
74487450
( - Start of item group. Can be used for setting the width and
74497451
alignment of a section. Must be followed by %) somewhere.
74507452
) - End of item group. No width fields allowed.

runtime/optwin.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,15 @@ if has("cursorbind")
506506
call <SID>BinOptionL("crb")
507507
endif
508508
if has("terminal")
509-
call append("$", "termsize\tsize of a terminal window")
509+
call append("$", "termwinsize\tsize of a terminal window")
510510
call append("$", "\t(local to window)")
511-
call <SID>OptionL("tms")
512-
call append("$", "termkey\tkey that precedes Vim commands in a terminal window")
511+
call <SID>OptionL("tws")
512+
call append("$", "termwinkey\tkey that precedes Vim commands in a terminal window")
513513
call append("$", "\t(local to window)")
514-
call <SID>OptionL("tk")
514+
call <SID>OptionL("twk")
515+
call append("$", "termwinscroll\tmax number of lines to keep for scrollback in a terminal window")
516+
call append("$", "\t(local to window)")
517+
call <SID>OptionL("twsl")
515518
if exists("&winptydll")
516519
call append("$", "winptydll\tname of the winpty dynamic library")
517520
call <SID>OptionG("winptydll", &winptydll)

src/option.c

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@
250250
# define PV_COLE OPT_WIN(WV_COLE)
251251
#endif
252252
#ifdef FEAT_TERMINAL
253-
# define PV_TK OPT_WIN(WV_TK)
254-
# define PV_TMS OPT_WIN(WV_TMS)
253+
# define PV_TWK OPT_WIN(WV_TWK)
254+
# define PV_TWS OPT_WIN(WV_TWS)
255+
# define PV_TWSL OPT_BUF(BV_TWSL)
255256
#endif
256257
#ifdef FEAT_SIGNS
257258
# define PV_SCL OPT_WIN(WV_SCL)
@@ -373,6 +374,9 @@ static long p_wm;
373374
#ifdef FEAT_KEYMAP
374375
static char_u *p_keymap;
375376
#endif
377+
#ifdef FEAT_TERMINAL
378+
static long p_twsl;
379+
#endif
376380

377381
/* Saved values for when 'bin' is set. */
378382
static int p_et_nobin;
@@ -2750,27 +2754,57 @@ static struct vimoption options[] =
27502754
{(char_u *)FALSE, (char_u *)FALSE}
27512755
#endif
27522756
SCRIPTID_INIT},
2757+
/* TODO: remove this deprecated entry */
27532758
{"terminalscroll", "tlsl", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
27542759
#ifdef FEAT_TERMINAL
2755-
(char_u *)&p_tlsl, PV_NONE,
2760+
(char_u *)&p_twsl, PV_TWSL,
27562761
{(char_u *)10000L, (char_u *)10000L}
27572762
#else
27582763
(char_u *)NULL, PV_NONE,
27592764
{(char_u *)NULL, (char_u *)0L}
27602765
#endif
27612766
SCRIPTID_INIT},
2762-
{"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2767+
/* TODO: remove this deprecated entry */
2768+
{"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
27632769
#ifdef FEAT_TERMINAL
2764-
(char_u *)VAR_WIN, PV_TK,
2770+
(char_u *)VAR_WIN, PV_TWK,
27652771
{(char_u *)"", (char_u *)NULL}
27662772
#else
27672773
(char_u *)NULL, PV_NONE,
27682774
{(char_u *)NULL, (char_u *)0L}
27692775
#endif
27702776
SCRIPTID_INIT},
2777+
/* TODO: remove this deprecated entry */
27712778
{"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
27722779
#ifdef FEAT_TERMINAL
2773-
(char_u *)VAR_WIN, PV_TMS,
2780+
(char_u *)VAR_WIN, PV_TWS,
2781+
{(char_u *)"", (char_u *)NULL}
2782+
#else
2783+
(char_u *)NULL, PV_NONE,
2784+
{(char_u *)NULL, (char_u *)0L}
2785+
#endif
2786+
SCRIPTID_INIT},
2787+
{"termwinkey", "twk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2788+
#ifdef FEAT_TERMINAL
2789+
(char_u *)VAR_WIN, PV_TWK,
2790+
{(char_u *)"", (char_u *)NULL}
2791+
#else
2792+
(char_u *)NULL, PV_NONE,
2793+
{(char_u *)NULL, (char_u *)0L}
2794+
#endif
2795+
SCRIPTID_INIT},
2796+
{"termwinscroll", "twsl", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2797+
#ifdef FEAT_TERMINAL
2798+
(char_u *)&p_twsl, PV_TWSL,
2799+
{(char_u *)10000L, (char_u *)10000L}
2800+
#else
2801+
(char_u *)NULL, PV_NONE,
2802+
{(char_u *)NULL, (char_u *)0L}
2803+
#endif
2804+
SCRIPTID_INIT},
2805+
{"termwinsize", "tws", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2806+
#ifdef FEAT_TERMINAL
2807+
(char_u *)VAR_WIN, PV_TWS,
27742808
{(char_u *)"", (char_u *)NULL}
27752809
#else
27762810
(char_u *)NULL, PV_NONE,
@@ -7452,19 +7486,20 @@ did_set_string_option(
74527486
#endif
74537487

74547488
#ifdef FEAT_TERMINAL
7455-
/* 'termkey' */
7456-
else if (varp == &curwin->w_p_tk)
7489+
/* 'termwinkey' */
7490+
else if (varp == &curwin->w_p_twk)
74577491
{
7458-
if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7492+
if (*curwin->w_p_twk != NUL
7493+
&& string_to_key(curwin->w_p_twk, TRUE) == 0)
74597494
errmsg = e_invarg;
74607495
}
7461-
/* 'termsize' */
7462-
else if (varp == &curwin->w_p_tms)
7496+
/* 'termwinsize' */
7497+
else if (varp == &curwin->w_p_tws)
74637498
{
7464-
if (*curwin->w_p_tms != NUL)
7499+
if (*curwin->w_p_tws != NUL)
74657500
{
7466-
p = skipdigits(curwin->w_p_tms);
7467-
if (p == curwin->w_p_tms
7501+
p = skipdigits(curwin->w_p_tws);
7502+
if (p == curwin->w_p_tws
74687503
|| (*p != 'x' && *p != '*')
74697504
|| *skipdigits(p + 1) != NUL)
74707505
errmsg = e_invarg;
@@ -10687,8 +10722,9 @@ get_varp(struct vimoption *p)
1068710722
case PV_COLE: return (char_u *)&(curwin->w_p_cole);
1068810723
#endif
1068910724
#ifdef FEAT_TERMINAL
10690-
case PV_TK: return (char_u *)&(curwin->w_p_tk);
10691-
case PV_TMS: return (char_u *)&(curwin->w_p_tms);
10725+
case PV_TWK: return (char_u *)&(curwin->w_p_twk);
10726+
case PV_TWS: return (char_u *)&(curwin->w_p_tws);
10727+
case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl);
1069210728
#endif
1069310729

1069410730
case PV_AI: return (char_u *)&(curbuf->b_p_ai);
@@ -10887,8 +10923,8 @@ copy_winopt(winopt_T *from, winopt_T *to)
1088710923
to->wo_cole = from->wo_cole;
1088810924
#endif
1088910925
#ifdef FEAT_TERMINAL
10890-
to->wo_tk = vim_strsave(from->wo_tk);
10891-
to->wo_tms = vim_strsave(from->wo_tms);
10926+
to->wo_twk = vim_strsave(from->wo_twk);
10927+
to->wo_tws = vim_strsave(from->wo_tws);
1089210928
#endif
1089310929
#ifdef FEAT_FOLDING
1089410930
to->wo_fdc = from->wo_fdc;
@@ -10957,8 +10993,8 @@ check_winopt(winopt_T *wop UNUSED)
1095710993
check_string_option(&wop->wo_cocu);
1095810994
#endif
1095910995
#ifdef FEAT_TERMINAL
10960-
check_string_option(&wop->wo_tk);
10961-
check_string_option(&wop->wo_tms);
10996+
check_string_option(&wop->wo_twk);
10997+
check_string_option(&wop->wo_tws);
1096210998
#endif
1096310999
#ifdef FEAT_LINEBREAK
1096411000
check_string_option(&wop->wo_briopt);
@@ -11000,8 +11036,8 @@ clear_winopt(winopt_T *wop UNUSED)
1100011036
clear_string_option(&wop->wo_cocu);
1100111037
#endif
1100211038
#ifdef FEAT_TERMINAL
11003-
clear_string_option(&wop->wo_tk);
11004-
clear_string_option(&wop->wo_tms);
11039+
clear_string_option(&wop->wo_twk);
11040+
clear_string_option(&wop->wo_tws);
1100511041
#endif
1100611042
}
1100711043

@@ -11177,6 +11213,9 @@ buf_copy_options(buf_T *buf, int flags)
1117711213
#ifdef FEAT_KEYMAP
1117811214
buf->b_p_keymap = vim_strsave(p_keymap);
1117911215
buf->b_kmap_state |= KEYMAP_INIT;
11216+
#endif
11217+
#ifdef FEAT_TERMINAL
11218+
buf->b_p_twsl = p_twsl;
1118011219
#endif
1118111220
/* This isn't really an option, but copying the langmap and IME
1118211221
* state from the current buffer is better than resetting it. */

src/option.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,9 @@ enum
11141114
, BV_UDF
11151115
, BV_UL
11161116
, BV_WM
1117+
#ifdef FEAT_TERMINAL
1118+
, BV_TWSL
1119+
#endif
11171120
, BV_COUNT /* must be the last one */
11181121
};
11191122

@@ -1133,8 +1136,8 @@ enum
11331136
, WV_COLE
11341137
#endif
11351138
#ifdef FEAT_TERMINAL
1136-
, WV_TK
1137-
, WV_TMS
1139+
, WV_TWK
1140+
, WV_TWS
11381141
#endif
11391142
, WV_CRBIND
11401143
#ifdef FEAT_LINEBREAK

src/terminal.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
* redirection. Probably in call to channel_set_pipes().
4343
* - Win32: Redirecting output does not work, Test_terminal_redir_file()
4444
* is disabled.
45+
* - Add test for 'termwinkey'.
46+
* - libvterm: bringg back using // comments and trailing comma in enum
4547
* - When starting terminal window with shell in terminal, then using :gui to
4648
* switch to GUI, shell stops working. Scrollback seems wrong, command
4749
* running in shell is still running.
@@ -215,17 +217,17 @@ parse_termsize(win_T *wp, int *rows, int *cols)
215217
*rows = 0;
216218
*cols = 0;
217219

218-
if (*wp->w_p_tms != NUL)
220+
if (*wp->w_p_tws != NUL)
219221
{
220-
char_u *p = vim_strchr(wp->w_p_tms, 'x');
222+
char_u *p = vim_strchr(wp->w_p_tws, 'x');
221223

222224
/* Syntax of value was already checked when it's set. */
223225
if (p == NULL)
224226
{
225227
minsize = TRUE;
226-
p = vim_strchr(wp->w_p_tms, '*');
228+
p = vim_strchr(wp->w_p_tws, '*');
227229
}
228-
*rows = atoi((char *)wp->w_p_tms);
230+
*rows = atoi((char *)wp->w_p_tws);
229231
*cols = atoi((char *)p + 1);
230232
}
231233
return minsize;
@@ -2000,8 +2002,8 @@ terminal_loop(int blocking)
20002002
* stored reference. */
20012003
in_terminal_loop = curbuf->b_term;
20022004

2003-
if (*curwin->w_p_tk != NUL)
2004-
termkey = string_to_key(curwin->w_p_tk, TRUE);
2005+
if (*curwin->w_p_twk != NUL)
2006+
termkey = string_to_key(curwin->w_p_twk, TRUE);
20052007
position_cursor(curwin, &curbuf->b_term->tl_cursor_pos);
20062008
may_set_cursor_props(curbuf->b_term);
20072009

@@ -2562,9 +2564,9 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
25622564

25632565
/* If the number of lines that are stored goes over 'termscrollback' then
25642566
* delete the first 10%. */
2565-
if (term->tl_scrollback.ga_len >= p_tlsl)
2567+
if (term->tl_scrollback.ga_len >= term->tl_buffer->b_p_twsl)
25662568
{
2567-
int todo = p_tlsl / 10;
2569+
int todo = term->tl_buffer->b_p_twsl / 10;
25682570
int i;
25692571

25702572
curbuf = term->tl_buffer;

src/testdir/gen_opt_test.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ let test_values = {
130130
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
131131
\ 'term': [[], []],
132132
\ 'termguicolors': [[], []],
133-
\ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
134133
\ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
134+
\ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
135+
\ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
135136
\ 'toolbar': [['', 'icons', 'text'], ['xxx']],
136137
\ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
137138
\ 'ttymouse': [['', 'xterm'], ['xxx']],

src/testdir/test_terminal.vim

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ endfunc
273273

274274
func Test_terminal_scrollback()
275275
let buf = Run_shell_in_terminal({})
276-
set terminalscroll=100
276+
set termwinscroll=100
277277
call writefile(range(150), 'Xtext')
278278
if has('win32')
279279
call term_sendkeys(buf, "type Xtext\<CR>")
@@ -289,7 +289,7 @@ func Test_terminal_scrollback()
289289
call Stop_shell_in_terminal(buf)
290290
call term_wait(buf)
291291
exe buf . 'bwipe'
292-
set terminalscroll&
292+
set termwinscroll&
293293
endfunc
294294

295295
func Test_terminal_size()
@@ -1381,11 +1381,11 @@ func Test_terminal_ansicolors_func()
13811381
exe buf . 'bwipe'
13821382
endfunc
13831383

1384-
func Test_terminal_termsize_option_fixed()
1384+
func Test_terminal_termwinsize_option_fixed()
13851385
if !CanRunVimInTerminal()
13861386
return
13871387
endif
1388-
set termsize=6x40
1388+
set termwinsize=6x40
13891389
let text = []
13901390
for n in range(10)
13911391
call add(text, repeat(n, 50))
@@ -1407,43 +1407,43 @@ func Test_terminal_termsize_option_fixed()
14071407
call StopVimInTerminal(buf)
14081408
call delete('Xwinsize')
14091409

1410-
call assert_fails('set termsize=40', 'E474')
1411-
call assert_fails('set termsize=10+40', 'E474')
1412-
call assert_fails('set termsize=abc', 'E474')
1410+
call assert_fails('set termwinsize=40', 'E474')
1411+
call assert_fails('set termwinsize=10+40', 'E474')
1412+
call assert_fails('set termwinsize=abc', 'E474')
14131413

1414-
set termsize=
1414+
set termwinsize=
14151415
endfunc
14161416

1417-
func Test_terminal_termsize_option_zero()
1418-
set termsize=0x0
1417+
func Test_terminal_termwinsize_option_zero()
1418+
set termwinsize=0x0
14191419
let buf = Run_shell_in_terminal({})
14201420
let win = bufwinid(buf)
14211421
call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
14221422
call Stop_shell_in_terminal(buf)
14231423
call term_wait(buf)
14241424
exe buf . 'bwipe'
14251425

1426-
set termsize=7x0
1426+
set termwinsize=7x0
14271427
let buf = Run_shell_in_terminal({})
14281428
let win = bufwinid(buf)
14291429
call assert_equal([7, winwidth(win)], term_getsize(buf))
14301430
call Stop_shell_in_terminal(buf)
14311431
call term_wait(buf)
14321432
exe buf . 'bwipe'
14331433

1434-
set termsize=0x33
1434+
set termwinsize=0x33
14351435
let buf = Run_shell_in_terminal({})
14361436
let win = bufwinid(buf)
14371437
call assert_equal([winheight(win), 33], term_getsize(buf))
14381438
call Stop_shell_in_terminal(buf)
14391439
call term_wait(buf)
14401440
exe buf . 'bwipe'
14411441

1442-
set termsize=
1442+
set termwinsize=
14431443
endfunc
14441444

1445-
func Test_terminal_termsize_mininmum()
1446-
set termsize=10*50
1445+
func Test_terminal_termwinsize_mininmum()
1446+
set termwinsize=10*50
14471447
vsplit
14481448
let buf = Run_shell_in_terminal({})
14491449
let win = bufwinid(buf)
@@ -1469,13 +1469,13 @@ func Test_terminal_termsize_mininmum()
14691469
call term_wait(buf)
14701470
exe buf . 'bwipe'
14711471

1472-
set termsize=0*0
1472+
set termwinsize=0*0
14731473
let buf = Run_shell_in_terminal({})
14741474
let win = bufwinid(buf)
14751475
call assert_equal([winheight(win), winwidth(win)], term_getsize(buf))
14761476
call Stop_shell_in_terminal(buf)
14771477
call term_wait(buf)
14781478
exe buf . 'bwipe'
14791479

1480-
set termsize=
1480+
set termwinsize=
14811481
endfunc

0 commit comments

Comments
 (0)