From 5830232c021102e47a4e6fc81857604e4a031ddf Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 22 Aug 2017 20:33:53 +0200 Subject: [PATCH 1/4] patch 8.0.0984: terminal blinking cursor not correct in the GUI Problem: Terminal blinking cursor not correct in the GUI. Solution: Set blinkoff correctly. Also make the cursor blink on MS-Windows by default. (Ken Takata) --- src/terminal.c | 21 ++++++++++++++++----- src/version.c | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 2cf4525ae4..551fbe70e8 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -43,6 +43,10 @@ * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". * - support minimal size when 'termsize' is empty? + * - do not set bufhidden to "hide"? works like a buffer with changes. + * document that CTRL-W :hide can be used. + * - command argument with spaces doesn't work #1999 + * :terminal ls dir\ with\ spaces * - implement job options when starting a terminal. Allow: * "in_io", "in_top", "in_bot", "in_name", "in_buf" "out_io", "out_name", "out_buf", "out_modifiable", "out_msg" @@ -845,7 +849,7 @@ add_scrollback_line_to_buffer(term_T *term, char_u *text, int len) int empty = (buf->b_ml.ml_flags & ML_EMPTY); linenr_T lnum = buf->b_ml.ml_line_count; -#ifdef _WIN32 +#ifdef WIN3264 if (!enc_utf8 && enc_codepage > 0) { WCHAR *ret = NULL; @@ -1295,7 +1299,7 @@ term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg) { entry.blinkwait = 700; entry.blinkon = 400; - entry.blinkon = 250; + entry.blinkoff = 250; } *fg = gui.back_pixel; if (term->tl_cursor_color == NULL) @@ -1487,7 +1491,7 @@ terminal_loop(void) goto theend; } } -# ifdef _WIN32 +# ifdef WIN3264 if (!enc_utf8 && has_mbyte && c >= 0x80) { WCHAR wc; @@ -2120,7 +2124,7 @@ term_update_window(win_T *wp) ScreenLinesUC[off] = NUL; } } -# ifdef _WIN32 +# ifdef WIN3264 else if (has_mbyte && c >= 0x80) { char_u mb[MB_MAXBYTES+1]; @@ -2263,8 +2267,15 @@ create_vterm(term_T *term, int rows, int cols) /* Allow using alternate screen. */ vterm_screen_enable_altscreen(screen, 1); - /* We do not want a blinking cursor by default. */ + /* For unix do not use a blinking cursor. In an xterm this causes the + * cursor to blink if it's blinking in the xterm. + * We do want a blinking cursor by default on Windows, since that's what + * the default is for a console. */ +#ifdef WIN3264 + value.boolean = 1; +#else value.boolean = 0; +#endif vterm_state_set_termprop(vterm_obtain_state(vterm), VTERM_PROP_CURSORBLINK, &value); } diff --git a/src/version.c b/src/version.c index a5cb078f0d..0383e58c1e 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 984, /**/ 983, /**/ From 6d0826dfbba9880820d9ec221327e4250bbf6540 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 22 Aug 2017 22:12:17 +0200 Subject: [PATCH 2/4] patch 8.0.0985: libvterm has its own idea of character width Problem: Libvterm has its own idea of character width. Solution: Use the Vim functions for character width and composing to avoid a mismatch. (idea by Yasuhiro Matsumoto) --- src/Make_cyg_ming.mak | 6 +++++- src/Make_mvc.mak | 7 ++++++- src/Makefile | 6 +++++- src/libvterm/src/unicode.c | 28 ++++++++++++++++++++++++---- src/mbyte.c | 22 ++++++++++++++++++++++ src/proto/mbyte.pro | 2 ++ src/version.c | 2 ++ 7 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index 5b0719f7d9..1c368badf1 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -971,7 +971,11 @@ $(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS) $(CC) -c $(CFLAGS) terminal.c -o $(OUTDIR)/terminal.o -CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf +CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" \ + -DVSNPRINTF=vim_vsnprintf \ + -DIS_COMBINING_FUNCTION=utf_iscomposing_uint \ + -DWCWIDTH_FUNCTION=utf_uint2cells + $(OUTDIR)/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS) $(CCCTERM) libvterm/src/encoding.c -o $@ diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index d1221d0f0a..4180b7c76f 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -1474,7 +1474,12 @@ $(OUTDIR)/dimm_i.obj: $(OUTDIR) dimm_i.c $(INCL) $(OUTDIR)/glbl_ime.obj: $(OUTDIR) glbl_ime.cpp dimm.h $(INCL) -CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf -D_CRT_SECURE_NO_WARNINGS +CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" \ + -DVSNPRINTF=vim_vsnprintf \ + -DIS_COMBINING_FUNCTION=utf_iscomposing_uint \ + -DWCWIDTH_FUNCTION=utf_uint2cells \ + -D_CRT_SECURE_NO_WARNINGS + $(OUTDIR)/term_encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS) $(CCCTERM) -Fo$@ libvterm/src/encoding.c diff --git a/src/Makefile b/src/Makefile index 1f252f0565..e4da3b4b6b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3296,7 +3296,11 @@ objects/channel.o: channel.c Makefile: @echo The name of the makefile MUST be "Makefile" (with capital M)!!!! -CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf +CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" \ + -DVSNPRINTF=vim_vsnprintf \ + -DIS_COMBINING_FUNCTION=utf_iscomposing_uint \ + -DWCWIDTH_FUNCTION=utf_uint2cells + objects/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/encoding.c diff --git a/src/libvterm/src/unicode.c b/src/libvterm/src/unicode.c index b989add3ca..e5a25a5e76 100644 --- a/src/libvterm/src/unicode.c +++ b/src/libvterm/src/unicode.c @@ -68,6 +68,7 @@ * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ +#if !defined(IS_COMBINING_FUNCTION) || !defined(WCWIDTH_FUNCTION) struct interval { int first; int last; @@ -126,7 +127,6 @@ static const struct interval combining[] = { { 0xE0100, 0xE01EF } }; - /* auxiliary function for binary search in interval table */ static int bisearch(uint32_t ucs, const struct interval *table, int max) { int min = 0; @@ -146,6 +146,7 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max) { return 0; } +#endif /* The following two functions define the column width of an ISO 10646 @@ -180,6 +181,11 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max) { * in ISO 10646. */ +#ifdef WCWIDTH_FUNCTION +/* use a provided wcwidth() function */ +int WCWIDTH_FUNCTION(uint32_t ucs); +#else +# define WCWIDTH_FUNCTION mk_wcwidth static int mk_wcwidth(uint32_t ucs) { @@ -196,7 +202,7 @@ static int mk_wcwidth(uint32_t ucs) /* if we arrive here, ucs is not a combining or C0/C1 control character */ - return 1 + + return 1 + (ucs >= 0x1100 && (ucs <= 0x115f || /* Hangul Jamo init. consonants */ ucs == 0x2329 || ucs == 0x232a || @@ -211,6 +217,7 @@ static int mk_wcwidth(uint32_t ucs) (ucs >= 0x20000 && ucs <= 0x2fffd) || (ucs >= 0x30000 && ucs <= 0x3fffd))); } +#endif #if 0 /* unused */ static int mk_wcswidth(const uint32_t *pwcs, size_t n) @@ -317,15 +324,28 @@ static int mk_wcswidth_cjk(const uint32_t *pwcs, size_t n) } #endif +#ifdef IS_COMBINING_FUNCTION +/* Use a provided is_combining() function. */ +int IS_COMBINING_FUNCTION(uint32_t codepoint); +#else +# define IS_COMBINING_FUNCTION vterm_is_combining + static int +vterm_is_combining(uint32_t codepoint) +{ + return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1); +} +#endif + + /* ################################ * ### The rest added by Paul Evans */ INTERNAL int vterm_unicode_width(uint32_t codepoint) { - return mk_wcwidth(codepoint); + return WCWIDTH_FUNCTION(codepoint); } INTERNAL int vterm_unicode_is_combining(uint32_t codepoint) { - return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1); + return IS_COMBINING_FUNCTION(codepoint); } diff --git a/src/mbyte.c b/src/mbyte.c index 33fa0a2540..e3c47d6a51 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1395,6 +1395,17 @@ static struct interval ambiguous[] = {0x100000, 0x10fffd} }; +#if defined(FEAT_TERMINAL) || defined(PROTO) +/* + * utf_char2cells() with different argument type for libvterm. + */ + int +utf_uint2cells(uint32_t c) +{ + return utf_char2cells((int)c); +} +#endif + /* * For UTF-8 character "c" return 2 for a double-width character, 1 for others. * Returns 4 or 6 for an unprintable character. @@ -2296,6 +2307,17 @@ utf_char2bytes(int c, char_u *buf) return 6; } +#if defined(FEAT_TERMINAL) || defined(PROTO) +/* + * utf_iscomposing() with different argument type for libvterm. + */ + int +utf_iscomposing_uint(uint32_t c) +{ + return utf_iscomposing((int)c); +} +#endif + /* * Return TRUE if "c" is a composing UTF-8 character. This means it will be * drawn on top of the preceding character. diff --git a/src/proto/mbyte.pro b/src/proto/mbyte.pro index 83bcadc696..b37064b8e3 100644 --- a/src/proto/mbyte.pro +++ b/src/proto/mbyte.pro @@ -10,6 +10,7 @@ int latin_char2len(int c); int latin_char2bytes(int c, char_u *buf); int latin_ptr2len(char_u *p); int latin_ptr2len_len(char_u *p, int size); +int utf_uint2cells(uint32_t c); int utf_char2cells(int c); int latin_ptr2cells(char_u *p); int utf_ptr2cells(char_u *p); @@ -37,6 +38,7 @@ int utfc_ptr2len(char_u *p); int utfc_ptr2len_len(char_u *p, int size); int utf_char2len(int c); int utf_char2bytes(int c, char_u *buf); +int utf_iscomposing_uint(uint32_t c); int utf_iscomposing(int c); int utf_printable(int c); int utf_class(int c); diff --git a/src/version.c b/src/version.c index 0383e58c1e..ef0209e573 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 985, /**/ 984, /**/ From ec0e07a32484ab70f1c7668294c3d8d67f8aca82 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 22 Aug 2017 22:21:37 +0200 Subject: [PATCH 3/4] patch 8.0.0986: terminal feature always requires multi-byte feature Problem: Terminal feature always requires multi-byte feature. Solution: Remove #ifdef FEAT_MBYTE, disable terminal without multi-byte. --- src/feature.h | 4 +++- src/terminal.c | 11 ++--------- src/version.c | 2 ++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/feature.h b/src/feature.h index ae3859b815..b7f3664266 100644 --- a/src/feature.h +++ b/src/feature.h @@ -1269,8 +1269,10 @@ /* * +terminal ":terminal" command. Runs a terminal in a window. + * requires +channel and +multibyte */ -#if !defined(FEAT_JOB_CHANNEL) && defined(FEAT_TERMINAL) +#if defined(FEAT_TERMINAL) && \ + !(defined(FEAT_JOB_CHANNEL) && defined(FEAT_MBYTE)) # undef FEAT_TERMINAL #endif #if defined(FEAT_TERMINAL) && !defined(CURSOR_SHAPE) diff --git a/src/terminal.c b/src/terminal.c index 551fbe70e8..3ee50e490f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -63,7 +63,6 @@ * mouse in the Terminal window for copy/paste. * - when 'encoding' is not utf-8, or the job is using another encoding, setup * conversions. - * - update ":help function-list" for terminal functions. * - In the GUI use a terminal emulator for :!cmd. * - Copy text in the vterm to the Vim buffer once in a while, so that * completion works. @@ -2103,14 +2102,11 @@ term_update_window(win_T *wp) if (c == NUL) { ScreenLines[off] = ' '; -#if defined(FEAT_MBYTE) if (enc_utf8) ScreenLinesUC[off] = NUL; -#endif } else { -#if defined(FEAT_MBYTE) if (enc_utf8) { if (c >= 0x80) @@ -2124,7 +2120,7 @@ term_update_window(win_T *wp) ScreenLinesUC[off] = NUL; } } -# ifdef WIN3264 +#ifdef WIN3264 else if (has_mbyte && c >= 0x80) { char_u mb[MB_MAXBYTES+1]; @@ -2140,9 +2136,8 @@ term_update_window(win_T *wp) else ScreenLines[off] = c; } -# endif - else #endif + else ScreenLines[off] = c; } ScreenAttrs[off] = cell2attr(cell.attrs, cell.fg, cell.bg); @@ -2151,11 +2146,9 @@ term_update_window(win_T *wp) ++off; if (cell.width == 2) { -#if defined(FEAT_MBYTE) if (enc_utf8) ScreenLinesUC[off] = NUL; else if (!has_mbyte) -#endif ScreenLines[off] = NUL; ++pos.col; ++off; diff --git a/src/version.c b/src/version.c index ef0209e573..6baf62be44 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 986, /**/ 985, /**/ From d2c45a1964ddb0d9ac16c9c985051fab41f37840 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 22 Aug 2017 22:29:00 +0200 Subject: [PATCH 4/4] patch 8.0.0987: terminal: second byte of double-byte char wrong Problem: terminal: second byte of double-byte char wrong Solution: Set the second byte to NUL only for utf-8 and non-multibyte. --- src/terminal.c | 8 ++++++-- src/version.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 3ee50e490f..1baad7bf1f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -2130,7 +2130,7 @@ term_update_window(win_T *wp) (char*)mb, 2, 0, 0) > 1) { ScreenLines[off] = mb[0]; - ScreenLines[off+1] = mb[1]; + ScreenLines[off + 1] = mb[1]; cell.width = mb_ptr2cells(mb); } else @@ -2148,8 +2148,12 @@ term_update_window(win_T *wp) { if (enc_utf8) ScreenLinesUC[off] = NUL; - else if (!has_mbyte) + + /* don't set the second byte to NUL for a DBCS encoding, it + * has been set above */ + if (enc_utf8 || !has_mbyte) ScreenLines[off] = NUL; + ++pos.col; ++off; } diff --git a/src/version.c b/src/version.c index 6baf62be44..6d2de86633 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 987, /**/ 986, /**/