To: vim_dev@googlegroups.com Subject: Patch 8.0.0769 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0769 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) Files: src/libvterm/bin/vterm-ctrl.c, runtime/doc/terminal.txt, src/INSTALLpc.txt, src/Make_cyg_ming.mak, src/Make_mvc.mak, src/libvterm/Makefile.msc, src/terminal.c *** ../vim-8.0.0768/src/libvterm/bin/vterm-ctrl.c 2017-07-07 11:53:29.515876528 +0200 --- src/libvterm/bin/vterm-ctrl.c 2017-07-24 22:16:41.622220575 +0200 *************** *** 1,10 **** #define _XOPEN_SOURCE 500 /* strdup */ - #include #include #include #include #define streq(a,b) (strcmp(a,b)==0) #include --- 1,11 ---- #define _XOPEN_SOURCE 500 /* strdup */ #include #include #include #define streq(a,b) (strcmp(a,b)==0) + #define TRUE 1 + #define FALSE 0 #include *************** *** 60,72 **** NULL }; ! static bool seticanon(bool icanon, bool echo) { struct termios termios; tcgetattr(0, &termios); ! bool ret = (termios.c_lflag & ICANON); if(icanon) termios.c_lflag |= ICANON; else termios.c_lflag &= ~ICANON; --- 61,74 ---- NULL }; ! static int seticanon(int icanon, int echo) { struct termios termios; + int ret; tcgetattr(0, &termios); ! ret = (termios.c_lflag & ICANON); if(icanon) termios.c_lflag |= ICANON; else termios.c_lflag &= ~ICANON; *************** *** 84,99 **** int c; /* await CSI - 8bit or 2byte 7bit form */ ! bool in_esc = false; while((c = getchar())) { if(c == c1) break; if(in_esc && c == (char)(c1 - 0x40)) break; if(!in_esc && c == 0x1b) ! in_esc = true; else ! in_esc = false; } } --- 86,101 ---- int c; /* await CSI - 8bit or 2byte 7bit form */ ! int in_esc = FALSE; while((c = getchar())) { if(c == c1) break; if(in_esc && c == (char)(c1 - 0x40)) break; if(!in_esc && c == 0x1b) ! in_esc = TRUE; else ! in_esc = FALSE; } } *************** *** 121,127 **** static char *read_dcs() { unsigned char dcs[32]; ! bool in_esc = false; int i; await_c1(0x90); --- 123,129 ---- static char *read_dcs() { unsigned char dcs[32]; ! int in_esc = FALSE; int i; await_c1(0x90); *************** *** 133,142 **** if(in_esc && c == 0x5c) break; if(!in_esc && c == 0x1b) ! in_esc = true; else { dcs[i++] = c; ! in_esc = false; } } dcs[++i] = 0; --- 135,144 ---- if(in_esc && c == 0x5c) break; if(!in_esc && c == 0x1b) ! in_esc = TRUE; else { dcs[i++] = c; ! in_esc = FALSE; } } dcs[++i] = 0; *************** *** 158,164 **** exit(exitcode); } ! static bool query_dec_mode(int mode) { char *s = NULL; --- 160,166 ---- exit(exitcode); } ! static int query_dec_mode(int mode) { char *s = NULL; *************** *** 189,200 **** free(s); if(reply_value == 1 || reply_value == 3) ! return true; if(reply_value == 2 || reply_value == 4) ! return false; printf("Unrecognised reply to DECRQM: %d\n", reply_value); ! return false; } while(1); } --- 191,202 ---- free(s); if(reply_value == 1 || reply_value == 3) ! return TRUE; if(reply_value == 2 || reply_value == 4) ! return FALSE; printf("Unrecognised reply to DECRQM: %d\n", reply_value); ! return FALSE; } while(1); } *************** *** 247,257 **** } while(1); } ! bool wasicanon; void restoreicanon(void) { ! seticanon(wasicanon, true); } int main(int argc, char *argv[]) --- 249,259 ---- } while(1); } ! int wasicanon; void restoreicanon(void) { ! seticanon(wasicanon, TRUE); } int main(int argc, char *argv[]) *************** *** 261,267 **** if(argc == 1) usage(0); ! wasicanon = seticanon(false, false); atexit(restoreicanon); while(argi < argc) { --- 263,269 ---- if(argc == 1) usage(0); ! wasicanon = seticanon(FALSE, FALSE); atexit(restoreicanon); while(argi < argc) { *** ../vim-8.0.0768/runtime/doc/terminal.txt 2017-07-07 11:53:29.515876528 +0200 --- runtime/doc/terminal.txt 2017-07-24 22:18:13.461537368 +0200 *************** *** 1,4 **** ! *terminal.txt* For Vim version 8.0. Last change: 2017 Jul 04 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *terminal.txt* For Vim version 8.0. Last change: 2017 Jul 24 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 9,14 **** --- 9,18 ---- WARNING: THIS IS ONLY PARTLY IMPLEMENTED, ANYTHING CAN STILL CHANGE + The terminal feature is optional, use this to check if your Vim has it: > + echo has('terminal') + If the result is "1" you have it. + 1. Basic use |terminal-use| 2. Remote testing |terminal-testing| *************** *** 34,53 **** Navigate between windows with CTRL-W commands (and mouse). E.g. CTRL-W CTRL-W moves focus to the next window. ! Option 'termkey' ! Specify key for Vim command in terminal window. local to window. Default is CTRL-W. ! Option 'termsize' ! Specify terminal size. Local to window. ! When empty the terminal gets the size from the window. ! When set (e.g., "24x80") the terminal size is fixed. If the window is smaller ! only the top-left part is displayed. (TODO: scrolling?) Syntax ~ ! *:ter* *:terminal* ! :terminal[!] [command] Open a new terminal window. If [command] is provided run it as a job and connect the input and output to the terminal. --- 38,55 ---- Navigate between windows with CTRL-W commands (and mouse). E.g. CTRL-W CTRL-W moves focus to the next window. + Use "CTRL-W :" to edit an Ex command. ! See option 'termkey' for specifying the key that precedes a Vim command. Default is CTRL-W. ! See option 'termsize' for controlling the size of the terminal window. ! (TODO: scrolling when the terminal is larger than the window) Syntax ~ ! ! :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. *************** *** 66,71 **** --- 68,77 ---- buffer. If there are unsaved changes this fails, use ! to force, as usual. + When the buffer associated with the terminal is wiped out the job is killed, + similar to calling `job_stop(job, "kill")` + + Resizing ~ The size of the terminal can be in one of three modes: *************** *** 74,80 **** 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. 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 --- 80,86 ---- 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 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 *************** *** 87,92 **** --- 93,122 ---- terminal. |term_setsize()| can be used only when in the first or second mode, not when 'termsize' is "rowsXcols". + + Unix ~ + + On Unix a pty is used to make it possible to run all kinds of commands. You + can even run Vim in the terminal! That's used for debugging, see below. + + + MS-Windows ~ + + 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* *** ../vim-8.0.0768/src/INSTALLpc.txt 2017-07-23 17:10:58.022823919 +0200 --- src/INSTALLpc.txt 2017-07-24 22:19:15.645074902 +0200 *************** *** 706,725 **** 13. Building with Terminal support ================================== ! Vim with Terminal support can be built with either MSVC, or 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: ! winpty.dll ! winpty-agent.dll ! You can download them from the following page: ! https://github.com/rprichard/winpty ! ! Just put the DLL files somewhere in your PATH. 14. Windows 3.1x --- 706,722 ---- 13. Building with Terminal support ================================== ! 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. Just set TERMINAL to yes. ! E.g. When using MSVC: ! nmake -f Make_mvc.mak TERMINAL=yes ! Or when using MinGW (as one line): ! mingw32-make -f Make_mingw.mak TERMINAL=yes 14. Windows 3.1x *** ../vim-8.0.0768/src/Make_cyg_ming.mak 2017-07-22 16:14:39.272915812 +0200 --- src/Make_cyg_ming.mak 2017-07-24 22:19:15.645074902 +0200 *************** *** 73,78 **** --- 73,79 ---- else CHANNEL=$(GUI) endif + # Set to yes to enable terminal support. TERMINAL=no *** ../vim-8.0.0768/src/Make_mvc.mak 2017-07-23 17:10:58.022823919 +0200 --- src/Make_mvc.mak 2017-07-24 22:19:15.645074902 +0200 *************** *** 356,361 **** --- 356,364 ---- !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 *************** *** 1154,1160 **** $(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) \ version.c version.h $(CC) $(CFLAGS) version.c $(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) \ --- 1157,1163 ---- $(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) $(VTERM_LIB) \ version.c version.h $(CC) $(CFLAGS) version.c $(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(CUI_OBJ) $(OLE_OBJ) \ *************** *** 1549,1555 **** libvterm/vterm.lib : cd libvterm ! $(MAKE) /NOLOGO -f Makefile.msc cd .. # vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0: --- 1552,1558 ---- libvterm/vterm.lib : cd libvterm ! $(MAKE) /NOLOGO -f Makefile.msc "MSVC_MAJOR=$(MSVC_MAJOR)" cd .. # vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0: *** ../vim-8.0.0768/src/libvterm/Makefile.msc 2017-07-23 17:10:58.022823919 +0200 --- src/libvterm/Makefile.msc 2017-07-24 22:21:50.623922751 +0200 *************** *** 1,3 **** --- 1,5 ---- + CFLAGS = /DINLINE= /Iinclude + OBJS = \ src\encoding.c \ src\keyboard.c \ *************** *** 24,30 **** .c.obj : ! cl /DINLINE= /Iinclude /Fo$@ /c $< vterm.lib : $(OBJS) lib /OUT:$@ $(OBJS) --- 26,35 ---- .c.obj : ! cl $(CFLAGS) /Fo$@ /c $< vterm.lib : $(OBJS) lib /OUT:$@ $(OBJS) + + clean: + del $(OBJS) vterm.lib *** ../vim-8.0.0768/src/terminal.c 2017-07-24 21:44:38.768901080 +0200 --- src/terminal.c 2017-07-24 22:19:15.645074902 +0200 *************** *** 25,31 **** * 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. * * If the job produces output, it is written to the terminal emulator. The * terminal emulator invokes callbacks when its screen content changes. The --- 25,31 ---- * the terminal emulator. * * If the terminal window has keyboard focus, typed keys are converted to the ! * 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 *************** *** 731,737 **** else if (red == 128) { if (green == 128 && blue == 128) ! return 9; /* high intensity bladk */ } else if (red == 255) { --- 731,737 ---- else if (red == 128) { if (green == 128 && blue == 128) ! return 9; /* high intensity black */ } else if (red == 255) { *************** *** 894,900 **** if (c == NUL) { ScreenLines[off] = ' '; ! ScreenLinesUC[off] = NUL; } else { --- 894,903 ---- if (c == NUL) { ScreenLines[off] = ' '; ! #if defined(FEAT_MBYTE) ! if (enc_utf8) ! ScreenLinesUC[off] = NUL; ! #endif } else { *************** *** 907,913 **** else { ScreenLines[off] = c; ! ScreenLinesUC[off] = NUL; } #else ScreenLines[off] = c; --- 910,917 ---- else { ScreenLines[off] = c; ! if (enc_utf8) ! ScreenLinesUC[off] = NUL; } #else ScreenLines[off] = c; *************** *** 920,926 **** if (cell.width == 2) { ScreenLines[off] = NUL; ! ScreenLinesUC[off] = NUL; ++pos.col; ++off; } --- 924,933 ---- if (cell.width == 2) { ScreenLines[off] = NUL; ! #if defined(FEAT_MBYTE) ! if (enc_utf8) ! ScreenLinesUC[off] = NUL; ! #endif ++pos.col; ++off; } *************** *** 1025,1033 **** #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull ! void* (*winpty_config_new)(int, void*); void* (*winpty_open)(void*, void*); ! void* (*winpty_spawn_config_new)(int, 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*); --- 1032,1040 ---- #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull ! void* (*winpty_config_new)(UINT64, void*); void* (*winpty_open)(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*); *** ../vim-8.0.0768/src/version.c 2017-07-24 21:44:38.768901080 +0200 --- src/version.c 2017-07-24 22:24:24.118782233 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 769, /**/ -- You are Dead. Do you wish to restart, load, or quit? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///