mirror of
https://github.com/vim/vim.git
synced 2025-10-05 05:34:07 -04:00
patch 8.0.1616: Win32: shell commands in the GUI open a new console
Problem: Win32: shell commands in the GUI open a new console. Solution: Use a terminal window for interactive use when 'guioptions' contains "!".
This commit is contained in:
@@ -4488,7 +4488,7 @@ mch_system_piped(char *cmd, int options)
|
|||||||
int c;
|
int c;
|
||||||
int noread_cnt = 0;
|
int noread_cnt = 0;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
int delay = 1;
|
int delay = 1;
|
||||||
DWORD buffer_off = 0; /* valid bytes in buffer[] */
|
DWORD buffer_off = 0; /* valid bytes in buffer[] */
|
||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
|
|
||||||
@@ -4782,6 +4782,69 @@ mch_system(char *cmd, int options)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEAT_GUI) && defined(FEAT_TERMINAL)
|
||||||
|
/*
|
||||||
|
* Use a terminal window to run a shell command in.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
mch_call_shell_terminal(
|
||||||
|
char_u *cmd,
|
||||||
|
int options UNUSED) /* SHELL_*, see vim.h */
|
||||||
|
{
|
||||||
|
jobopt_T opt;
|
||||||
|
char_u *newcmd = NULL;
|
||||||
|
typval_T argvar[2];
|
||||||
|
long_u cmdlen;
|
||||||
|
int retval = -1;
|
||||||
|
buf_T *buf;
|
||||||
|
aco_save_T aco;
|
||||||
|
oparg_T oa; /* operator arguments */
|
||||||
|
|
||||||
|
cmdlen = STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10;
|
||||||
|
|
||||||
|
newcmd = lalloc(cmdlen, TRUE);
|
||||||
|
if (newcmd == NULL)
|
||||||
|
return 255;
|
||||||
|
vim_snprintf((char *)newcmd, cmdlen, "%s %s %s", p_sh, p_shcf, cmd);
|
||||||
|
|
||||||
|
init_job_options(&opt);
|
||||||
|
ch_log(NULL, "starting terminal for system command '%s'", cmd);
|
||||||
|
|
||||||
|
argvar[0].v_type = VAR_STRING;
|
||||||
|
argvar[0].vval.v_string = newcmd;
|
||||||
|
argvar[1].v_type = VAR_UNKNOWN;
|
||||||
|
buf = term_start(argvar, NULL, &opt, TERM_START_SYSTEM);
|
||||||
|
|
||||||
|
/* Find a window to make "buf" curbuf. */
|
||||||
|
aucmd_prepbuf(&aco, buf);
|
||||||
|
|
||||||
|
clear_oparg(&oa);
|
||||||
|
while (term_use_loop())
|
||||||
|
{
|
||||||
|
if (oa.op_type == OP_NOP && oa.regname == NUL && !VIsual_active)
|
||||||
|
{
|
||||||
|
/* If terminal_loop() returns OK we got a key that is handled
|
||||||
|
* in Normal model. We don't do redrawing anyway. */
|
||||||
|
if (terminal_loop(TRUE) == OK)
|
||||||
|
normal_cmd(&oa, TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
normal_cmd(&oa, TRUE);
|
||||||
|
}
|
||||||
|
retval = 0;
|
||||||
|
ch_log(NULL, "system command finished");
|
||||||
|
|
||||||
|
/* restore curwin/curbuf and a few other things */
|
||||||
|
aucmd_restbuf(&aco);
|
||||||
|
|
||||||
|
wait_return(TRUE);
|
||||||
|
do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE);
|
||||||
|
|
||||||
|
vim_free(newcmd);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Either execute a command by calling the shell or start a new shell
|
* Either execute a command by calling the shell or start a new shell
|
||||||
*/
|
*/
|
||||||
@@ -4851,6 +4914,19 @@ mch_call_shell(
|
|||||||
fflush(fdDump);
|
fflush(fdDump);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(FEAT_GUI) && defined(FEAT_TERMINAL)
|
||||||
|
/* TODO: make the terminal window work with input or output redirected. */
|
||||||
|
if (vim_strchr(p_go, GO_TERMINAL) != NULL
|
||||||
|
&& (options & (SHELL_FILTER|SHELL_DOOUT|SHELL_WRITE|SHELL_READ)) == 0)
|
||||||
|
{
|
||||||
|
/* Use a terminal window to run the command in. */
|
||||||
|
x = mch_call_shell_terminal(cmd, options);
|
||||||
|
#ifdef FEAT_TITLE
|
||||||
|
resettitle();
|
||||||
|
#endif
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Catch all deadly signals while running the external command, because a
|
* Catch all deadly signals while running the external command, because a
|
||||||
|
@@ -766,6 +766,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 */
|
||||||
|
/**/
|
||||||
|
1616,
|
||||||
/**/
|
/**/
|
||||||
1615,
|
1615,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user