comparison src/gui_beval.c @ 12865:ebb4f6c93598 v8.0.1309

patch 8.0.1309: cannot use 'balloonexpr' in a terminal commit https://github.com/vim/vim/commit/51b0f3701ecb440aa72ab6017c1df6940c0e0f6f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 18 18:52:04 2017 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Nov 2017 19:00:06 +0100
parents 972ea22c946f
children 1a450ce6980c
comparison
equal deleted inserted replaced
12864:e98532b79dba 12865:ebb4f6c93598
33 #endif 33 #endif
34 static int recursive = FALSE; 34 static int recursive = FALSE;
35 35
36 /* Don't do anything when 'ballooneval' is off, messages scrolled the 36 /* Don't do anything when 'ballooneval' is off, messages scrolled the
37 * windows up or we have no beval area. */ 37 * windows up or we have no beval area. */
38 if (!p_beval || balloonEval == NULL || msg_scrolled > 0) 38 if (!((gui.in_use && p_beval)
39 # ifdef FEAT_BEVALTERM
40 || (!gui.in_use && p_bevalterm)
41 # endif
42 ) || beval == NULL || msg_scrolled > 0)
39 return; 43 return;
40 44
41 /* Don't do this recursively. Happens when the expression evaluation 45 /* Don't do this recursively. Happens when the expression evaluation
42 * takes a long time and invokes something that checks for CTRL-C typed. */ 46 * takes a long time and invokes something that checks for CTRL-C typed. */
43 if (recursive) 47 if (recursive)
44 return; 48 return;
45 recursive = TRUE; 49 recursive = TRUE;
46 50
47 #ifdef FEAT_EVAL 51 #ifdef FEAT_EVAL
48 if (get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK) 52 if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
49 { 53 {
50 bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr 54 bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
51 : wp->w_buffer->b_p_bexpr; 55 : wp->w_buffer->b_p_bexpr;
52 if (*bexpr != NUL) 56 if (*bexpr != NUL)
53 { 57 {
94 --textlock; 98 --textlock;
95 99
96 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1); 100 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
97 if (result != NULL && result[0] != NUL) 101 if (result != NULL && result[0] != NUL)
98 { 102 {
99 gui_mch_post_balloon(beval, result); 103 post_balloon(beval, result);
100 recursive = FALSE; 104 recursive = FALSE;
101 return; 105 return;
102 } 106 }
103 } 107 }
104 } 108 }
333 int row, col; 337 int row, col;
334 char_u *lbuf; 338 char_u *lbuf;
335 linenr_T lnum; 339 linenr_T lnum;
336 340
337 *textp = NULL; 341 *textp = NULL;
338 row = Y_2_ROW(beval->y); 342 # ifdef FEAT_BEVALTERM
339 col = X_2_COL(beval->x); 343 if (!gui.in_use)
344 {
345 row = mouse_row;
346 col = mouse_col;
347 }
348 else
349 # endif
350 {
351 row = Y_2_ROW(beval->y);
352 col = X_2_COL(beval->x);
353 }
340 wp = mouse_find_win(&row, &col); 354 wp = mouse_find_win(&row, &col);
341 if (wp != NULL && row < wp->w_height && col < wp->w_width) 355 if (wp != NULL && row < wp->w_height && col < wp->w_width)
342 { 356 {
343 /* Found a window and the cursor is in the text. Now find the line 357 /* Found a window and the cursor is in the text. Now find the line
344 * number. */ 358 * number. */
419 } 433 }
420 434
421 return FAIL; 435 return FAIL;
422 } 436 }
423 437
438 /*
439 * Show a balloon with "mesg".
440 */
441 void
442 post_balloon(BalloonEval *beval, char_u *mesg)
443 {
444 # ifdef FEAT_BEVALTERM
445 if (!gui.in_use)
446 ui_post_balloon(mesg);
447 else
448 # endif
449 gui_mch_post_balloon(beval, mesg);
450 }
451
424 # if !defined(FEAT_GUI_W32) || defined(PROTO) 452 # if !defined(FEAT_GUI_W32) || defined(PROTO)
425 453
426 /* 454 /*
427 * Show a balloon with "mesg". 455 * Show a balloon with "mesg".
428 */ 456 */
449 undrawBalloon(beval); 477 undrawBalloon(beval);
450 } 478 }
451 #endif 479 #endif
452 480
453 #ifdef FEAT_GUI_GTK 481 #ifdef FEAT_GUI_GTK
454 /*
455 * We can unconditionally use ANSI-style prototypes here since
456 * GTK+ requires an ANSI C compiler anyway.
457 */
458 static void 482 static void
459 addEventHandler(GtkWidget *target, BalloonEval *beval) 483 addEventHandler(GtkWidget *target, BalloonEval *beval)
460 { 484 {
461 /* 485 /*
462 * Connect to the generic "event" signal instead of the individual 486 * Connect to the generic "event" signal instead of the individual