Hi,

I found some issues with the terminal feature (mainly on Windows):

* Couldn't build with VC2010, because libvterm requires stdbool.h.
  Reuse if_perl_msvc/stdbool.h for this.
  (Maybe it's better to change the directory name "if_perl_msvc", but I didn't
  do it this time.)

* vterm.lib was not build automatically by Make_mvc.mak. Add it to the
  dependency of vim.exe.
  (src/Makefile doesn't build libvterm.a and compiles/links it directly.
  Maybe it's better to do the same thing for src/Make_mvc.mak and
  src/Make_cyg_ming.mak, because we cannot build both 32- and 64-bit vim.exe
  in the same directory when the terminal feature is enabled.)

* Winpty didn't work with 32-bit vim.exe. Fix some function declarations.

* Fix crash when 'encoding' isn't "utf-8".

* Fix document.
  - Fix typos.
  - Move instructions for installing winpty to runtime/doc/terminal.txt from
    src/INSTALLpc.txt
  - etc.

Please check the attached patch.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# Parent  1b30134054469517ac0a8af7b589fcb8da3da8e5

diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt
--- a/runtime/doc/terminal.txt
+++ b/runtime/doc/terminal.txt
@@ -47,8 +47,9 @@ See option 'termsize' for controlling th
 (TODO: scrolling when the terminal is larger than the window)
 
 Syntax ~
-						*:ter* *:terminal*
-:terminal[!] [command]	Open a new terminal window.
+
+:ter[minal][!] [command]			*:ter* *:terminal*
+			Open a new terminal window.
 
 			If [command] is provided run it as a job and connect
 			the input and output to the terminal.
@@ -79,7 +80,7 @@ 1. The 'termsize' option is empty: The t
    The minimal size is 2 screen lines with 10 cells.
 
 2. The 'termsize' option is "rows*cols", where "rows" is the minimal number of
-   screen rows and "cols" is the minial number of cells.
+   screen rows and "cols" is the minimal number of cells.
 
 3. The 'termsize' option is "rowsXcols" (where the x is upper or lower case).
    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'
 
 MS-Windows ~
 
-On MS-Windows a hidden console is used to run the command in.  This should
-work well for all kind of commands.  Obviously, they must be commands that run
-in a terminal, not open their own window.
+On MS-Windows winpty is used to make it possible to run all kind of commands.
+Obviously, they must be commands that run in a terminal, not open their own
+window.
+
+You need the following two files from winpty:
+
+    winpty.dll
+    winpty-agent.exe
+
+You can download them from the following page:
+
+    https://github.com/rprichard/winpty
+
+Just put the files somewhere in your PATH.
 
 ==============================================================================
 2. Remote testing					*terminal-testing*
diff --git a/src/INSTALLpc.txt b/src/INSTALLpc.txt
--- a/src/INSTALLpc.txt
+++ b/src/INSTALLpc.txt
@@ -706,20 +706,17 @@ Or when using MinGW (as one line):
 13. Building with Terminal support
 ==================================
 
-Vim with Terminal support can be built with either MSVC, or MinGW or Cygwin.
+Vim with Terminal support can be built with either MSVC, MinGW or Cygwin.
 This uses the included libvterm and winpty.  No extra header files or
-libraries are needed for building.
-
-Running Vim with terminal support requires the following two winpty files:
+libraries are needed for building.  Just set TERMINAL to yes.
 
-    winpty.dll
-    winpty-agent.dll
+E.g. When using MSVC:
 
-You can download them from the following page:
+    nmake -f Make_mvc.mak TERMINAL=yes
 
-    https://github.com/rprichard/winpty
+Or when using MinGW (as one line):
 
-Just put the DLL files somewhere in your PATH.
+    mingw32-make -f Make_mingw.mak TERMINAL=yes
 
 
 14. Windows 3.1x
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -73,6 +73,7 @@ CHANNEL=yes
 else
 CHANNEL=$(GUI)
 endif
+# Set to yes to enable terminal support.
 TERMINAL=no
 
 
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -356,6 +356,9 @@ CSCOPE_DEFS  = -DFEAT_CSCOPE
 !if "$(TERMINAL)" == "yes"
 TERMINAL_OBJ   = $(OBJDIR)/terminal.obj
 TERMINAL_DEFS  = -DFEAT_TERMINAL
+!if $(MSVC_MAJOR) <= 11
+TERMINAL_DEFS = $(TERMINAL_DEFS) /I if_perl_msvc
+!endif
 TERMINAL_SRC   = terminal.c
 VTERM_LIB      = libvterm/vterm.lib
 !endif
