forked from aniani/vim
patch 8.1.0049: shell cannot tell running in a terminal window
Problem: Shell cannot tell running in a terminal window. Solution: Add the VIM_TERMINAL environment variable. (Christian Brabandt)
This commit is contained in:
@@ -376,6 +376,7 @@ Environment variables are used to pass information to the running job:
|
|||||||
COLUMNS number of columns in the terminal initially
|
COLUMNS number of columns in the terminal initially
|
||||||
COLORS number of colors, 't_Co' (256*256*256 in the GUI)
|
COLORS number of colors, 't_Co' (256*256*256 in the GUI)
|
||||||
VIM_SERVERNAME v:servername
|
VIM_SERVERNAME v:servername
|
||||||
|
VIM_TERMINAL v:version
|
||||||
|
|
||||||
|
|
||||||
MS-Windows ~
|
MS-Windows ~
|
||||||
|
@@ -4169,6 +4169,7 @@ set_child_environment(long rows, long columns, char *term)
|
|||||||
static char envbuf_Lines[20];
|
static char envbuf_Lines[20];
|
||||||
static char envbuf_Columns[20];
|
static char envbuf_Columns[20];
|
||||||
static char envbuf_Colors[20];
|
static char envbuf_Colors[20];
|
||||||
|
static char envbuf_Version[20];
|
||||||
# ifdef FEAT_CLIENTSERVER
|
# ifdef FEAT_CLIENTSERVER
|
||||||
static char envbuf_Servername[60];
|
static char envbuf_Servername[60];
|
||||||
# endif
|
# endif
|
||||||
@@ -4189,6 +4190,8 @@ set_child_environment(long rows, long columns, char *term)
|
|||||||
setenv("COLUMNS", (char *)envbuf, 1);
|
setenv("COLUMNS", (char *)envbuf, 1);
|
||||||
sprintf((char *)envbuf, "%ld", colors);
|
sprintf((char *)envbuf, "%ld", colors);
|
||||||
setenv("COLORS", (char *)envbuf, 1);
|
setenv("COLORS", (char *)envbuf, 1);
|
||||||
|
sprintf((char *)envbuf, "%ld", get_vim_var_nr(VV_VERSION));
|
||||||
|
setenv("VIM_TERMINAL", (char *)envbuf, 1);
|
||||||
# ifdef FEAT_CLIENTSERVER
|
# ifdef FEAT_CLIENTSERVER
|
||||||
setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
|
setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1);
|
||||||
# endif
|
# endif
|
||||||
@@ -4209,6 +4212,9 @@ set_child_environment(long rows, long columns, char *term)
|
|||||||
putenv(envbuf_Columns);
|
putenv(envbuf_Columns);
|
||||||
vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
|
vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors);
|
||||||
putenv(envbuf_Colors);
|
putenv(envbuf_Colors);
|
||||||
|
vim_snprintf(envbuf_Version, sizeof(envbuf_Version), "VIM_TERMINAL=%ld",
|
||||||
|
get_vim_var_nr(VV_VERSION));
|
||||||
|
putenv(envbuf_Version);
|
||||||
# ifdef FEAT_CLIENTSERVER
|
# ifdef FEAT_CLIENTSERVER
|
||||||
vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
|
vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername),
|
||||||
"VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
|
"VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName);
|
||||||
|
@@ -5275,25 +5275,43 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef FEAT_CLIENTSERVER
|
|
||||||
if (is_terminal)
|
if (is_terminal)
|
||||||
{
|
{
|
||||||
|
# ifdef FEAT_CLIENTSERVER
|
||||||
char_u *servername = get_vim_var_str(VV_SEND_SERVER);
|
char_u *servername = get_vim_var_str(VV_SEND_SERVER);
|
||||||
size_t lval = STRLEN(servername);
|
size_t servername_len = STRLEN(servername);
|
||||||
size_t n;
|
# endif
|
||||||
|
char_u *version = get_vim_var_str(VV_VERSION);
|
||||||
|
size_t version_len = STRLEN(version);
|
||||||
|
// size of "VIM_SERVERNAME=" and value,
|
||||||
|
// plus "VIM_TERMINAL=" and value,
|
||||||
|
// plus two terminating NULs
|
||||||
|
size_t n = 0
|
||||||
|
# ifdef FEAT_CLIENTSERVER
|
||||||
|
+ 15 + servername_len
|
||||||
|
# endif
|
||||||
|
+ 13 + version_len + 2;
|
||||||
|
|
||||||
if (ga_grow(gap, (int)(14 + lval + 2)) == OK)
|
if (ga_grow(gap, (int)n) == OK)
|
||||||
{
|
{
|
||||||
|
# ifdef FEAT_CLIENTSERVER
|
||||||
for (n = 0; n < 15; n++)
|
for (n = 0; n < 15; n++)
|
||||||
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
||||||
(WCHAR)"VIM_SERVERNAME="[n];
|
(WCHAR)"VIM_SERVERNAME="[n];
|
||||||
for (n = 0; n < lval; n++)
|
for (n = 0; n < servername_len; n++)
|
||||||
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
||||||
(WCHAR)servername[n];
|
(WCHAR)servername[n];
|
||||||
*((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
|
*((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
|
||||||
|
# endif
|
||||||
|
for (n = 0; n < 13; n++)
|
||||||
|
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
||||||
|
(WCHAR)"VIM_TERMINAL="[n];
|
||||||
|
for (n = 0; n < version_len; n++)
|
||||||
|
*((WCHAR*)gap->ga_data + gap->ga_len++) =
|
||||||
|
(WCHAR)version[n];
|
||||||
|
*((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -482,18 +482,25 @@ func Test_terminal_servername()
|
|||||||
if !has('clientserver')
|
if !has('clientserver')
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
call s:test_environment("VIM_SERVERNAME", v:servername)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_terminal_version()
|
||||||
|
call s:test_environment("VIM_TERMINAL", string(v:version))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func s:test_environment(name, value)
|
||||||
let buf = Run_shell_in_terminal({})
|
let buf = Run_shell_in_terminal({})
|
||||||
" Wait for the shell to display a prompt
|
" Wait for the shell to display a prompt
|
||||||
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
|
||||||
if has('win32')
|
if has('win32')
|
||||||
call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
|
call term_sendkeys(buf, "echo %" . a:name . "%\r")
|
||||||
else
|
else
|
||||||
call term_sendkeys(buf, "echo $VIM_SERVERNAME\r")
|
call term_sendkeys(buf, "echo $" . a:name . "\r")
|
||||||
endif
|
endif
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call Stop_shell_in_terminal(buf)
|
call Stop_shell_in_terminal(buf)
|
||||||
call WaitFor('getline(2) == v:servername')
|
call WaitForAssert({-> assert_equal(a:value, getline(2))})
|
||||||
call assert_equal(v:servername, getline(2))
|
|
||||||
|
|
||||||
exe buf . 'bwipe'
|
exe buf . 'bwipe'
|
||||||
unlet buf
|
unlet buf
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
49,
|
||||||
/**/
|
/**/
|
||||||
48,
|
48,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user