Skip to content

Commit 68cde01

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents a787335 + 8a77306 commit 68cde01

12 files changed

Lines changed: 208 additions & 95 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 19
1+
*terminal.txt* For Vim version 8.0. Last change: 2017 Jul 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -47,8 +47,9 @@ See option 'termsize' for controlling the size of the terminal window.
4747
(TODO: scrolling when the terminal is larger than the window)
4848

4949
Syntax ~
50-
*:ter* *:terminal*
51-
:terminal[!] [command] Open a new terminal window.
50+
51+
:ter[minal][!] [command] *:ter* *:terminal*
52+
Open a new terminal window.
5253

5354
If [command] is provided run it as a job and connect
5455
the input and output to the terminal.
@@ -79,7 +80,7 @@ The size of the terminal can be in one of three modes:
7980
The minimal size is 2 screen lines with 10 cells.
8081

8182
2. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
82-
screen rows and "cols" is the minial number of cells.
83+
screen rows and "cols" is the minimal number of cells.
8384

8485
3. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
8586
The terminal size is fixed to the specified number of screen lines and
@@ -101,9 +102,20 @@ can even run Vim in the terminal! That's used for debugging, see below.
101102

102103
MS-Windows ~
103104

104-
On MS-Windows a hidden console is used to run the command in. This should
105-
work well for all kind of commands. Obviously, they must be commands that run
106-
in a terminal, not open their own window.
105+
On MS-Windows winpty is used to make it possible to run all kind of commands.
106+
Obviously, they must be commands that run in a terminal, not open their own
107+
window.
108+
109+
You need the following two files from winpty:
110+
111+
winpty.dll
112+
winpty-agent.exe
113+
114+
You can download them from the following page:
115+
116+
https://github.com/rprichard/winpty
117+
118+
Just put the files somewhere in your PATH.
107119

108120
==============================================================================
109121
2. Remote testing *terminal-testing*

src/INSTALLpc.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -706,20 +706,17 @@ Or when using MinGW (as one line):
706706
13. Building with Terminal support
707707
==================================
708708

709-
Vim with Terminal support can be built with either MSVC, or MinGW or Cygwin.
709+
Vim with Terminal support can be built with either MSVC, MinGW or Cygwin.
710710
This uses the included libvterm and winpty. No extra header files or
711-
libraries are needed for building.
711+
libraries are needed for building. Just set TERMINAL to yes.
712712

713-
Running Vim with terminal support requires the following two winpty files:
713+
E.g. When using MSVC:
714714

715-
winpty.dll
716-
winpty-agent.dll
715+
nmake -f Make_mvc.mak TERMINAL=yes
717716

718-
You can download them from the following page:
719-
720-
https://github.com/rprichard/winpty
717+
Or when using MinGW (as one line):
721718

722-
Just put the DLL files somewhere in your PATH.
719+
mingw32-make -f Make_mingw.mak TERMINAL=yes
723720

724721

725722
14. Windows 3.1x

src/Make_cyg_ming.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ CHANNEL=yes
7373
else
7474
CHANNEL=$(GUI)
7575
endif
76+
# Set to yes to enable terminal support.
7677
TERMINAL=no
7778

7879

src/Make_mvc.mak

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ CSCOPE_DEFS = -DFEAT_CSCOPE
356356
!if "$(TERMINAL)" == "yes"
357357
TERMINAL_OBJ = $(OBJDIR)/terminal.obj
358358
TERMINAL_DEFS = -DFEAT_TERMINAL
359+
!if $(MSVC_MAJOR) <= 11
360+
TERMINAL_DEFS = $(TERMINAL_DEFS) /I if_perl_msvc
361+
!endif
359362
TERMINAL_SRC = terminal.c
360363
VTERM_LIB = libvterm/vterm.lib
361364
!endif
@@ -1154,7 +1157,7 @@ all: $(VIM).exe \
11541157

