Skip to content

Commit fca66e9

Browse files
committed
Enable reflow when supported
term reflow is supported since libvterm v0.3 1. echo a long line of text 2. reduce the window width to be shorter than the line of the text 3. increase the window width to the original size old behavior: the text is truncated and not recovered new behavior: the text is reflowed
1 parent 94e2b0b commit fca66e9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ if (USE_SYSTEM_LIBVTERM)
5151
if (${VTermSBClearExists} EQUAL "0")
5252
add_definitions(-DVTermSBClearNotExists)
5353
endif()
54+
execute_process(COMMAND grep -c "vterm_screen_enable_reflow" "${LIBVTERM_INCLUDE_DIR}/vterm.h" OUTPUT_VARIABLE VTermEnableReflowExists)
55+
if (${VTermEnableReflowExists} EQUAL "0")
56+
message(WARNING "System libvterm too old, reflow not supported")
57+
add_definitions(-DVTermEnableReflowNotExists)
58+
endif()
5459
else()
5560
message(STATUS "System libvterm not found: libvterm will be downloaded and compiled as part of the build process")
5661
endif()

vterm-module.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ static int term_sb_push(int cols, const VTermScreenCell *cells, void *data) {
6969
sbrow->info = term->lines[0];
7070
memmove(term->lines, term->lines + 1,
7171
sizeof(term->lines[0]) * (term->lines_len - 1));
72-
if (term->resizing) {
72+
if (term->resizing &&
73+
term->height_resize < 0 &&
74+
term->lines_len + term->height_resize > term->height) {
7375
/* pushed by window height decr */
7476
if (term->lines[term->lines_len - 1] != NULL) {
7577
/* do not need free here ,it is reused ,we just need set null */
@@ -1242,6 +1244,9 @@ emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs, emacs_value args[],
12421244
vterm_screen_set_callbacks(term->vts, &vterm_screen_callbacks, term);
12431245
vterm_screen_set_damage_merge(term->vts, VTERM_DAMAGE_SCROLL);
12441246
vterm_screen_enable_altscreen(term->vts, true);
1247+
#ifndef VTermEnableReflowNotExists
1248+
vterm_screen_enable_reflow(term->vts, true);
1249+
#endif
12451250
term->sb_size = MIN(SB_MAX, sb_size);
12461251
term->sb_current = 0;
12471252
term->sb_pending = 0;

0 commit comments

Comments
 (0)