forked from aniani/vim
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Problem: Terminal: screen updates from 'balloonexpr' are not displayed. Solution: Update the screen if needed. Fix the word position for "mousemoved".
This commit is contained in:
17
src/beval.c
17
src/beval.c
@@ -27,10 +27,12 @@ find_word_under_cursor(
|
|||||||
win_T **winp, // can be NULL
|
win_T **winp, // can be NULL
|
||||||
linenr_T *lnump, // can be NULL
|
linenr_T *lnump, // can be NULL
|
||||||
char_u **textp,
|
char_u **textp,
|
||||||
int *colp)
|
int *colp, // column where mouse hovers, can be NULL
|
||||||
|
int *startcolp) // column where text starts, can be NULL
|
||||||
{
|
{
|
||||||
int row = mouserow;
|
int row = mouserow;
|
||||||
int col = mousecol;
|
int col = mousecol;
|
||||||
|
int scol;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
char_u *lbuf;
|
char_u *lbuf;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
@@ -98,8 +100,8 @@ find_word_under_cursor(
|
|||||||
{
|
{
|
||||||
// Find the word under the cursor.
|
// Find the word under the cursor.
|
||||||
++emsg_off;
|
++emsg_off;
|
||||||
len = find_ident_at_pos(wp, lnum, (colnr_T)col, &lbuf,
|
len = find_ident_at_pos(wp, lnum, (colnr_T)col,
|
||||||
flags);
|
&lbuf, &scol, flags);
|
||||||
--emsg_off;
|
--emsg_off;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -112,7 +114,10 @@ find_word_under_cursor(
|
|||||||
if (lnump != NULL)
|
if (lnump != NULL)
|
||||||
*lnump = lnum;
|
*lnump = lnum;
|
||||||
*textp = lbuf;
|
*textp = lbuf;
|
||||||
|
if (colp != NULL)
|
||||||
*colp = col;
|
*colp = col;
|
||||||
|
if (startcolp != NULL)
|
||||||
|
*startcolp = scol;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +155,7 @@ get_beval_info(
|
|||||||
#endif
|
#endif
|
||||||
if (find_word_under_cursor(row, col, getword,
|
if (find_word_under_cursor(row, col, getword,
|
||||||
FIND_IDENT + FIND_STRING + FIND_EVAL,
|
FIND_IDENT + FIND_STRING + FIND_EVAL,
|
||||||
winp, lnump, textp, colp) == OK)
|
winp, lnump, textp, colp, NULL) == OK)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_VARTABS
|
#ifdef FEAT_VARTABS
|
||||||
vim_free(beval->vts);
|
vim_free(beval->vts);
|
||||||
@@ -296,12 +301,10 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
|
|||||||
if (result != NULL && result[0] != NUL)
|
if (result != NULL && result[0] != NUL)
|
||||||
post_balloon(beval, result, NULL);
|
post_balloon(beval, result, NULL);
|
||||||
|
|
||||||
# ifdef FEAT_GUI
|
|
||||||
// The 'balloonexpr' evaluation may show something on the screen
|
// The 'balloonexpr' evaluation may show something on the screen
|
||||||
// that requires a screen update.
|
// that requires a screen update.
|
||||||
if (gui.in_use && must_redraw)
|
if (must_redraw)
|
||||||
redraw_after_callback(FALSE);
|
redraw_after_callback(FALSE);
|
||||||
# endif
|
|
||||||
|
|
||||||
recursive = FALSE;
|
recursive = FALSE;
|
||||||
return;
|
return;
|
||||||
|
56
src/normal.c
56
src/normal.c
@@ -2325,6 +2325,7 @@ do_mouse(
|
|||||||
ui_may_remove_balloon();
|
ui_may_remove_balloon();
|
||||||
if (p_bevalterm)
|
if (p_bevalterm)
|
||||||
{
|
{
|
||||||
|
ch_log(NULL, "setting balloon timer");
|
||||||
profile_setlimit(p_bdlay, &bevalexpr_due);
|
profile_setlimit(p_bdlay, &bevalexpr_due);
|
||||||
bevalexpr_due_set = TRUE;
|
bevalexpr_due_set = TRUE;
|
||||||
}
|
}
|
||||||
@@ -3327,28 +3328,28 @@ find_is_eval_item(
|
|||||||
* Find the identifier under or to the right of the cursor.
|
* Find the identifier under or to the right of the cursor.
|
||||||
* "find_type" can have one of three values:
|
* "find_type" can have one of three values:
|
||||||
* FIND_IDENT: find an identifier (keyword)
|
* FIND_IDENT: find an identifier (keyword)
|
||||||
* FIND_STRING: find any non-white string
|
* FIND_STRING: find any non-white text
|
||||||
* FIND_IDENT + FIND_STRING: find any non-white string, identifier preferred.
|
* FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred.
|
||||||
* FIND_EVAL: find text useful for C program debugging
|
* FIND_EVAL: find text useful for C program debugging
|
||||||
*
|
*
|
||||||
* There are three steps:
|
* There are three steps:
|
||||||
* 1. Search forward for the start of an identifier/string. Doesn't move if
|
* 1. Search forward for the start of an identifier/text. Doesn't move if
|
||||||
* already on one.
|
* already on one.
|
||||||
* 2. Search backward for the start of this identifier/string.
|
* 2. Search backward for the start of this identifier/text.
|
||||||
* This doesn't match the real Vi but I like it a little better and it
|
* This doesn't match the real Vi but I like it a little better and it
|
||||||
* shouldn't bother anyone.
|
* shouldn't bother anyone.
|
||||||
* 3. Search forward to the end of this identifier/string.
|
* 3. Search forward to the end of this identifier/text.
|
||||||
* When FIND_IDENT isn't defined, we backup until a blank.
|
* When FIND_IDENT isn't defined, we backup until a blank.
|
||||||
*
|
*
|
||||||
* Returns the length of the string, or zero if no string is found.
|
* Returns the length of the text, or zero if no text is found.
|
||||||
* If a string is found, a pointer to the string is put in "*string". This
|
* If text is found, a pointer to the text is put in "*text". This
|
||||||
* string is not always NUL terminated.
|
* points into the current buffer line and is not always NUL terminated.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
find_ident_under_cursor(char_u **string, int find_type)
|
find_ident_under_cursor(char_u **text, int find_type)
|
||||||
{
|
{
|
||||||
return find_ident_at_pos(curwin, curwin->w_cursor.lnum,
|
return find_ident_at_pos(curwin, curwin->w_cursor.lnum,
|
||||||
curwin->w_cursor.col, string, find_type);
|
curwin->w_cursor.col, text, NULL, find_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3360,33 +3361,34 @@ find_ident_at_pos(
|
|||||||
win_T *wp,
|
win_T *wp,
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
colnr_T startcol,
|
colnr_T startcol,
|
||||||
char_u **string,
|
char_u **text,
|
||||||
|
int *textcol, // column where "text" starts, can be NULL
|
||||||
int find_type)
|
int find_type)
|
||||||
{
|
{
|
||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
int col = 0; /* init to shut up GCC */
|
int col = 0; // init to shut up GCC
|
||||||
int i;
|
int i;
|
||||||
int this_class = 0;
|
int this_class = 0;
|
||||||
int prev_class;
|
int prev_class;
|
||||||
int prevcol;
|
int prevcol;
|
||||||
int bn = 0; /* bracket nesting */
|
int bn = 0; // bracket nesting
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if i == 0: try to find an identifier
|
* if i == 0: try to find an identifier
|
||||||
* if i == 1: try to find any non-white string
|
* if i == 1: try to find any non-white text
|
||||||
*/
|
*/
|
||||||
ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||||
for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i)
|
for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* 1. skip to start of identifier/string
|
* 1. skip to start of identifier/text
|
||||||
*/
|
*/
|
||||||
col = startcol;
|
col = startcol;
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
while (ptr[col] != NUL)
|
while (ptr[col] != NUL)
|
||||||
{
|
{
|
||||||
/* Stop at a ']' to evaluate "a[x]". */
|
// Stop at a ']' to evaluate "a[x]".
|
||||||
if ((find_type & FIND_EVAL) && ptr[col] == ']')
|
if ((find_type & FIND_EVAL) && ptr[col] == ']')
|
||||||
break;
|
break;
|
||||||
this_class = mb_get_class(ptr + col);
|
this_class = mb_get_class(ptr + col);
|
||||||
@@ -3402,11 +3404,11 @@ find_ident_at_pos(
|
|||||||
)
|
)
|
||||||
++col;
|
++col;
|
||||||
|
|
||||||
/* When starting on a ']' count it, so that we include the '['. */
|
// When starting on a ']' count it, so that we include the '['.
|
||||||
bn = ptr[col] == ']';
|
bn = ptr[col] == ']';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 2. Back up to start of identifier/string.
|
* 2. Back up to start of identifier/text.
|
||||||
*/
|
*/
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
@@ -3432,8 +3434,8 @@ find_ident_at_pos(
|
|||||||
col = prevcol;
|
col = prevcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we don't want just any old string, or we've found an
|
// If we don't want just any old text, or we've found an
|
||||||
* identifier, stop searching. */
|
// identifier, stop searching.
|
||||||
if (this_class > 2)
|
if (this_class > 2)
|
||||||
this_class = 2;
|
this_class = 2;
|
||||||
if (!(find_type & FIND_STRING) || this_class == 2)
|
if (!(find_type & FIND_STRING) || this_class == 2)
|
||||||
@@ -3454,8 +3456,8 @@ find_ident_at_pos(
|
|||||||
))
|
))
|
||||||
--col;
|
--col;
|
||||||
|
|
||||||
/* If we don't want just any old string, or we've found an
|
// If we don't want just any old text, or we've found an
|
||||||
* identifier, stop searching. */
|
// identifier, stop searching.
|
||||||
if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col]))
|
if (!(find_type & FIND_STRING) || vim_iswordc(ptr[col]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3464,7 +3466,7 @@ find_ident_at_pos(
|
|||||||
if (ptr[col] == NUL || (i == 0
|
if (ptr[col] == NUL || (i == 0
|
||||||
&& (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col]))))
|
&& (has_mbyte ? this_class != 2 : !vim_iswordc(ptr[col]))))
|
||||||
{
|
{
|
||||||
// didn't find an identifier or string
|
// didn't find an identifier or text
|
||||||
if ((find_type & FIND_NOERROR) == 0)
|
if ((find_type & FIND_NOERROR) == 0)
|
||||||
{
|
{
|
||||||
if (find_type & FIND_STRING)
|
if (find_type & FIND_STRING)
|
||||||
@@ -3475,17 +3477,19 @@ find_ident_at_pos(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ptr += col;
|
ptr += col;
|
||||||
*string = ptr;
|
*text = ptr;
|
||||||
|
if (textcol != NULL)
|
||||||
|
*textcol = col;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 3. Find the end if the identifier/string.
|
* 3. Find the end if the identifier/text.
|
||||||
*/
|
*/
|
||||||
bn = 0;
|
bn = 0;
|
||||||
startcol -= col;
|
startcol -= col;
|
||||||
col = 0;
|
col = 0;
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
{
|
{
|
||||||
/* Search for point of changing multibyte character class. */
|
// Search for point of changing multibyte character class.
|
||||||
this_class = mb_get_class(ptr);
|
this_class = mb_get_class(ptr);
|
||||||
while (ptr[col] != NUL
|
while (ptr[col] != NUL
|
||||||
&& ((i == 0 ? mb_get_class(ptr + col) == this_class
|
&& ((i == 0 ? mb_get_class(ptr + col) == this_class
|
||||||
|
@@ -188,7 +188,7 @@ set_mousemoved_columns(win_T *wp, int flags)
|
|||||||
int col;
|
int col;
|
||||||
|
|
||||||
if (find_word_under_cursor(mouse_row, mouse_col, TRUE, flags,
|
if (find_word_under_cursor(mouse_row, mouse_col, TRUE, flags,
|
||||||
NULL, NULL, &text, &col) == OK)
|
NULL, NULL, &text, NULL, &col) == OK)
|
||||||
{
|
{
|
||||||
wp->w_popup_mouse_mincol = col;
|
wp->w_popup_mouse_mincol = col;
|
||||||
wp->w_popup_mouse_maxcol = col + STRLEN(text) - 1;
|
wp->w_popup_mouse_maxcol = col + STRLEN(text) - 1;
|
||||||
@@ -1437,6 +1437,7 @@ check_mouse_moved(win_T *wp, win_T *mouse_wp)
|
|||||||
{
|
{
|
||||||
typval_T res;
|
typval_T res;
|
||||||
|
|
||||||
|
ch_log(NULL, "closing popup %d", wp->w_id);
|
||||||
res.v_type = VAR_NUMBER;
|
res.v_type = VAR_NUMBER;
|
||||||
res.vval.v_number = -2;
|
res.vval.v_number = -2;
|
||||||
// Careful: this makes "wp" invalid.
|
// Careful: this makes "wp" invalid.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* beval.c */
|
/* beval.c */
|
||||||
int find_word_under_cursor(int mouserow, int mousecol, int getword, int flags, win_T **winp, linenr_T *lnump, char_u **textp, int *colp);
|
int find_word_under_cursor(int mouserow, int mousecol, int getword, int flags, win_T **winp, linenr_T *lnump, char_u **textp, int *colp, int *startcolp);
|
||||||
int get_beval_info(BalloonEval *beval, int getword, win_T **winp, linenr_T *lnump, char_u **textp, int *colp);
|
int get_beval_info(BalloonEval *beval, int getword, win_T **winp, linenr_T *lnump, char_u **textp, int *colp);
|
||||||
void post_balloon(BalloonEval *beval, char_u *mesg, list_T *list);
|
void post_balloon(BalloonEval *beval, char_u *mesg, list_T *list);
|
||||||
int can_use_beval(void);
|
int can_use_beval(void);
|
||||||
|
@@ -7,8 +7,8 @@ void check_visual_highlight(void);
|
|||||||
void end_visual_mode(void);
|
void end_visual_mode(void);
|
||||||
void reset_VIsual_and_resel(void);
|
void reset_VIsual_and_resel(void);
|
||||||
void reset_VIsual(void);
|
void reset_VIsual(void);
|
||||||
int find_ident_under_cursor(char_u **string, int find_type);
|
int find_ident_under_cursor(char_u **text, int find_type);
|
||||||
int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **string, int find_type);
|
int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **text, int *textcol, int find_type);
|
||||||
void clear_showcmd(void);
|
void clear_showcmd(void);
|
||||||
int add_to_showcmd(int c);
|
int add_to_showcmd(int c);
|
||||||
void add_to_showcmd_c(int c);
|
void add_to_showcmd_c(int c);
|
||||||
|
@@ -777,6 +777,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1657,
|
||||||
/**/
|
/**/
|
||||||
1656,
|
1656,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user