From 51b0f3701ecb440aa72ab6017c1df6940c0e0f6f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 18 Nov 2017 18:52:04 +0100 Subject: patch 8.0.1309: cannot use 'balloonexpr' in a terminal 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. --- src/gui_beval.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'src/gui_beval.c') diff --git a/src/gui_beval.c b/src/gui_beval.c index 1c01ecc84a..ada048c62c 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) { -- cgit v1.2.3