summaryrefslogtreecommitdiff
path: root/src/gui_beval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-11-18 18:52:04 +0100
committerBram Moolenaar <Bram@vim.org>2017-11-18 18:52:04 +0100
commit51b0f3701ecb440aa72ab6017c1df6940c0e0f6f (patch)
tree9cfd3546d8e52be2b1425dcc65095f8e650eadde /src/gui_beval.c
parent234d16286a2733adedef56784c17415ae169b9ad (diff)
downloadvim-git-51b0f3701ecb440aa72ab6017c1df6940c0e0f6f.tar.gz
patch 8.0.1309: cannot use 'balloonexpr' in a terminalv8.0.1309
Problem: Cannot use 'balloonexpr' in a terminal. Solution: Add 'balloonevalterm' and add code to handle mouse movements in a terminal. Initial implementation for Unix with GUI.
Diffstat (limited to 'src/gui_beval.c')
-rw-r--r--src/gui_beval.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/gui_beval.c b/src/gui_beval.c
index 1c01ecc84..ada048c62 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -35,7 +35,11 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
/* Don't do anything when 'ballooneval' is off, messages scrolled the
* windows up or we have no beval area. */
- if (!p_beval || balloonEval == NULL || msg_scrolled > 0)
+ if (!((gui.in_use && p_beval)
+# ifdef FEAT_BEVALTERM
+ || (!gui.in_use && p_bevalterm)
+# endif
+ ) || beval == NULL || msg_scrolled > 0)
return;
/* Don't do this recursively. Happens when the expression evaluation
@@ -45,7 +49,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
recursive = TRUE;
#ifdef FEAT_EVAL
- if (get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK)
+ if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
{
bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
: wp->w_buffer->b_p_bexpr;
@@ -96,7 +100,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
if (result != NULL && result[0] != NUL)
{
- gui_mch_post_balloon(beval, result);
+ post_balloon(beval, result);
recursive = FALSE;
return;
}
@@ -335,8 +339,18 @@ get_beval_info(
linenr_T lnum;
*textp = NULL;
- row = Y_2_ROW(beval->y);
- col = X_2_COL(beval->x);
+# ifdef FEAT_BEVALTERM
+ if (!gui.in_use)
+ {
+ row = mouse_row;
+ col = mouse_col;
+ }
+ else
+# endif
+ {
+ row = Y_2_ROW(beval->y);
+ col = X_2_COL(beval->x);
+ }
wp = mouse_find_win(&row, &col);
if (wp != NULL && row < wp->w_height && col < wp->w_width)
{
@@ -421,6 +435,20 @@ get_beval_info(
return FAIL;
}
+/*
+ * Show a balloon with "mesg".
+ */
+ void
+post_balloon(BalloonEval *beval, char_u *mesg)
+{
+# ifdef FEAT_BEVALTERM
+ if (!gui.in_use)
+ ui_post_balloon(mesg);
+ else
+# endif
+ gui_mch_post_balloon(beval, mesg);
+}
+
# if !defined(FEAT_GUI_W32) || defined(PROTO)
/*
@@ -451,10 +479,6 @@ gui_mch_unpost_balloon(BalloonEval *beval)
#endif
#ifdef FEAT_GUI_GTK
-/*
- * We can unconditionally use ANSI-style prototypes here since
- * GTK+ requires an ANSI C compiler anyway.
- */
static void
addEventHandler(GtkWidget *target, BalloonEval *beval)
{