Skip to content

Commit 2ecbffb

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 5130947 + d2c45a1 commit 2ecbffb

9 files changed

Lines changed: 98 additions & 23 deletions

File tree

src/Make_cyg_ming.mak

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,11 @@ $(OUTDIR)/terminal.o: terminal.c $(INCL) $(TERM_DEPS)
971971
$(CC) -c $(CFLAGS) terminal.c -o $(OUTDIR)/terminal.o
972972

973973

974-
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf
974+
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" \
975+
-DVSNPRINTF=vim_vsnprintf \
976+
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
977+
-DWCWIDTH_FUNCTION=utf_uint2cells
978+
975979
$(OUTDIR)/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
976980
$(CCCTERM) libvterm/src/encoding.c -o $@
977981

src/Make_mvc.mak

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,12 @@ $(OUTDIR)/dimm_i.obj: $(OUTDIR) dimm_i.c $(INCL)
14741474
$(OUTDIR)/glbl_ime.obj: $(OUTDIR) glbl_ime.cpp dimm.h $(INCL)
14751475

14761476

1477-
CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf -D_CRT_SECURE_NO_WARNINGS
1477+
CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" \
1478+
-DVSNPRINTF=vim_vsnprintf \
1479+
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
1480+
-DWCWIDTH_FUNCTION=utf_uint2cells \
1481+
-D_CRT_SECURE_NO_WARNINGS
1482+
14781483
$(OUTDIR)/term_encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS)
14791484
$(CCCTERM) -Fo$@ libvterm/src/encoding.c
14801485

src/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3322,7 +3322,11 @@ objects/channel.o: channel.c
33223322
Makefile:
33233323
@echo The name of the makefile MUST be "Makefile" (with capital M)!!!!
33243324

3325-
CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" -DVSNPRINTF=vim_vsnprintf
3325+
CCCTERM = $(CCC) -Ilibvterm/include -DINLINE="" \
3326+
-DVSNPRINTF=vim_vsnprintf \
3327+
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
3328+
-DWCWIDTH_FUNCTION=utf_uint2cells
3329+
33263330
objects/term_encoding.o: libvterm/src/encoding.c $(TERM_DEPS)
33273331
$(CCCTERM) -o $@ libvterm/src/encoding.c
33283332

src/feature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,10 @@
12831283

12841284
/*
12851285
* +terminal ":terminal" command. Runs a terminal in a window.
1286+
* requires +channel and +multibyte
12861287
*/
1287-
#if !defined(FEAT_JOB_CHANNEL) && defined(FEAT_TERMINAL)
1288+
#if defined(FEAT_TERMINAL) && \
1289+
!(defined(FEAT_JOB_CHANNEL) && defined(FEAT_MBYTE))
12881290
# undef FEAT_TERMINAL
12891291
#endif
12901292
#if defined(FEAT_TERMINAL) && !defined(CURSOR_SHAPE)

src/libvterm/src/unicode.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
6969
*/
7070

71+
#if !defined(IS_COMBINING_FUNCTION) || !defined(WCWIDTH_FUNCTION)
7172
struct interval {
7273
int first;
7374
int last;
@@ -126,7 +127,6 @@ static const struct interval combining[] = {
126127
{ 0xE0100, 0xE01EF }
127128
};
128129

129-
130130
/* auxiliary function for binary search in interval table */
131131
static int bisearch(uint32_t ucs, const struct interval *table, int max) {
132132
int min = 0;
@@ -146,6 +146,7 @@ static int bisearch(uint32_t ucs, const struct interval *table, int max) {
146146

147147
return 0;
148148
}
149+
#endif
149150

150151

151152
/* 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) {
180181
* in ISO 10646.
181182
*/
182183

184+
#ifdef WCWIDTH_FUNCTION
185+
/* use a provided wcwidth() function */
186+
int WCWIDTH_FUNCTION(uint32_t ucs);
187+
#else
188+
# define WCWIDTH_FUNCTION mk_wcwidth
183189

184190
static int mk_wcwidth(uint32_t ucs)
185191
{
@@ -196,7 +202,7 @@ static int mk_wcwidth(uint32_t ucs)
196202

197203
/* if we arrive here, ucs is not a combining or C0/C1 control character */
198204

199-
return 1 +
205+
return 1 +
200206
(ucs >= 0x1100 &&
201207
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
202208
ucs == 0x2329 || ucs == 0x232a ||
@@ -211,6 +217,7 @@ static int mk_wcwidth(uint32_t ucs)
211217
(ucs >= 0x20000 && ucs <= 0x2fffd) ||
212218
(ucs >= 0x30000 && ucs <= 0x3fffd)));
213219
}
220+
#endif
214221

215222
#if 0 /* unused */
216223
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)
317324
}
318325
#endif
319326

