diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-11-19 19:56:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-11-19 19:56:27 +0100 |
commit | 246fe03d154c09070d5b7365b7f61716c4e0ddd4 (patch) | |
tree | 1d0ad5929d17f1af24ac22817bd9fe6c0d5d84f2 /src/evalfunc.c | |
parent | e518226713784e628ae7ee077f1b66cb12b9ffd9 (diff) |
patch 8.0.1318: terminal balloon only shows one linev8.0.1318
Problem: Terminal balloon only shows one line.
Solution: Split into several lines in a clever way. Add balloon_split().
Make balloon_show() accept a list in the terminal.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index c03e214165..77a4fc2c05 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -61,6 +61,7 @@ static void f_atan2(typval_T *argvars, typval_T *rettv); #endif #ifdef FEAT_BEVAL static void f_balloon_show(typval_T *argvars, typval_T *rettv); +static void f_balloon_split(typval_T *argvars, typval_T *rettv); #endif static void f_browse(typval_T *argvars, typval_T *rettv); static void f_browsedir(typval_T *argvars, typval_T *rettv); @@ -494,6 +495,7 @@ static struct fst #endif #ifdef FEAT_BEVAL {"balloon_show", 1, 1, f_balloon_show}, + {"balloon_split", 1, 1, f_balloon_split}, #endif {"browse", 4, 4, f_browse}, {"browsedir", 2, 2, f_browsedir}, @@ -1410,7 +1412,37 @@ f_atan2(typval_T *argvars, typval_T *rettv) f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED) { if (balloonEval != NULL) - post_balloon(balloonEval, get_tv_string_chk(&argvars[0])); + { + if (argvars[0].v_type == VAR_LIST +# ifdef FEAT_GUI + && !gui.in_use +# endif + ) + post_balloon(balloonEval, NULL, argvars[0].vval.v_list); + else + post_balloon(balloonEval, get_tv_string_chk(&argvars[0]), NULL); + } +} + + static void +f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED) +{ + if (rettv_list_alloc(rettv) == OK) + { + char_u *msg = get_tv_string_chk(&argvars[0]); + + if (msg != NULL) + { + pumitem_T *array; + int size = split_message(msg, &array); + int i; + + /* Skip the first and last item, they are always empty. */ + for (i = 1; i < size - 1; ++i) + list_append_string(rettv->vval.v_list, array[i].pum_text, -1); + vim_free(array); + } + } } #endif |