/* vi:set ts=8 sts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
* Visual Workshop integration by Gordon Prieur
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
#include "vim.h"
#if defined(FEAT_BEVAL) || defined(PROTO)
/*
* Common code, invoked when the mouse is resting for a moment.
*/
/*ARGSUSED*/
void
general_beval_cb(beval, state)
BalloonEval *beval;
int state;
{
win_T *wp;
int col;
int use_sandbox;
linenr_T lnum;
char_u *text;
static char_u *result = NULL;
long winnr = 0;
#ifdef FEAT_WINDOWS
win_T *cw;
#endif
/* 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)
return;
#ifdef FEAT_EVAL
if (*p_bexpr != NUL
&& get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK)
{
# ifdef FEAT_WINDOWS
/* Convert window pointer to number. */
for (cw = firstwin; cw != wp; cw = cw->w_next)
++winnr;
# endif
set_vim_var_nr(VV_BEVAL_BUFNR, (long)wp->w_buffer->b_fnum);
set_vim_var_nr(VV_BEVAL_WINNR, winnr);
set_vim_var_nr(VV_BEVAL_LNUM, (long)lnum);
set_vim_var_nr(VV_BEVAL_COL, (long)(col + 1));
set_vim_var_string(VV_BEVAL_TEXT, text, -1);
vim_free(text);
use_sandbox = was_set_insecurely((char_u *)"balloonexpr");
if (use_sandbox)
++sandbox;
++textlock;
vim_free(result);
result = eval_to_string(p_bexpr, NULL);
if (use_sandbox)
--sandbox;
--textlock;
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
if (result != NULL && result[0] != NUL)
{
gui_mch_post_balloon(beval, resu