11551158
$(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
11561159
$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
1157-
$(CSCOPE_OBJ) $(TERMINAL_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) \
1160+
$(CSCOPE_OBJ) $(TERMINAL_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) $(VTERM_LIB) \
11581161
version.c version.h
11591162
$(CC) $(CFLAGS) version.c
11601163
$(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) \
@@ -1549,7 +1552,7 @@ proto.h: \
15491552

15501553
libvterm/vterm.lib :
15511554
cd libvterm
1552-
$(MAKE) /NOLOGO -f Makefile.msc
1555+
$(MAKE) /NOLOGO -f Makefile.msc "MSVC_MAJOR=$(MSVC_MAJOR)"
15531556
cd ..
15541557

15551558
# vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0:

src/buffer.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,27 +3634,41 @@ maketitle(void)
36343634
#define SPACE_FOR_ARGNR (IOSIZE - 10) /* at least room for " - VIM" */
36353635
if (curbuf->b_fname == NULL)
36363636
vim_strncpy(buf, (char_u *)_("[No Name]"), SPACE_FOR_FNAME);
3637+
#ifdef FEAT_TERMINAL
3638+
else if (curbuf->b_term != NULL)
3639+
{
3640+
vim_strncpy(buf, term_get_status_text(curbuf->b_term),
3641+
SPACE_FOR_FNAME);
3642+
}
3643+
#endif
36373644
else
36383645
{
36393646
p = transstr(gettail(curbuf->b_fname));
36403647
vim_strncpy(buf, p, SPACE_FOR_FNAME);
36413648
vim_free(p);
36423649
}
36433650

3644-
switch (bufIsChanged(curbuf)
3645-
+ (curbuf->b_p_ro * 2)
3646-
+ (!curbuf->b_p_ma * 4))
3647-
{
3648-
case 1: STRCAT(buf, " +"); break;
3649-
case 2: STRCAT(buf, " ="); break;
3650-
case 3: STRCAT(buf, " =+"); break;
3651-
case 4:
3652-
case 6: STRCAT(buf, " -"); break;
3653-
case 5:
3654-
case 7: STRCAT(buf, " -+"); break;
3655-
}
3651+
#ifdef FEAT_TERMINAL
3652+
if (curbuf->b_term == NULL)
3653+
#endif
3654+
switch (bufIsChanged(curbuf)
3655+
+ (curbuf->b_p_ro * 2)
3656+
+ (!curbuf->b_p_ma * 4))
3657+
{
3658+
case 1: STRCAT(buf, " +"); break;
3659+
case 2: STRCAT(buf, " ="); break;
3660+
case 3: STRCAT(buf, " =+"); break;
3661+
case 4:
3662+
case 6: STRCAT(buf, " -"); break;
3663+
case 5:
3664+
case 7: STRCAT(buf, " -+"); break;
3665+
}
36563666

3657-
if (curbuf->b_fname != NULL)
3667+
if (curbuf->b_fname != NULL
3668+
#ifdef FEAT_TERMINAL
3669+
&& curbuf->b_term == NULL
3670+
#endif
3671+
)
36583672
{
36593673
/* Get path of file, replace home dir with ~ */
36603674
off = (int)STRLEN(buf);
@@ -3671,18 +3685,8 @@ maketitle(void)
36713685
p = gettail_sep(buf + off);
36723686
if (p == buf + off)
36733687
{
3674-
char *txt;
3675-
3676-
#ifdef FEAT_TERMINAL
3677-
if (curbuf->b_term != NULL)
3678-
txt = term_job_running(curbuf)
3679-
? _("running") : _("finished");
3680-
else
3681-
#endif
3682-
txt = _("help");
3683-
3684-
/* must be a help or terminal buffer */
3685-
vim_strncpy(buf + off, (char_u *)txt,
3688+
/* must be a help buffer */
3689+
vim_strncpy(buf + off, (char_u *)_("help"),
36863690
(size_t)(SPACE_FOR_DIR - off - 1));
36873691
}
36883692
else
@@ -5680,16 +5684,20 @@ buf_spname(buf_T *buf)
56805684
return (char_u *)_(msg_qflist);
56815685
}
56825686
#endif
5683-
#ifdef FEAT_QUICKFIX
5687+
56845688
/* There is no _file_ when 'buftype' is "nofile", b_sfname
5685-
* contains the name as specified by the user */
5689+
* contains the name as specified by the user. */
56865690
if (bt_nofile(buf))
56875691
{
5692+
#ifdef FEAT_TERMINAL
5693+
if (buf->b_term != NULL)
5694+
return term_get_status_text(buf->b_term);
5695+
#endif
56885696
if (buf->b_sfname != NULL)
56895697
return buf->b_sfname;
56905698
return (char_u *)_("[Scratch]");
56915699
}
5692-
#endif
5700+
56935701
if (buf->b_fname == NULL)
56945702
return (char_u *)_("[No Name]");
56955703
return NULL;

src/gui_x11.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,8 +2270,6 @@ fontset_ascent(XFontSet fs)
22702270
gui_mch_get_color(char_u *name)
22712271
{
22722272
guicolor_T requested;
2273-
XColor available;
2274-
Colormap colormap;
22752273

22762274
/* can't do this when GUI not running */
22772275
if (!gui.in_use || name == NULL || *name == NUL)
@@ -2295,6 +2293,8 @@ gui_mch_get_color(char_u *name)
22952293
gui_mch_get_rgb_color(int r, int g, int b)
22962294
{
22972295
char spec[8]; /* space enough to hold "#RRGGBB" */
2296+
XColor available;
2297+
Colormap colormap;
22982298

22992299
vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b);
23002300
colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));

src/libvterm/Makefile.msc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
CFLAGS = /DINLINE= /Iinclude
2+
13
OBJS = \
24
src\encoding.c \
35
src\keyboard.c \
@@ -24,7 +26,10 @@ all : vterm.lib
2426

2527

2628
.c.obj :
27-
cl /DINLINE= /Iinclude /Fo$@ /c $<
29+
cl $(CFLAGS) /Fo$@ /c $<
2830

2931
vterm.lib : $(OBJS)
3032
lib /OUT:$@ $(OBJS)
33+
34+
clean:
35+
del $(OBJS) vterm.lib

src/libvterm/bin/vterm-ctrl.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#define _XOPEN_SOURCE 500 /* strdup */
22

3-
#include <stdbool.h>
43
#include <stdio.h>
54
#include <stdlib.h>
65
#include <string.h>
76
#define streq(a,b) (strcmp(a,b)==0)
7+
#define TRUE 1
8+
#define FALSE 0
89

910
#include <termios.h>
1011

@@ -60,13 +61,14 @@ static char *helptext[] = {
6061
NULL
6162
};
6263

63-
static bool seticanon(bool icanon, bool echo)
64+
static int seticanon(int icanon, int echo)
6465
{
6566
struct termios termios;
67+
int ret;
6668

6769
tcgetattr(0, &termios);
6870

69-
bool ret = (termios.c_lflag & ICANON);
71+
ret = (termios.c_lflag & ICANON);
7072

7173
if(icanon) termios.c_lflag |= ICANON;
7274
else termios.c_lflag &= ~ICANON;
@@ -84,16 +86,16 @@ static void await_c1(int c1)
8486
int c;
8587

8688
/* await CSI - 8bit or 2byte 7bit form */
87-
bool in_esc = false;
89+
int in_esc = FALSE;
8890
while((c = getchar())) {
8991
if(c == c1)
9092
break;
9193
if(in_esc && c == (char)(c1 - 0x40))
9294
break;
9395
if(!in_esc && c == 0x1b)
94-
in_esc = true;
96+
in_esc = TRUE;
9597
else
96-
in_esc = false;
98+
in_esc = FALSE;
9799
}
98100
}
99101

@@ -121,7 +123,7 @@ static char *read_csi()
121123
static char *read_dcs()
122124
{
123125
unsigned char dcs[32];
124-
bool in_esc = false;
126+
int in_esc = FALSE;
125127
int i;
126128

127129
await_c1(0x90);
@@ -133,10 +135,10 @@ static char *read_dcs()
133135
if(in_esc && c == 0x5c)
134136
break;
135137
if(!in_esc && c == 0x1b)
136-
in_esc = true;
138+
in_esc = TRUE;
137139
else {
138140
dcs[i++] = c;
139-
in_esc = false;
141+
in_esc = FALSE;
140142
}
141143
}
142144
dcs[++i] = 0;
@@ -158,7 +160,7 @@ static void usage(int exitcode)
158160
exit(exitcode);
159161
}
160162

