From 0838ee3b3b77f0a6945b57bca87315acf650479f Mon Sep 17 00:00:00 2001 From: jixiuf Date: Tue, 30 Aug 2022 11:17:40 +0800 Subject: check libvterm version,make it compile with libvterm<0.2 --- CMakeLists.txt | 6 ++++++ vterm-module.c | 7 +++++-- vterm-module.h | 4 ++-- vterm.el | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0c0851..d909076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,12 @@ if (USE_SYSTEM_LIBVTERM) # add_compile_definitions(VTermStringFragmentNotExists) add_definitions(-DVTermStringFragmentNotExists) endif() + execute_process(COMMAND grep -c "VTermSelectionMask" "${LIBVTERM_INCLUDE_DIR}/vterm.h" OUTPUT_VARIABLE VTermSelectionMaskExists) + if (${VTermSelectionMaskExists} EQUAL "0") +# add_compile_definitions(VTermStringFragmentNotExists) + add_definitions(-DVTermSelectionMaskNotExists) + endif() + else() message(STATUS "System libvterm not found: libvterm will be downloaded and compiled as part of the build process") endif() diff --git a/vterm-module.c b/vterm-module.c index 8fcf8ed..a41188a 100644 --- a/vterm-module.c +++ b/vterm-module.c @@ -1153,7 +1153,7 @@ static VTermStateFallbacks parser_callbacks = { .osc = &osc_callback, .dcs = NULL, }; - +#ifndef VTermSelectionMaskNotExists static int set_selection(VTermSelectionMask mask, VTermStringFragment frag, void *user) { Term *term = (Term *)user; @@ -1183,6 +1183,7 @@ static VTermSelectionCallbacks selection_callbacks = { .set = &set_selection, .query = NULL, }; +#endif /* VTermSelectionMaskNotExists */ #endif @@ -1206,9 +1207,11 @@ emacs_value Fvterm_new(emacs_env *env, ptrdiff_t nargs, emacs_value args[], VTermState *state = vterm_obtain_state(term->vt); vterm_state_set_unrecognised_fallbacks(state, &parser_callbacks, term); + +#ifndef VTermSelectionMaskNotExists vterm_state_set_selection_callbacks(state, &selection_callbacks, term, term->selection_buf, SELECTION_BUF_LEN); - +#endif vterm_state_set_bold_highbright(state, set_bold_hightbright); vterm_screen_reset(term->vts, 1); diff --git a/vterm-module.h b/vterm-module.h index dca092b..e8bb01b 100644 --- a/vterm-module.h +++ b/vterm-module.h @@ -100,9 +100,9 @@ typedef struct Term { /* c , p , q , s , 0 , 1 , 2 , 3 , 4 , 5 , 6 , and 7 */ /* clipboard, primary, secondary, select, or cut buffers 0 through 7 */ - VTermSelectionMask selection_mask; + int selection_mask; /* see VTermSelectionMask in vterm.h */ char *selection_data; - char selection_buf[SELECTION_BUF_LEN]; /* buf for */ + char selection_buf[SELECTION_BUF_LEN]; /* the size of dirs almost = window height, value = directory of that line */ LineInfo **lines; diff --git a/vterm.el b/vterm.el index dd4c5a4..38d85b7 100644 --- a/vterm.el +++ b/vterm.el @@ -305,7 +305,7 @@ demo: \\='(\"env1=v1\" \"env2=v2\")" (defcustom vterm-enable-manipulate-selection-data-by-osc52 nil - "Support OSC 52 MANIPULATE SELECTION DATA. + "Support OSC 52 MANIPULATE SELECTION DATA(libvterm 0.2 is needed). Support copy text to Emacs kill ring and system clipboard by using OSC 52. For example: send base64 encoded \\='foo\\=' to kill ring: echo -en \\='\\e]52;c;Zm9v\\a\\=', -- cgit v1.0