Skip to content

Commit 8a77306

Browse files
committed
patch 8.0.0769: build problems with terminal on MS-Windows
Problem: Build problems with terminal on MS-Windows using MSVC. Solution: Remove stdbool.h dependency. Only use ScreenLinesUC when it was allocated. Fix typos. (Ken Takata)
1 parent 2155441 commit 8a77306

8 files changed

Lines changed: 71 additions & 42 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/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/terminal.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* the terminal emulator.
2626
*
2727
* If the terminal window has keyboard focus, typed keys are converted to the
28-
* terminal encoding and writting to the job over a channel.
28+
* terminal encoding and writing to the job over a channel.
2929
*
3030
* If the job produces output, it is written to the terminal emulator. The
3131
* terminal emulator invokes callbacks when its screen content changes. The
@@ -731,7 +731,7 @@ color2index(VTermColor *color)
731731
else if (red == 128)
732732
{
733733
if (green == 128 && blue == 128)
734-
return 9; /* high intensity bladk */
734+
return 9; /* high intensity black */
735735
}
736736
else if (red == 255)
737737
{
@@ -894,7 +894,10 @@ term_update_window(win_T *wp)
894894
if (c == NUL)
895895
{
896896
ScreenLines[off] = ' ';
897-
ScreenLinesUC[off] = NUL;
897+
#if defined(FEAT_MBYTE)
898+
if (enc_utf8)
899+
ScreenLinesUC[off] = NUL;
900+
#endif
898901
}
899902
else
900903
{
@@ -907,7 +910,8 @@ term_update_window(win_T *wp)
907910
else
908911
{
909912
ScreenLines[off] = c;
910-
ScreenLinesUC[off] = NUL;
913+
if (enc_utf8)
914+
ScreenLinesUC[off] = NUL;
911915
}
912916
#else
913917
ScreenLines[off] = c;
@@ -920,7 +924,10 @@ term_update_window(win_T *wp)
920924
if (cell.width == 2)
921925
{
922926
ScreenLines[off] = NUL;
923-
ScreenLinesUC[off] = NUL;
927+
#if defined(FEAT_MBYTE)
928+
if (enc_utf8)
929+
ScreenLinesUC[off] = NUL;
930+
#endif
924931
++pos.col;
925932
++off;
926933
}
@@ -1025,9 +1032,9 @@ term_get_status_text(term_T *term)
10251032
#define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul
10261033
#define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull
10271034

1028-
void* (*winpty_config_new)(int, void*);
1035+
void* (*winpty_config_new)(UINT64, void*);
10291036
void* (*winpty_open)(void*, void*);
1030-
void* (*winpty_spawn_config_new)(int, void*, LPCWSTR, void*, void*, void*);
1037+
void* (*winpty_spawn_config_new)(UINT64, void*, LPCWSTR, void*, void*, void*);
10311038
BOOL (*winpty_spawn)(void*, void*, HANDLE*, HANDLE*, DWORD*, void*);
10321039
void (*winpty_config_set_initial_size)(void*, int, int);
10331040
LPCWSTR (*winpty_conin_name)(void*);

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+
769,
772774
/**/
773775
768,
774776
/**/

0 commit comments

Comments
 (0)