summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ca412f7549..eaefccf620 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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},
@@ -1764,6 +1766,19 @@ f_atan2(typval_T *argvars, typval_T *rettv)
*/
#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)
{
if (balloonEval != NULL)
@@ -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);
+ }
}
}