diff options
author | Christian Clason <c.clason@uni-graz.at> | 2022-09-06 22:41:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 22:41:37 +0200 |
commit | 694ac269468fce8a5e02f0aceb46dbee5528a9d7 (patch) | |
tree | 3fb4fdbb498afadd03dce347a6e90090ac1ad533 | |
parent | 74a8b5982a27cdccc6505343a9feeba1b3e74e31 (diff) | |
parent | b76e33b5989dcdbc48cdb6f099c9c0c917efa610 (diff) | |
download | rneovim-694ac269468fce8a5e02f0aceb46dbee5528a9d7.tar.gz rneovim-694ac269468fce8a5e02f0aceb46dbee5528a9d7.tar.bz2 rneovim-694ac269468fce8a5e02f0aceb46dbee5528a9d7.zip |
Merge pull request #17329 from cryptomilk/asn-vterm-0-2
build(deps): bump libvterm to 0.3-RC1
-rw-r--r-- | cmake.deps/CMakeLists.txt | 4 | ||||
-rw-r--r-- | cmake.deps/cmake/BuildLibvterm.cmake | 6 | ||||
-rw-r--r-- | cmake.deps/patches/libvterm-Remove-VLAs-for-MSVC.patch | 50 | ||||
-rw-r--r-- | src/nvim/terminal.c | 40 | ||||
-rw-r--r-- | test/functional/terminal/altscreen_spec.lua | 10 |
5 files changed, 41 insertions, 69 deletions
diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt index 1e99b4c057..885aa9c64c 100644 --- a/cmake.deps/CMakeLists.txt +++ b/cmake.deps/CMakeLists.txt @@ -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) diff --git a/cmake.deps/cmake/BuildLibvterm.cmake b/cmake.deps/cmake/BuildLibvterm.cmake index 1f7088cdb7..10ddbb47ba 100644 --- a/cmake.deps/cmake/BuildLibvterm.cmake +++ b/cmake.deps/cmake/BuildLibvterm.cmake @@ -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 diff --git a/cmake.deps/patches/libvterm-Remove-VLAs-for-MSVC.patch b/cmake.deps/patches/libvterm-Remove-VLAs-for-MSVC.patch deleted file mode 100644 index e999c0fa9b..0000000000 --- a/cmake.deps/patches/libvterm-Remove-VLAs-for-MSVC.patch +++ /dev/null @@ -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 - diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 90966bcfad..744579217b 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -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; } diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua index 155a156d15..e4e1aa5fa2 100644 --- a/test/functional/terminal/altscreen_spec.lua +++ b/test/functional/terminal/altscreen_spec.lua @@ -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) |