Skip to content

Commit 5130947

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 43d09fb + 3f9a1ff commit 5130947

12 files changed

Lines changed: 330 additions & 135 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 12
1+
*terminal.txt* For Vim version 8.0. Last change: 2017 Aug 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -102,10 +102,9 @@ Syntax ~
102102
parentheses. E.g. if "gdb" exists the second terminal
103103
buffer will use "!gdb (1)".
104104

105-
If [range] is given it is used for the terminal size.
106-
One number specifies the number of rows. Unless the
107-
"vertical" modifier is used, then it is the number of
108-
columns.
105+
If [range] is given the specified lines are used as
106+
input for the job. It will not be possible to type
107+
keys in the terminal window.
109108

110109
Two comma separated numbers are used as "rows,cols".
111110
E.g. `:24,80gdb` opens a terminal with 24 rows and 80
@@ -125,6 +124,10 @@ Syntax ~
125124
cannot be |abandon|ed.
126125
++hidden Open the terminal in a hidden buffer,
127126
no window will be used.
127+
++rows={height} Use {height} for the terminal window
128+
height.
129+
++cols={width} Use {width} for the terminal window
130+
width.
128131

129132
If you want to use more options use the |term_start()|
130133
function.

src/ex_cmds.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,8 +1490,8 @@ EX(CMD_tearoff, "tearoff", ex_tearoff,
14901490
NEEDARG|EXTRA|TRLBAR|NOTRLCOM|CMDWIN,
14911491
ADDR_LINES),
14921492
EX(CMD_terminal, "terminal", ex_terminal,
1493-
RANGE|NOTADR|BANG|FILES|TRLBAR|CMDWIN,
1494-
ADDR_OTHER),
1493+
RANGE|BANG|FILES|TRLBAR|CMDWIN,
1494+
ADDR_LINES),
14951495
EX(CMD_tfirst, "tfirst", ex_tag,
14961496
RANGE|NOTADR|BANG|TRLBAR|ZEROR,
14971497
ADDR_LINES),