@@ -1156,7 +1159,7 @@ all:	$(VIM).exe \
 
 $(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
 		$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
-		$(CSCOPE_OBJ) $(TERMINAL_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) \
+		$(CSCOPE_OBJ) $(TERMINAL_OBJ) $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) $(VTERM_LIB) \
 		version.c version.h
 	$(CC) $(CFLAGS) version.c
 	$(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) \
@@ -1551,7 +1554,7 @@ proto.h: \
 
 libvterm/vterm.lib :
 	cd libvterm
-	$(MAKE) /NOLOGO -f Makefile.msc
+	$(MAKE) /NOLOGO -f Makefile.msc "MSVC_MAJOR=$(MSVC_MAJOR)"
 	cd ..
 
 # vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0:
diff --git a/src/if_perl_msvc/stdbool.h b/src/if_perl_msvc/stdbool.h
--- a/src/if_perl_msvc/stdbool.h
+++ b/src/if_perl_msvc/stdbool.h
@@ -1,3 +1,6 @@
 /* A stub stdbool.h for VC2012 or earlier.
  * ActivePerl 5.20+ requires stdbool.h but VC2012 doesn't have it. */
 #define bool char
+#define false	0
+#define true	1
+#define __bool_true_false_are_defined	1
diff --git a/src/libvterm/Makefile.msc b/src/libvterm/Makefile.msc
--- a/src/libvterm/Makefile.msc
+++ b/src/libvterm/Makefile.msc
@@ -1,3 +1,8 @@
+CFLAGS = /DINLINE= /Iinclude
+!if defined(MSVC_MAJOR) && $(MSVC_MAJOR) <= 11
+CFLAGS = $(CFLAGS) /I ../if_perl_msvc
+!endif
+
 OBJS = \
 	src\encoding.c \
 	src\keyboard.c \
@@ -24,7 +29,10 @@ all : vterm.lib
 
 
 .c.obj :
-	cl /DINLINE= /Iinclude /Fo$@ /c $<
+	cl $(CFLAGS) /Fo$@ /c $<
 
 vterm.lib : $(OBJS)
 	lib /OUT:$@ $(OBJS)
+
+clean:
+	del $(OBJS) vterm.lib
diff --git a/src/terminal.c b/src/terminal.c
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -25,7 +25,7 @@
  * the terminal emulator.
  *
  * If the terminal window has keyboard focus, typed keys are converted to the
- * terminal encoding and writting to the job over a channel.
+ * terminal encoding and writing to the job over a channel.
  *
  * If the job produces output, it is written to the terminal emulator.  The
  * terminal emulator invokes callbacks when its screen content changes.  The
@@ -687,7 +687,7 @@ color2index(VTermColor *color)
     else if (red == 128)
     {
 	if (green == 128 && blue == 128)
-	    return 9; /* high intensity bladk */
+	    return 9; /* high intensity black */
     }
     else if (red == 255)
     {
@@ -850,7 +850,10 @@ term_update_window(win_T *wp)
 		if (c == NUL)
 		{
 		    ScreenLines[off] = ' ';
-		    ScreenLinesUC[off] = NUL;
+#if defined(FEAT_MBYTE)
+		    if (enc_utf8)
+			ScreenLinesUC[off] = NUL;
+#endif
 		}
 		else
 		{
@@ -863,7 +866,8 @@ term_update_window(win_T *wp)
 		    else
 		    {
 			ScreenLines[off] = c;
-			ScreenLinesUC[off] = NUL;
+			if (enc_utf8)
+			    ScreenLinesUC[off] = NUL;
 		    }
 #else
 		    ScreenLines[off] = c;
@@ -876,7 +880,10 @@ term_update_window(win_T *wp)
 		if (cell.width == 2)
 		{
 		    ScreenLines[off] = NUL;
-		    ScreenLinesUC[off] = NUL;
+#if defined(FEAT_MBYTE)
+		    if (enc_utf8)
+			ScreenLinesUC[off] = NUL;
+#endif
 		    ++pos.col;
 		    ++off;
 		}
@@ -955,9 +962,9 @@ create_vterm(term_T *term, int rows, int
 #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul
 #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull
 
-void* (*winpty_config_new)(int, void*);
+void* (*winpty_config_new)(UINT64, void*);
 void* (*winpty_open)(void*, void*);
-void* (*winpty_spawn_config_new)(int, void*, LPCWSTR, void*, void*, void*);
+void* (*winpty_spawn_config_new)(UINT64, void*, LPCWSTR, void*, void*, void*);
 BOOL (*winpty_spawn)(void*, void*, HANDLE*, HANDLE*, DWORD*, void*);
 void (*winpty_config_set_initial_size)(void*, int, int);
 LPCWSTR (*winpty_conin_name)(void*);

Raspunde prin e-mail lui