forked from aniani/vim
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:
@@ -2226,6 +2226,7 @@ assert_true({actual} [, {msg}]) Number assert {actual} is true
|
|||||||
asin({expr}) Float arc sine of {expr}
|
asin({expr}) Float arc sine of {expr}
|
||||||
atan({expr}) Float arc tangent of {expr}
|
atan({expr}) Float arc tangent of {expr}
|
||||||
atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
|
atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2}
|
||||||
|
balloon_gettext() String current text in the balloon
|
||||||
balloon_show({expr}) none show {expr} inside the balloon
|
balloon_show({expr}) none show {expr} inside the balloon
|
||||||
balloon_split({msg}) List split {msg} as used for a balloon
|
balloon_split({msg}) List split {msg} as used for a balloon
|
||||||
browse({save}, {title}, {initdir}, {default})
|
browse({save}, {title}, {initdir}, {default})
|
||||||
@@ -3007,15 +3008,20 @@ atan2({expr1}, {expr2}) *atan2()*
|
|||||||
< 2.356194
|
< 2.356194
|
||||||
{only available when compiled with the |+float| feature}
|
{only available when compiled with the |+float| feature}
|
||||||
|
|
||||||
|
balloon_gettext() *balloon_gettext()*
|
||||||
|
Return the current text in the balloon. Only for the string,
|
||||||
|
not used for the List.
|
||||||
|
|
||||||
balloon_show({expr}) *balloon_show()*
|
balloon_show({expr}) *balloon_show()*
|
||||||
Show {expr} inside the balloon. For the GUI {expr} is used as
|
Show {expr} inside the balloon. For the GUI {expr} is used as
|
||||||
a string. For a terminal {expr} can be a list, which contains
|
a string. For a terminal {expr} can be a list, which contains
|
||||||
the lines of the balloon. If {expr} is not a list it will be
|
the lines of the balloon. If {expr} is not a list it will be
|
||||||
split with |balloon_split()|.
|
split with |balloon_split()|.
|
||||||
|
If {expr} is an empty string any existing balloon is removed.
|
||||||
|
|
||||||
Example: >
|
Example: >
|
||||||
func GetBalloonContent()
|
func GetBalloonContent()
|
||||||
" initiate getting the content
|
" ... initiate getting the content
|
||||||
return ''
|
return ''
|
||||||
endfunc
|
endfunc
|
||||||
set balloonexpr=GetBalloonContent()
|
set balloonexpr=GetBalloonContent()
|
||||||
@@ -4229,6 +4235,8 @@ feedkeys({string} [, {mode}]) *feedkeys()*
|
|||||||
and "\..." notation |expr-quote|. For example,
|
and "\..." notation |expr-quote|. For example,
|
||||||
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
|
feedkeys("\<CR>") simulates pressing of the <Enter> key. But
|
||||||
feedkeys('\<CR>') pushes 5 characters.
|
feedkeys('\<CR>') pushes 5 characters.
|
||||||
|
A special code that might be useful is <Ignore>, it exits the
|
||||||
|
wait for a character without doing anything. *<Ignore>*
|
||||||
|
|
||||||
{mode} is a String, which can contain these character flags:
|
{mode} is a String, which can contain these character flags:
|
||||||
'm' Remap keys. This is default. If {mode} is absent,
|
'm' Remap keys. This is default. If {mode} is absent,
|
||||||
|
@@ -75,7 +75,7 @@ typedef struct BalloonEvalStruct
|
|||||||
#ifdef FEAT_VARTABS
|
#ifdef FEAT_VARTABS
|
||||||
int *vts; // vartabstop setting for this buffer
|
int *vts; // vartabstop setting for this buffer
|
||||||
#endif
|
#endif
|
||||||
char_u *msg;
|
char_u *msg; // allocated: current text
|
||||||
#ifdef FEAT_GUI_MSWIN
|
#ifdef FEAT_GUI_MSWIN
|
||||||
void *tofree;
|
void *tofree;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -63,6 +63,7 @@ static void f_atan(typval_T *argvars, typval_T *rettv);
|
|||||||
static void f_atan2(typval_T *argvars, typval_T *rettv);
|
static void f_atan2(typval_T *argvars, typval_T *rettv);
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_BEVAL
|
#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);
|
static void f_balloon_show(typval_T *argvars, typval_T *rettv);
|
||||||
# if defined(FEAT_BEVAL_TERM)
|
# if defined(FEAT_BEVAL_TERM)
|
||||||
static void f_balloon_split(typval_T *argvars, typval_T *rettv);
|
static void f_balloon_split(typval_T *argvars, typval_T *rettv);
|
||||||
@@ -552,6 +553,7 @@ static struct fst
|
|||||||
{"atan2", 2, 2, f_atan2},
|
{"atan2", 2, 2, f_atan2},
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_BEVAL
|
#ifdef FEAT_BEVAL
|
||||||
|
{"balloon_gettext", 0, 0, f_balloon_gettext},
|
||||||
{"balloon_show", 1, 1, f_balloon_show},
|
{"balloon_show", 1, 1, f_balloon_show},
|
||||||
# if defined(FEAT_BEVAL_TERM)
|
# if defined(FEAT_BEVAL_TERM)
|
||||||
{"balloon_split", 1, 1, f_balloon_split},
|
{"balloon_split", 1, 1, f_balloon_split},
|
||||||
@@ -1763,6 +1765,19 @@ f_atan2(typval_T *argvars, typval_T *rettv)
|
|||||||
* "balloon_show()" function
|
* "balloon_show()" function
|
||||||
*/
|
*/
|
||||||
#ifdef FEAT_BEVAL
|
#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
|
static void
|
||||||
f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
|
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
|
&& !gui.in_use
|
||||||
# endif
|
# 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
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -117,7 +117,8 @@ gui_mch_create_beval_area(
|
|||||||
beval->appContext = XtWidgetToApplicationContext((Widget)target);
|
beval->appContext = XtWidgetToApplicationContext((Widget)target);
|
||||||
#endif
|
#endif
|
||||||
beval->showState = ShS_NEUTRAL;
|
beval->showState = ShS_NEUTRAL;
|
||||||
beval->msg = mesg;
|
vim_free(beval->msg);
|
||||||
|
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
|
||||||
beval->msgCB = mesgCB;
|
beval->msgCB = mesgCB;
|
||||||
beval->clientData = clientData;
|
beval->clientData = clientData;
|
||||||
|
|
||||||
@@ -208,8 +209,9 @@ gui_mch_currently_showing_beval(void)
|
|||||||
void
|
void
|
||||||
gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
|
gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
|
||||||
{
|
{
|
||||||
beval->msg = mesg;
|
vim_free(beval->msg);
|
||||||
if (mesg != NULL)
|
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
|
||||||
|
if (beval->msg != NULL)
|
||||||
drawBalloon(beval);
|
drawBalloon(beval);
|
||||||
else
|
else
|
||||||
undrawBalloon(beval);
|
undrawBalloon(beval);
|
||||||
@@ -225,6 +227,7 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
|
|||||||
void
|
void
|
||||||
gui_mch_unpost_balloon(BalloonEval *beval)
|
gui_mch_unpost_balloon(BalloonEval *beval)
|
||||||
{
|
{
|
||||||
|
VIM_CLEAR(beval->msg);
|
||||||
undrawBalloon(beval);
|
undrawBalloon(beval);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -975,6 +978,7 @@ drawBalloon(BalloonEval *beval)
|
|||||||
gtk_widget_show(beval->balloonShell);
|
gtk_widget_show(beval->balloonShell);
|
||||||
|
|
||||||
beval->showState = ShS_SHOWING;
|
beval->showState = ShS_SHOWING;
|
||||||
|
gui_mch_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8506,6 +8506,15 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
|
|||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
|
|
||||||
|
vim_free(beval->msg);
|
||||||
|
beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
|
||||||
|
if (beval->msg == NULL)
|
||||||
|
{
|
||||||
|
delete_tooltip(beval);
|
||||||
|
beval->showState = ShS_NEUTRAL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TRACE0("gui_mch_post_balloon {{{");
|
// TRACE0("gui_mch_post_balloon {{{");
|
||||||
if (beval->showState == ShS_SHOWING)
|
if (beval->showState == ShS_SHOWING)
|
||||||
return;
|
return;
|
||||||
|
@@ -1154,7 +1154,10 @@ ui_post_balloon(char_u *mesg, list_T *list)
|
|||||||
ui_remove_balloon();
|
ui_remove_balloon();
|
||||||
|
|
||||||
if (mesg == NULL && list == NULL)
|
if (mesg == NULL && list == NULL)
|
||||||
|
{
|
||||||
|
pum_undisplay();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (list != NULL)
|
if (list != NULL)
|
||||||
{
|
{
|
||||||
listitem_T *li;
|
listitem_T *li;
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
" Tests for 'balloonevalterm'.
|
" Tests for 'balloonevalterm'.
|
||||||
|
|
||||||
if !has('balloon_eval_term') || has('gui_running')
|
" Tests that only work in the terminal.
|
||||||
finish
|
if has('balloon_eval_term') && !has('gui_running')
|
||||||
endif
|
|
||||||
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
if !CanRunVimInTerminal()
|
if !CanRunVimInTerminal()
|
||||||
@@ -53,3 +52,24 @@ func Test_balloon_eval_term_visual()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('XTest_beval_visual')
|
call delete('XTest_beval_visual')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Tests that only work in the GUI
|
||||||
|
if has('gui_running')
|
||||||
|
|
||||||
|
func Test_balloon_show_gui()
|
||||||
|
let msg = 'this this this this'
|
||||||
|
call balloon_show(msg)
|
||||||
|
call assert_equal(msg, balloon_gettext())
|
||||||
|
sleep 10m
|
||||||
|
call balloon_show('')
|
||||||
|
|
||||||
|
let msg = 'that that'
|
||||||
|
call balloon_show(msg)
|
||||||
|
call assert_equal(msg, balloon_gettext())
|
||||||
|
sleep 10m
|
||||||
|
call balloon_show('')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
endif
|
||||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1303,
|
||||||
/**/
|
/**/
|
||||||
1302,
|
1302,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user