src/ex_cmds2.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,9 +2051,7 @@ dialog_changed(
20512051
else
20522052
{
20532053
#endif
2054-
dialog_msg(buff, _("Save changes to \"%s\"?"),
2055-
(buf->b_fname != NULL) ?
2056-
buf->b_fname : (char_u *)_("Untitled"));
2054+
dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname);
20572055
if (checkall)
20582056
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
20592057
else

src/option.c

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,6 +3254,8 @@ static struct vimoption options[] =
32543254
p_term("t_AL", T_CAL)
32553255
p_term("t_al", T_AL)
32563256
p_term("t_bc", T_BC)
3257+
p_term("t_BE", T_BE)
3258+
p_term("t_BD", T_BD)
32573259
p_term("t_cd", T_CD)
32583260
p_term("t_ce", T_CE)
32593261
p_term("t_cl", T_CL)
@@ -3270,13 +3272,11 @@ static struct vimoption options[] =
32703272
p_term("t_db", T_DB)
32713273
p_term("t_DL", T_CDL)
32723274
p_term("t_dl", T_DL)
3275+
p_term("t_EC", T_CEC)
32733276
p_term("t_EI", T_CEI)
32743277
p_term("t_fs", T_FS)
3278+
p_term("t_GP", T_CGP)
32753279
p_term("t_IE", T_CIE)
3276-
p_term("t_SC", T_CSC)
3277-
p_term("t_EC", T_CEC)
3278-
p_term("t_SH", T_CSH)
3279-
p_term("t_RS", T_CRS)
32803280
p_term("t_IS", T_CIS)
32813281
p_term("t_ke", T_KE)
32823282
p_term("t_ks", T_KS)
@@ -3290,10 +3290,13 @@ static struct vimoption options[] =
32903290
p_term("t_op", T_OP)
32913291
p_term("t_RB", T_RBG)
32923292
p_term("t_RI", T_CRI)
3293+
p_term("t_RS", T_CRS)
32933294
p_term("t_RV", T_CRV)
32943295
p_term("t_Sb", T_CSB)
3296+
p_term("t_SC", T_CSC)
32953297
p_term("t_se", T_SE)
32963298
p_term("t_Sf", T_CSF)
3299+
p_term("t_SH", T_CSH)
32973300
p_term("t_SI", T_CSI)
32983301
p_term("t_so", T_SO)
32993302
p_term("t_SR", T_CSR)
@@ -3308,18 +3311,16 @@ static struct vimoption options[] =
33083311
p_term("t_vb", T_VB)
33093312
p_term("t_ve", T_VE)
33103313
p_term("t_vi", T_VI)
3314+
p_term("t_VS", T_CVS)
33113315
p_term("t_vs", T_VS)
33123316
p_term("t_WP", T_CWP)
3313-
p_term("t_GP", T_CGP)
33143317
p_term("t_WS", T_CWS)
33153318
p_term("t_xn", T_XN)
33163319
p_term("t_xs", T_XS)
33173320
p_term("t_ZH", T_CZH)
33183321
p_term("t_ZR", T_CZR)
33193322
p_term("t_8f", T_8F)
33203323
p_term("t_8b", T_8B)
3321-
p_term("t_BE", T_BE)
3322-
p_term("t_BD", T_BD)
33233324

33243325
/* terminal key codes are not in here */
33253326

@@ -4468,8 +4469,6 @@ trigger_optionsset_string(
44684469
(char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
44694470
reset_v_option_vars();
44704471
}
4471-
vim_free(oldval);
4472-
vim_free(newval);
44734472
}
44744473
#endif
44754474

@@ -4935,19 +4934,19 @@ do_set(
49354934
}
49364935
else if (opt_idx >= 0) /* string */
49374936
{
4938-
char_u *save_arg = NULL;
4939-
char_u *s = NULL;
4940-
char_u *oldval = NULL; /* previous value if *varp */
4941-
char_u *newval;
4942-
char_u *origval = NULL;
4937+
char_u *save_arg = NULL;
4938+
char_u *s = NULL;
4939+
char_u *oldval = NULL; /* previous value if *varp */
4940+
char_u *newval;
4941+
char_u *origval = NULL;
49434942
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4944-
char_u *saved_origval = NULL;
4945-
char_u *saved_newval = NULL;
4943+
char_u *saved_origval = NULL;
4944+
char_u *saved_newval = NULL;
49464945
#endif
4947-
unsigned newlen;
4948-
int comma;
4949-
int bs;
4950-
int new_value_alloced; /* new string option
4946+
unsigned newlen;
4947+
int comma;
4948+
int bs;
4949+
int new_value_alloced; /* new string option
49514950
was allocated */
49524951

49534952
/* When using ":set opt=val" for a global option
@@ -4960,6 +4959,16 @@ do_set(
49604959
/* The old value is kept until we are sure that the
49614960
* new value is valid. */
49624961
oldval = *(char_u **)varp;
4962+
4963+
/* When setting the local value of a global
4964+
* option, the old value may be the global value. */
4965+
if (((int)options[opt_idx].indir & PV_BOTH)
4966+
&& (opt_flags & OPT_LOCAL))
4967+
origval = *(char_u **)get_varp(
4968+
&options[opt_idx]);
4969+
else
4970+
origval = oldval;
4971+
49634972
if (nextchar == '&') /* set to default val */
49644973
{
49654974
newval = options[opt_idx].def_val[
@@ -5036,6 +5045,8 @@ do_set(
50365045
break;
50375046
}
50385047
vim_free(oldval);
5048+
if (origval == oldval)
5049+
origval = *(char_u **)varp;
50395050
oldval = *(char_u **)varp;
50405051
}
50415052
/*
@@ -5074,15 +5085,6 @@ do_set(
50745085
++arg;
50755086
}
50765087

5077-
/* When setting the local value of a global
5078-
* option, the old value may be the global value. */
5079-
if (((int)options[opt_idx].indir & PV_BOTH)
5080-
&& (opt_flags & OPT_LOCAL))
5081-
origval = *(char_u **)get_varp(
5082-
&options[opt_idx]);
5083-
else
5084-
origval = oldval;
5085-
50865088
/*
50875089
* Copy the new string into allocated memory.
50885090
* Can't use set_string_option_direct(), because
@@ -5286,7 +5288,9 @@ do_set(
52865288
new_value_alloced = TRUE;
52875289
}
52885290

5289-
/* Set the new value. */
5291+
/*
5292+
* Set the new value.
5293+
*/
52905294
*(char_u **)(varp) = newval;
52915295

52925296
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
@@ -5312,19 +5316,16 @@ do_set(
53125316
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
53135317
new_value_alloced, oldval, errbuf, opt_flags);
53145318

5315-
/* If error detected, print the error message. */
5316-
if (errmsg != NULL)
5317-
{
53185319
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5319-
vim_free(saved_origval);
5320-
vim_free(saved_newval);
5321-
#endif
5322-
goto skip;
5323-
}
5324-
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5325-
trigger_optionsset_string(opt_idx, opt_flags,
5320+
if (errmsg == NULL)
5321+
trigger_optionsset_string(opt_idx, opt_flags,
53265322
saved_origval, saved_newval);
5323+
vim_free(saved_origval);
5324+
vim_free(saved_newval);
53275325
#endif
5326+
/* If error detected, print the error message. */
5327+
if (errmsg != NULL)
5328+
goto skip;
53285329
}
53295330
else /* key code option */
53305331
{
@@ -6135,8 +6136,11 @@ set_string_option(
61356136

61366137
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
61376138
/* call autocommand after handling side effects */
6138-
trigger_optionsset_string(opt_idx, opt_flags,
6139+
if (r == NULL)
6140+
trigger_optionsset_string(opt_idx, opt_flags,
61396141
saved_oldval, saved_newval);
6142+
vim_free(saved_oldval);
6143+
vim_free(saved_newval);
61406144
#endif
61416145
}
61426146
return r;

src/os_unix.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,6 +4352,7 @@ mch_call_shell(
43524352

43534353
# define EXEC_FAILED 122 /* Exit code when shell didn't execute. Don't use
43544354
127, some shells use that already */
4355+
# define OPEN_NULL_FAILED 123 /* Exit code if /dev/null can't be opened */
43554356

43564357
char_u *newcmd;
43574358
pid_t pid;
@@ -5260,6 +5261,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
52605261
int use_file_for_in = options->jo_io[PART_IN] == JIO_FILE;
52615262
int use_file_for_out = options->jo_io[PART_OUT] == JIO_FILE;
52625263
int use_file_for_err = options->jo_io[PART_ERR] == JIO_FILE;
5264+
int use_buffer_for_in = options->jo_io[PART_IN] == JIO_BUFFER;
52635265
int use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT;
52645266
SIGSET_DECL(curset)
52655267

@@ -5269,7 +5271,10 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
52695271
/* default is to fail */
52705272
job->jv_status = JOB_FAILED;
52715273

5272-
if (options->jo_pty)
5274+
if (options->jo_pty
5275+
&& (!(use_file_for_in || use_null_for_in)
5276+
|| !(use_file_for_in || use_null_for_out)
5277+
|| !(use_out_for_err || use_file_for_err || use_null_for_err)))
52735278
open_pty(&pty_master_fd, &pty_slave_fd, &job->jv_tty_name);
52745279

52755280
/* TODO: without the channel feature connect the child to /dev/null? */
@@ -5285,8 +5290,12 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
52855290
goto failed;
52865291
}
52875292
}
5288-
else if (!use_null_for_in && pty_master_fd < 0 && pipe(fd_in) < 0)
5289-
goto failed;
5293+
else
5294+
/* When writing buffer lines to the input don't use the pty, so that
5295+
* the pipe can be closed when all lines were written. */
5296+
if (!use_null_for_in && (pty_master_fd < 0 || use_buffer_for_in)
5297+
&& pipe(fd_in) < 0)
5298+
goto failed;
52905299

52915300
if (use_file_for_out)
52925301
{
@@ -5383,7 +5392,14 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
53835392
}
53845393

53855394
if (use_null_for_in || use_null_for_out || use_null_for_err)
5395+
{
53865396
null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0);
5397+
if (null_fd < 0)
5398+
{
5399+
perror("opening /dev/null failed");
5400+
_exit(OPEN_NULL_FAILED);
5401+
}
5402+
}
53875403

53885404
if (pty_slave_fd >= 0)
53895405
{

src/proto/term.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void cursor_on(void);
5353
void cursor_off(void);
5454
void term_cursor_mode(int forced);
5555
void term_cursor_color(char_u *color);
56-
void term_cursor_blink(int blink);
5756
void term_cursor_shape(int shape, int blink);
5857
void scroll_region_set(win_T *wp, int off);
5958
void scroll_region_reset(void);

0 commit comments

Comments
 (0)