forked from aniani/vim
patch 8.2.0783: libvterm code lags behind the upstream version
Problem: Libvterm code lags behind the upstream version. Solution: Include revisions 728 - 729.
This commit is contained in:
@@ -1246,6 +1246,7 @@ $(OUTDIR)/pathdef.o: $(PATHDEF_SRC) $(INCL)
|
||||
|
||||
CCCTERM = $(CC) -c $(CFLAGS) -Ilibvterm/include -DINLINE="" \
|
||||
-DVSNPRINTF=vim_vsnprintf \
|
||||
-DSNPRINTF=vim_snprintf \
|
||||
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||
-DWCWIDTH_FUNCTION=utf_uint2cells \
|
||||
-DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type
|
||||
|
@@ -1812,6 +1812,7 @@ $(OUTDIR)/glbl_ime.obj: $(OUTDIR) glbl_ime.cpp dimm.h $(INCL)
|
||||
|
||||
CCCTERM = $(CC) $(CFLAGS) -Ilibvterm/include -DINLINE="" \
|
||||
-DVSNPRINTF=vim_vsnprintf \
|
||||
-DSNPRINTF=vim_snprintf \
|
||||
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||
-DWCWIDTH_FUNCTION=utf_uint2cells \
|
||||
-DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type \
|
||||
|
@@ -3537,6 +3537,7 @@ Makefile:
|
||||
# prefix vterm_ to avoid name clashes.
|
||||
CCCTERM = $(CCC_NF) $(VTERM_CFLAGS) $(ALL_CFLAGS) -DINLINE="" \
|
||||
-DVSNPRINTF=vim_vsnprintf \
|
||||
-DSNPRINTF=vim_snprintf \
|
||||
-DIS_COMBINING_FUNCTION=utf_iscomposing_uint \
|
||||
-DWCWIDTH_FUNCTION=utf_uint2cells
|
||||
|
||||
|
@@ -102,10 +102,10 @@ static keycodes_s keycodes[] = {
|
||||
|
||||
static keycodes_s keycodes_fn[] = {
|
||||
{ KEYCODE_NONE, 0, 0 }, // F0 - shouldn't happen
|
||||
{ KEYCODE_CSI_CURSOR, 'P', 0 }, // F1
|
||||
{ KEYCODE_CSI_CURSOR, 'Q', 0 }, // F2
|
||||
{ KEYCODE_CSI_CURSOR, 'R', 0 }, // F3
|
||||
{ KEYCODE_CSI_CURSOR, 'S', 0 }, // F4
|
||||
{ KEYCODE_SS3, 'P', 0 }, // F1
|
||||
{ KEYCODE_SS3, 'Q', 0 }, // F2
|
||||
{ KEYCODE_SS3, 'R', 0 }, // F3
|
||||
{ KEYCODE_SS3, 'S', 0 }, // F4
|
||||
{ KEYCODE_CSINUM, '~', 15 }, // F5
|
||||
{ KEYCODE_CSINUM, '~', 17 }, // F6
|
||||
{ KEYCODE_CSINUM, '~', 18 }, // F7
|
||||
|
@@ -74,6 +74,9 @@ VTerm *vterm_new_with_allocator(int rows, int cols, VTermAllocatorFunctions *fun
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vt->tmpbuffer_len = 64;
|
||||
vt->tmpbuffer = vterm_allocator_malloc(vt, vt->tmpbuffer_len);
|
||||
|
||||
return vt;
|
||||
}
|
||||
|
||||
@@ -135,67 +138,46 @@ void vterm_set_utf8(VTerm *vt, int is_utf8)
|
||||
INTERNAL void vterm_push_output_bytes(VTerm *vt, const char *bytes, size_t len)
|
||||
{
|
||||
if(len > vt->outbuffer_len - vt->outbuffer_cur) {
|
||||
DEBUG_LOG("vterm_push_output(): buffer overflow; truncating output\n");
|
||||
len = vt->outbuffer_len - vt->outbuffer_cur;
|
||||
DEBUG_LOG("vterm_push_output_bytes(): buffer overflow; dropping output\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(vt->outbuffer + vt->outbuffer_cur, bytes, len);
|
||||
vt->outbuffer_cur += len;
|
||||
}
|
||||
|
||||
static int outbuffer_is_full(VTerm *vt)
|
||||
{
|
||||
return vt->outbuffer_cur >= vt->outbuffer_len - 1;
|
||||
}
|
||||
|
||||
#if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) \
|
||||
|| defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
|
||||
# undef VSNPRINTF
|
||||
# define VSNPRINTF vsnprintf
|
||||
# undef SNPRINTF
|
||||
# define SNPRINTF snprintf
|
||||
#else
|
||||
# ifdef VSNPRINTF
|
||||
// Use a provided vsnprintf() function.
|
||||
int VSNPRINTF(char *str, size_t str_m, const char *fmt, va_list ap);
|
||||
# endif
|
||||
# ifdef SNPRINTF
|
||||
// Use a provided snprintf() function.
|
||||
int SNPRINTF(char *str, size_t str_m, const char *fmt, ...);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
INTERNAL void vterm_push_output_vsprintf(VTerm *vt, const char *format, va_list args)
|
||||
{
|
||||
int written;
|
||||
size_t len;
|
||||
#ifndef VSNPRINTF
|
||||
// When vsnprintf() is not available (C90) fall back to vsprintf().
|
||||
char buffer[1024]; // 1Kbyte is enough for everybody, right?
|
||||
#endif
|
||||
|
||||
if(outbuffer_is_full(vt)) {
|
||||
DEBUG_LOG("vterm_push_output(): buffer overflow; truncating output\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef VSNPRINTF
|
||||
written = VSNPRINTF(vt->outbuffer + vt->outbuffer_cur,
|
||||
vt->outbuffer_len - vt->outbuffer_cur,
|
||||
format, args);
|
||||
|
||||
if(written == (int)(vt->outbuffer_len - vt->outbuffer_cur)) {
|
||||
// output was truncated
|
||||
vt->outbuffer_cur = vt->outbuffer_len - 1;
|
||||
}
|
||||
else
|
||||
vt->outbuffer_cur += written;
|
||||
len = VSNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len, format, args);
|
||||
vterm_push_output_bytes(vt, vt->tmpbuffer, len);
|
||||
#else
|
||||
written = vsprintf(buffer, format, args);
|
||||
|
||||
if(written >= (int)(vt->outbuffer_len - vt->outbuffer_cur - 1)) {
|
||||
// output was truncated
|
||||
written = vt->outbuffer_len - vt->outbuffer_cur - 1;
|
||||
}
|
||||
if (written > 0)
|
||||
{
|
||||
strncpy(vt->outbuffer + vt->outbuffer_cur, buffer, written + 1);
|
||||
vt->outbuffer_cur += written;
|
||||
}
|
||||
len = vsprintf(buffer, format, args);
|
||||
vterm_push_output_bytes(vt, buffer, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -209,40 +191,52 @@ INTERNAL void vterm_push_output_sprintf(VTerm *vt, const char *format, ...)
|
||||
|
||||
INTERNAL void vterm_push_output_sprintf_ctrl(VTerm *vt, unsigned char ctrl, const char *fmt, ...)
|
||||
{
|
||||
size_t orig_cur = vt->outbuffer_cur;
|
||||
size_t cur;
|
||||
va_list args;
|
||||
|
||||
if(ctrl >= 0x80 && !vt->mode.ctrl8bit)
|
||||
vterm_push_output_sprintf(vt, ESC_S "%c", ctrl - 0x40);
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
ESC_S "%c", ctrl - 0x40);
|
||||
else
|
||||
vterm_push_output_sprintf(vt, "%c", ctrl);
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
"%c", ctrl);
|
||||
if(cur >= vt->tmpbuffer_len)
|
||||
return;
|
||||
vterm_push_output_bytes(vt, vt->tmpbuffer, cur);
|
||||
|
||||
va_start(args, fmt);
|
||||
vterm_push_output_vsprintf(vt, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if(outbuffer_is_full(vt))
|
||||
vt->outbuffer_cur = orig_cur;
|
||||
}
|
||||
|
||||
INTERNAL void vterm_push_output_sprintf_dcs(VTerm *vt, const char *fmt, ...)
|
||||
{
|
||||
size_t orig_cur = vt->outbuffer_cur;
|
||||
size_t cur;
|
||||
va_list args;
|
||||
|
||||
if(!vt->mode.ctrl8bit)
|
||||
vterm_push_output_sprintf(vt, ESC_S "%c", C1_DCS - 0x40);
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
ESC_S "%c", C1_DCS - 0x40);
|
||||
else
|
||||
vterm_push_output_sprintf(vt, "%c", C1_DCS);
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
"%c", C1_DCS);
|
||||
if(cur >= vt->tmpbuffer_len)
|
||||
return;
|
||||
vterm_push_output_bytes(vt, vt->tmpbuffer, cur);
|
||||
|
||||
va_start(args, fmt);
|
||||
vterm_push_output_vsprintf(vt, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
vterm_push_output_sprintf_ctrl(vt, C1_ST, "");
|
||||
|
||||
if(outbuffer_is_full(vt))
|
||||
vt->outbuffer_cur = orig_cur;
|
||||
if(!vt->mode.ctrl8bit)
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
ESC_S "%c", C1_ST - 0x40);
|
||||
else
|
||||
cur = SNPRINTF(vt->tmpbuffer, vt->tmpbuffer_len,
|
||||
"%c", C1_ST);
|
||||
if(cur >= vt->tmpbuffer_len)
|
||||
return;
|
||||
vterm_push_output_bytes(vt, vt->tmpbuffer, cur);
|
||||
}
|
||||
|
||||
size_t vterm_output_get_buffer_size(const VTerm *vt)
|
||||
|
@@ -211,6 +211,9 @@ struct VTerm
|
||||
size_t outbuffer_len;
|
||||
size_t outbuffer_cur;
|
||||
|
||||
char *tmpbuffer;
|
||||
size_t tmpbuffer_len;
|
||||
|
||||
VTermState *state;
|
||||
VTermScreen *screen;
|
||||
|
||||
|
@@ -111,6 +111,18 @@ PUSH "\e[20h"
|
||||
INKEY 0 Enter
|
||||
output "\x0d\x0a"
|
||||
|
||||
!Unmodified F1 is SS3 P
|
||||
INKEY 0 F1
|
||||
output "\eOP"
|
||||
|
||||
!Modified F1 is CSI P
|
||||
INKEY S F1
|
||||
output "\e[1;2P"
|
||||
INKEY A F1
|
||||
output "\e[1;3P"
|
||||
INKEY C F1
|
||||
output "\e[1;5P"
|
||||
|
||||
!Keypad in DECKPNM
|
||||
INKEY 0 KP0
|
||||
output "0"
|
||||
|
@@ -59,4 +59,4 @@ PUSH "\e F"
|
||||
|
||||
!Truncation on attempted buffer overflow
|
||||
PUSH "\e[6n" x 30
|
||||
output "\e[10;10R" x 24
|
||||
output "\e[10;10R" x 25
|
||||
|
@@ -47,6 +47,7 @@ static VTermKey strp_key(char *str)
|
||||
{ "Tab", VTERM_KEY_TAB },
|
||||
{ "Enter", VTERM_KEY_ENTER },
|
||||
{ "KP0", VTERM_KEY_KP_0 },
|
||||
{ "F1", VTERM_KEY_FUNCTION(1) },
|
||||
{ NULL, VTERM_KEY_NONE },
|
||||
};
|
||||
int i;
|
||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
783,
|
||||
/**/
|
||||
782,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user