161-
static bool query_dec_mode(int mode)
163+
static int query_dec_mode(int mode)
162164
{
163165
char *s = NULL;
164166

@@ -189,12 +191,12 @@ static bool query_dec_mode(int mode)
189191
free(s);
190192

191193
if(reply_value == 1 || reply_value == 3)
192-
return true;
194+
return TRUE;
193195
if(reply_value == 2 || reply_value == 4)
194-
return false;
196+
return FALSE;
195197

196198
printf("Unrecognised reply to DECRQM: %d\n", reply_value);
197-
return false;
199+
return FALSE;
198200
} while(1);
199201
}
200202

@@ -247,11 +249,11 @@ static int query_rqss_numeric(char *cmd)
247249
} while(1);
248250
}
249251

250-
bool wasicanon;
252+
int wasicanon;
251253

252254
void restoreicanon(void)
253255
{
254-
seticanon(wasicanon, true);
256+
seticanon(wasicanon, TRUE);
255257
}
256258

257259
int main(int argc, char *argv[])
@@ -261,7 +263,7 @@ int main(int argc, char *argv[])
261263
if(argc == 1)
262264
usage(0);
263265

264-
wasicanon = seticanon(false, false);
266+
wasicanon = seticanon(FALSE, FALSE);
265267
atexit(restoreicanon);
266268

267269
while(argi < argc) {

src/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7602,7 +7602,7 @@ did_set_string_option(
76027602

76037603
#ifdef FEAT_TERMINAL
76047604
/* 'termkey' */
7605-
else if (varp == &curwin->w_p_tms)
7605+
else if (varp == &curwin->w_p_tk)
76067606
{
76077607
if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
76087608
errmsg = e_invarg;

src/proto/terminal.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ void free_terminal(term_T *term);
44
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
55
void terminal_loop(void);
66
void term_job_ended(job_T *job);
7-
int term_job_running(buf_T *buf);
87
void term_update_window(win_T *wp);
8+
char_u *term_get_status_text(term_T *term);
99
/* vim: set ft=c : */

0 commit comments

Comments
 (0)