/* 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;
char_u *bexpr;
buf_T *save_curbuf;
#ifdef FEAT_WINDOWS
win_T *cw;
#endif
static int recursive = FALSE;
/* 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;
/* Don't do this recursively. Happens when the expression evaluation
* takes a long time and invokes something that checks for CTRL-C typed. */
if (recursive)
return;
recursive = TRUE;
#ifdef FEAT_EVAL
if (get_beval_info(balloonEval, TRUE, &wp, &lnum, &text, &col) == OK)
{
bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
: wp->w_buffer->b_p_bexpr;
if (*bexpr != NUL)
{
# 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