0
0
mirror of https://github.com/vim/vim.git synced 2025-10-13 06:54:15 -04:00

patch 8.1.1303: not possible to hide a balloon

Problem:    Not possible to hide a balloon.
Solution:   Hide the balloon when balloon_show() is called with an empty
            string or list.  Add balloon_gettext().
This commit is contained in:
Bram Moolenaar
2019-05-09 13:50:16 +02:00
parent 06bd824869
commit be0a2597ae
8 changed files with 83 additions and 10 deletions

View File

@@ -63,6 +63,7 @@ static void f_atan(typval_T *argvars, typval_T *rettv);
static void f_atan2(typval_T *argvars, typval_T *rettv);
#endif
#ifdef FEAT_BEVAL
static void f_balloon_gettext(typval_T *argvars, typval_T *rettv);
static void f_balloon_show(typval_T *argvars, typval_T *rettv);
# if defined(FEAT_BEVAL_TERM)
static void f_balloon_split(typval_T *argvars, typval_T *rettv);
@@ -552,6 +553,7 @@ static struct fst
{"atan2", 2, 2, f_atan2},
#endif
#ifdef FEAT_BEVAL
{"balloon_gettext", 0, 0, f_balloon_gettext},
{"balloon_show", 1, 1, f_balloon_show},
# if defined(FEAT_BEVAL_TERM)
{"balloon_split", 1, 1, f_balloon_split},
@@ -1763,6 +1765,19 @@ f_atan2(typval_T *argvars, typval_T *rettv)
* "balloon_show()" function
*/
#ifdef FEAT_BEVAL
static void
f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
if (balloonEval != NULL)
{
if (balloonEval->msg == NULL)
rettv->vval.v_string = NULL;
else
rettv->vval.v_string = vim_strsave(balloonEval->msg);
}
}
static void
f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
{
@@ -1773,9 +1788,21 @@ f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
&& !gui.in_use
# endif
)
post_balloon(balloonEval, NULL, argvars[0].vval.v_list);
{
list_T *l = argvars[0].vval.v_list;
// empty list removes the balloon
post_balloon(balloonEval, NULL,
l == NULL || l->lv_len == 0 ? NULL : l);
}
else
post_balloon(balloonEval, tv_get_string_chk(&argvars[0]), NULL);
{
char_u *mesg = tv_get_string_chk(&argvars[0]);
if (mesg != NULL)
// empty string removes the balloon
post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
}
}
}