Skip to content

Commit dbe948d

Browse files
committed
patch 8.0.0764: 'termkey' does not work yet
Problem: 'termkey' does not work yet. Solution: Implement 'termkey'.
1 parent b6e0ec6 commit dbe948d

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

src/option.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,6 @@ static void set_options_default(int opt_flags);
32693269
static char_u *term_bg_default(void);
32703270
static void did_set_option(int opt_idx, int opt_flags, int new_value);
32713271
static char_u *illegal_char(char_u *, int);
3272-
static int string_to_key(char_u *arg);
32733272
#ifdef FEAT_CMDWIN
32743273
static char_u *check_cedit(void);
32753274
#endif
@@ -4763,7 +4762,7 @@ do_set(
47634762
&& (!arg[1] || VIM_ISWHITE(arg[1]))
47644763
&& !VIM_ISDIGIT(*arg))))
47654764
{
4766-
value = string_to_key(arg);
4765+
value = string_to_key(arg, FALSE);
47674766
if (value == 0 && (long *)varp != &p_wcm)
47684767
{
47694768
errmsg = e_invarg;
@@ -5320,14 +5319,17 @@ illegal_char(char_u *errbuf, int c)
53205319
/*
53215320
* Convert a key name or string into a key value.
53225321
* Used for 'wildchar' and 'cedit' options.
5322+
* When "multi_byte" is TRUE allow for multi-byte characters.
53235323
*/
5324-
static int
5325-
string_to_key(char_u *arg)
5324+
int
5325+
string_to_key(char_u *arg, int multi_byte)
53265326
{
53275327
if (*arg == '<')
53285328
return find_key_option(arg + 1);
53295329
if (*arg == '^')
53305330
return Ctrl_chr(arg[1]);
5331+
if (multi_byte)
5332+
return PTR2CHAR(arg);
53315333
return *arg;
53325334
}
53335335

@@ -5345,7 +5347,7 @@ check_cedit(void)
53455347
cedit_key = -1;
53465348
else
53475349
{
5348-
n = string_to_key(p_cedit);
5350+
n = string_to_key(p_cedit, FALSE);
53495351
if (vim_isprintc(n))
53505352
return e_invarg;
53515353
cedit_key = n;
@@ -7462,6 +7464,12 @@ did_set_string_option(
74627464
#endif
74637465

74647466
#ifdef FEAT_TERMINAL
7467+
/* 'termkey' */
7468+
else if (varp == &curwin->w_p_tms)
7469+
{
7470+
if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7471+
errmsg = e_invarg;
7472+
}
74657473
/* 'termsize' */
74667474
else if (varp == &curwin->w_p_tms)
74677475
{

src/proto/option.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void set_helplang_default(char_u *lang);
99
void init_gui_options(void);
1010
void set_title_defaults(void);
1111
int do_set(char_u *arg, int opt_flags);
12+
int string_to_key(char_u *arg, int multi_byte);
1213
void set_options_bin(int oldval, int newval, int opt_flags);
1314
int get_viminfo_parameter(int type);
1415
char_u *find_viminfo_parameter(int type);

src/terminal.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
* - implement term_scrape(buf, row) inspect terminal screen
6161
* - implement term_open(command, options) open terminal window
6262
* - implement term_getjob(buf)
63-
* - implement 'termkey'
6463
* - when 'encoding' is not utf-8, or the job is using another encoding, setup
6564
* conversions.
65+
* - In the GUI use a terminal emulator for :!cmd.
6666
*/
6767

6868
#include "vim.h"
@@ -445,6 +445,10 @@ terminal_loop(void)
445445
size_t len;
446446
static int mouse_was_outside = FALSE;
447447
int dragging_outside = FALSE;
448+
int termkey = 0;
449+
450+
if (*curwin->w_p_tk != NUL)
451+
termkey = string_to_key(curwin->w_p_tk, TRUE);
448452

449453
for (;;)
450454
{
@@ -459,10 +463,15 @@ terminal_loop(void)
459463
--no_mapping;
460464
--allow_keys;
461465

466+
if (c == (termkey == 0 ? Ctrl_W : termkey))
467+
{
468+
stuffcharReadbuff(Ctrl_W);
469+
return;
470+
}
471+
462472
/* Catch keys that need to be handled as in Normal mode. */
463473
switch (c)
464474
{
465-
case Ctrl_W:
466475
case NUL:
467476
case K_ZERO:
468477
stuffcharReadbuff(c);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
764,
772774
/**/
773775
763,
774776
/**/

0 commit comments

Comments
 (0)