327+
#ifdef IS_COMBINING_FUNCTION
328+
/* Use a provided is_combining() function. */
329+
int IS_COMBINING_FUNCTION(uint32_t codepoint);
330+
#else
331+
# define IS_COMBINING_FUNCTION vterm_is_combining
332+
static int
333+
vterm_is_combining(uint32_t codepoint)
334+
{
335+
return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1);
336+
}
337+
#endif
338+
339+
320340
/* ################################
321341
* ### The rest added by Paul Evans */
322342

323343
INTERNAL int vterm_unicode_width(uint32_t codepoint)
324344
{
325-
return mk_wcwidth(codepoint);
345+
return WCWIDTH_FUNCTION(codepoint);
326346
}
327347

328348
INTERNAL int vterm_unicode_is_combining(uint32_t codepoint)
329349
{
330-
return bisearch(codepoint, combining, sizeof(combining) / sizeof(struct interval) - 1);
350+
return IS_COMBINING_FUNCTION(codepoint);
331351
}

src/mbyte.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,17 @@ static struct interval ambiguous[] =
13951395
{0x100000, 0x10fffd}
13961396
};
13971397

1398+
#if defined(FEAT_TERMINAL) || defined(PROTO)
1399+
/*
1400+
* utf_char2cells() with different argument type for libvterm.
1401+
*/
1402+
int
1403+
utf_uint2cells(uint32_t c)
1404+
{
1405+
return utf_char2cells((int)c);
1406+
}
1407+
#endif
1408+
13981409
/*
13991410
* For UTF-8 character "c" return 2 for a double-width character, 1 for others.
14001411
* Returns 4 or 6 for an unprintable character.
@@ -2296,6 +2307,17 @@ utf_char2bytes(int c, char_u *buf)
22962307
return 6;
22972308
}
22982309

2310+
#if defined(FEAT_TERMINAL) || defined(PROTO)
2311+
/*
2312+
* utf_iscomposing() with different argument type for libvterm.
2313+
*/
2314+
int
2315+
utf_iscomposing_uint(uint32_t c)
2316+
{
2317+
return utf_iscomposing((int)c);
2318+
}
2319+
#endif
2320+
22992321
/*
23002322
* Return TRUE if "c" is a composing UTF-8 character. This means it will be
23012323
* drawn on top of the preceding character.

src/proto/mbyte.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ int latin_char2len(int c);
1010
int latin_char2bytes(int c, char_u *buf);
1111
int latin_ptr2len(char_u *p);
1212
int latin_ptr2len_len(char_u *p, int size);
13+
int utf_uint2cells(uint32_t c);
1314
int utf_char2cells(int c);
1415
int latin_ptr2cells(char_u *p);
1516
int utf_ptr2cells(char_u *p);
@@ -37,6 +38,7 @@ int utfc_ptr2len(char_u *p);
3738
int utfc_ptr2len_len(char_u *p, int size);
3839
int utf_char2len(int c);
3940
int utf_char2bytes(int c, char_u *buf);
41+
int utf_iscomposing_uint(uint32_t c);
4042
int utf_iscomposing(int c);
4143
int utf_printable(int c);
4244
int utf_class(int c);

src/terminal.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
* - add test for giving error for invalid 'termsize' value.
4444
* - support minimal size when 'termsize' is "rows*cols".
4545
* - support minimal size when 'termsize' is empty?
46+
* - do not set bufhidden to "hide"? works like a buffer with changes.
47+
* document that CTRL-W :hide can be used.
48+
* - command argument with spaces doesn't work #1999
49+
* :terminal ls dir\ with\ spaces
4650
* - implement job options when starting a terminal. Allow:
4751
* "in_io", "in_top", "in_bot", "in_name", "in_buf"
4852
"out_io", "out_name", "out_buf", "out_modifiable", "out_msg"
@@ -59,7 +63,6 @@
5963
* mouse in the Terminal window for copy/paste.
6064
* - when 'encoding' is not utf-8, or the job is using another encoding, setup
6165
* conversions.
62-
* - update ":help function-list" for terminal functions.
6366
* - In the GUI use a terminal emulator for :!cmd.
6467
* - Copy text in the vterm to the Vim buffer once in a while, so that
6568
* completion works.
@@ -850,7 +853,7 @@ add_scrollback_line_to_buffer(term_T *term, char_u *text, int len)
850853
int empty = (buf->b_ml.ml_flags & ML_EMPTY);
851854
linenr_T lnum = buf->b_ml.ml_line_count;
852855

853-
#ifdef _WIN32
856+
#ifdef WIN3264
854857
if (!enc_utf8 && enc_codepage > 0)
855858
{
856859
WCHAR *ret = NULL;
@@ -1300,7 +1303,7 @@ term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg)
13001303
{
13011304
entry.blinkwait = 700;
13021305
entry.blinkon = 400;
1303-
entry.blinkon = 250;
1306+
entry.blinkoff = 250;
13041307
}
13051308
*fg = gui.back_pixel;
13061309
if (term->tl_cursor_color == NULL)
@@ -1492,7 +1495,7 @@ terminal_loop(void)
14921495
goto theend;
14931496
}
14941497
}
1495-
# ifdef _WIN32
1498+
# ifdef WIN3264
14961499
if (!enc_utf8 && has_mbyte && c >= 0x80)
14971500
{
14981501
WCHAR wc;
@@ -2104,14 +2107,11 @@ term_update_window(win_T *wp)
21042107
if (c == NUL)
21052108
{
21062109
ScreenLines[off] = ' ';
2107-
#if defined(FEAT_MBYTE)
21082110
if (enc_utf8)
21092111
ScreenLinesUC[off] = NUL;
2110-
#endif
21112112
}
21122113
else
21132114
{
2114-
#if defined(FEAT_MBYTE)
21152115
if (enc_utf8)
21162116
{
21172117
if (c >= 0x80)
@@ -2125,7 +2125,7 @@ term_update_window(win_T *wp)
21252125
ScreenLinesUC[off] = NUL;
21262126
}
21272127
}
2128-
# ifdef _WIN32
2128+
#ifdef WIN3264
21292129
else if (has_mbyte && c >= 0x80)
21302130
{
21312131
char_u mb[MB_MAXBYTES+1];
@@ -2135,15 +2135,14 @@ term_update_window(win_T *wp)
21352135
(char*)mb, 2, 0, 0) > 1)
21362136
{
21372137
ScreenLines[off] = mb[0];
2138-
ScreenLines[off+1] = mb[1];
2138+
ScreenLines[off + 1] = mb[1];
21392139
cell.width = mb_ptr2cells(mb);
21402140
}
21412141
else
21422142
ScreenLines[off] = c;
21432143
}
2144-
# endif
2145-
else
21462144
#endif
2145+
else
21472146
ScreenLines[off] = c;
21482147
}
21492148
ScreenAttrs[off] = cell2attr(cell.attrs, cell.fg, cell.bg);
@@ -2152,12 +2151,14 @@ term_update_window(win_T *wp)
21522151
++off;
21532152
if (cell.width == 2)
21542153
{
2155-
#if defined(FEAT_MBYTE)
21562154
if (enc_utf8)
21572155
ScreenLinesUC[off] = NUL;
2158-
else if (!has_mbyte)
2159-
#endif
2156+
2157+
/* don't set the second byte to NUL for a DBCS encoding, it
2158+
* has been set above */
2159+
if (enc_utf8 || !has_mbyte)
21602160
ScreenLines[off] = NUL;
2161+
21612162
++pos.col;
21622163
++off;
21632164
}
@@ -2268,8 +2269,15 @@ create_vterm(term_T *term, int rows, int cols)
22682269
/* Allow using alternate screen. */
22692270
vterm_screen_enable_altscreen(screen, 1);
22702271

2271-
/* We do not want a blinking cursor by default. */
2272+
/* For unix do not use a blinking cursor. In an xterm this causes the
2273+
* cursor to blink if it's blinking in the xterm.
2274+
* We do want a blinking cursor by default on Windows, since that's what
2275+
* the default is for a console. */
2276+
#ifdef WIN3264
2277+
value.boolean = 1;
2278+
#else
22722279
value.boolean = 0;
2280+
#endif
22732281
vterm_state_set_termprop(vterm_obtain_state(vterm),
22742282
VTERM_PROP_CURSORBLINK, &value);
22752283
}

src/version.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,14 @@ static char *(features[]) =
784784

785785
static int included_patches[] =
786786
{ /* Add new patch number below this line */
787+
/**/
788+
987,
789+
/**/
790+
986,
791+
/**/
792+
985,
793+
/**/
794+
984,
787795
/**/
788796
983,
789797
/**/

0 commit comments

Comments
 (0)