Merge pull request #17329 from cryptomilk/asn-vterm-0-2

build(deps): bump libvterm to 0.3-RC1
This commit is contained in:
Christian Clason 2022-09-06 22:41:37 +02:00 committed by GitHub
commit 694ac26946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 69 deletions

View File

@ -173,8 +173,8 @@ set(UNIBILIUM_SHA256 29815283c654277ef77a3adcc8840db79ddbb20a0f0b0c8f648bd8cd49a
set(LIBTERMKEY_URL https://www.leonerd.org.uk/code/libtermkey/libtermkey-0.22.tar.gz)
set(LIBTERMKEY_SHA256 6945bd3c4aaa83da83d80a045c5563da4edd7d0374c62c0d35aec09eb3014600)
set(LIBVTERM_URL https://www.leonerd.org.uk/code/libvterm/libvterm-0.1.4.tar.gz)
set(LIBVTERM_SHA256 bc70349e95559c667672fc8c55b9527d9db9ada0fb80a3beda533418d782d3dd)
set(LIBVTERM_URL https://www.leonerd.org.uk/code/libvterm/libvterm-0.3-RC1.tar.gz)
set(LIBVTERM_SHA256 441d1c372b84a0df12525100ab06c0366260fb4f6252abd1665ee4fa571b5134)
set(LUV_VERSION 1.44.2-0)
set(LUV_URL https://github.com/luvit/luv/archive/1.44.2-0.tar.gz)

View File

@ -32,12 +32,6 @@ function(BuildLibvterm)
endfunction()
if(WIN32)
if(MSVC)
set(LIBVTERM_PATCH_COMMAND
${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm init
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm apply --ignore-whitespace
${CMAKE_CURRENT_SOURCE_DIR}/patches/libvterm-Remove-VLAs-for-MSVC.patch)
endif()
set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt

View File

@ -1,50 +0,0 @@
From eb386b1d82f7d07363c9133b7aa06902ccd555fe Mon Sep 17 00:00:00 2001
Date: Tue, 27 Feb 2018 17:54:20 -0600
Subject: [PATCH] Remove VLAs for MSVC
VLAs are replaced with calls to _alloca() because MSVC does not support them.
---
src/state.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/state.c b/src/state.c
index 84299df..f9aabb3 100644
--- a/src/state.c
+++ b/src/state.c
@@ -1,5 +1,6 @@
#include "vterm_internal.h"
+#include <malloc.h>
#include <stdio.h>
#include <string.h>
@@ -236,7 +237,7 @@ static int on_text(const char bytes[], size_t len, void *user)
VTermPos oldpos = state->pos;
// We'll have at most len codepoints
- uint32_t codepoints[len];
+ uint32_t* codepoints = _alloca(len * sizeof(uint32_t));
int npoints = 0;
size_t eaten = 0;
@@ -313,7 +314,7 @@ static int on_text(const char bytes[], size_t len, void *user)
int width = 0;
- uint32_t chars[glyph_ends - glyph_starts + 1];
+ uint32_t* chars = _alloca((glyph_ends - glyph_starts + 1) * sizeof(uint32_t));
for( ; i < glyph_ends; i++) {
chars[i - glyph_starts] = codepoints[i];
@@ -512,7 +513,7 @@ static int settermprop_int(VTermState *state, VTermProp prop, int v)
static int settermprop_string(VTermState *state, VTermProp prop, const char *str, size_t len)
{
- char strvalue[len+1];
+ char* strvalue = _alloca(len+1);
strncpy(strvalue, str, len);
strvalue[len] = 0;
--
2.16.1.windows.4

View File

@ -120,6 +120,10 @@ struct terminal {
// window height has increased) and must be deleted from the terminal buffer
int sb_pending;
char *title; // VTermStringFragment buffer
size_t title_len; // number of rows pushed to sb_buffer
size_t title_size; // sb_buffer size
// buf_T instance that acts as a "drawing surface" for libvterm
// we can't store a direct reference to the buffer because the
// refresh_timer_cb may be called after the buffer was freed, and there's
@ -230,7 +234,7 @@ Terminal *terminal_open(buf_T *buf, TerminalOptions opts)
set_option_value("wrap", false, NULL, OPT_LOCAL);
set_option_value("list", false, NULL, OPT_LOCAL);
if (buf->b_ffname != NULL) {
buf_set_term_title(buf, buf->b_ffname);
buf_set_term_title(buf, buf->b_ffname, strlen((char *)buf->b_ffname));
}
RESET_BINDING(curwin);
// Reset cursor in current window.
@ -636,6 +640,7 @@ void terminal_destroy(Terminal **termpp)
xfree(term->sb_buffer[i]);
}
xfree(term->sb_buffer);
xfree(term->title);
vterm_free(term->vt);
xfree(term);
*termpp = NULL; // coverity[dead-store]
@ -858,13 +863,13 @@ static int term_movecursor(VTermPos new, VTermPos old, int visible, void *data)
return 1;
}
static void buf_set_term_title(buf_T *buf, char *title)
static void buf_set_term_title(buf_T *buf, const char *title, size_t len)
FUNC_ATTR_NONNULL_ALL
{
Error err = ERROR_INIT;
dict_set_var(buf->b_vars,
STATIC_CSTR_AS_STRING("term_title"),
STRING_OBJ(cstr_as_string(title)),
STRING_OBJ(((String){ .data = (char *)title, .size = len })),
false,
false,
&err);
@ -887,7 +892,34 @@ static int term_settermprop(VTermProp prop, VTermValue *val, void *data)
case VTERM_PROP_TITLE: {
buf_T *buf = handle_get_buffer(term->buf_handle);
buf_set_term_title(buf, val->string);
#if VTERM_VERSION_MAJOR > 0 || (VTERM_VERSION_MAJOR == 0 && VTERM_VERSION_MINOR >= 2)
VTermStringFragment frag = val->string;
if (frag.initial && frag.final) {
buf_set_term_title(buf, frag.str, frag.len);
break;
}
if (frag.initial) {
term->title_len = 0;
term->title_size = MAX(frag.len, 1024);
term->title = xmalloc(sizeof(char *) * term->title_size);
} else if (term->title_len + frag.len > term->title_size) {
term->title_size *= 2;
term->title = xrealloc(term->title, sizeof(char *) * term->title_size);
}
memcpy(term->title + term->title_len, frag.str, frag.len);
term->title_len += frag.len;
if (frag.final) {
buf_set_term_title(buf, term->title, term->title_len);
xfree(term->title);
term->title = NULL;
}
#else
buf_set_term_title(buf, val->string, strlen(val->string));
#endif
break;
}

View File

@ -126,13 +126,13 @@ describe(':terminal altscreen', function()
wait_removal()
feed('<c-\\><c-n>4k')
screen:expect([[
^line3 |
^ |
|
|
rows: 4, cols: 50 |
|
]])
eq(8, curbuf('line_count'))
eq(9, curbuf('line_count'))
end)
describe('and after exit', function()
@ -142,15 +142,11 @@ describe(':terminal altscreen', function()
end)
it('restore buffer state', function()
-- FIXME(tarruda): Note that the last line was lost after restoring the
-- screen. This is a libvterm bug: When the main screen is restored it
-- seems to "cut" lines that would have been left below the new visible
-- screen.
screen:expect([[
line4 |
line5 |
line6 |
line7 |
line8 |
{3:-- TERMINAL --} |
]])
end)