Mercurial > vim
annotate src/beval.c @ 17315:f96f99faf747
Added tag v8.1.1656 for changeset b60402471f69c754122ce9974230299934a09d17
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 Jul 2019 20:30:06 +0200 |
parents | 1b0b90f1d95e |
children | 8813e1626e0a |
rev | line source |
---|---|
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 * |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 * Visual Workshop integration by Gordon Prieur |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 * |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 * Do ":help uganda" in Vim to read copying and usage conditions. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 * Do ":help credits" in Vim to see a list of people who contributed. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 * See README.txt for an overview of the Vim source code. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 #include "vim.h" |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
13 #if defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) || defined(PROT) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
14 /* |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
15 * Find text under the mouse position "row" / "col". |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
16 * If "getword" is TRUE the returned text in "*textp" is not the whole line but |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
17 * the relevant word in allocated memory. |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
18 * Return OK if found. |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
19 * Return FAIL if not found, no text at the mouse position. |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
20 */ |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
21 int |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
22 find_word_under_cursor( |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
23 int mouserow, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
24 int mousecol, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
25 int getword, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
26 int flags, // flags for find_ident_at_pos() |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
27 win_T **winp, // can be NULL |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
28 linenr_T *lnump, // can be NULL |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
29 char_u **textp, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
30 int *colp) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
31 { |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
32 int row = mouserow; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
33 int col = mousecol; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
34 win_T *wp; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
35 char_u *lbuf; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
36 linenr_T lnum; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
37 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
38 *textp = NULL; |
17041
5ed4965ebc7b
patch 8.1.1520: popup windows are ignored when dealing with mouse position
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
39 wp = mouse_find_win(&row, &col, FAIL_POPUP); |
12981 | 40 if (wp != NULL && row >= 0 && row < wp->w_height && col < wp->w_width) |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
42 // Found a window and the cursor is in the text. Now find the line |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
43 // number. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 if (!mouse_comp_pos(wp, &row, &col, &lnum)) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
46 // Not past end of the file. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 if (col <= win_linetabsize(wp, lbuf, (colnr_T)MAXCOL)) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
50 // Not past end of line. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 if (getword) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
53 // For Netbeans we get the relevant part of the line |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
54 // instead of the whole line. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 int len; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 pos_T *spos = NULL, *epos = NULL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 if (VIsual_active) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 if (LT_POS(VIsual, curwin->w_cursor)) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 spos = &VIsual; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 epos = &curwin->w_cursor; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 else |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 spos = &curwin->w_cursor; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 epos = &VIsual; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 col = vcol2col(wp, lnum, col); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 if (VIsual_active |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 && wp->w_buffer == curwin->w_buffer |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 && (lnum == spos->lnum |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 ? col >= (int)spos->col |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 : lnum > spos->lnum) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 && (lnum == epos->lnum |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 ? col <= (int)epos->col |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 : lnum < epos->lnum)) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
83 // Visual mode and pointing to the line with the |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
84 // Visual selection: return selected text, with a |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
85 // maximum of one line. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 if (spos->lnum != epos->lnum || spos->col == epos->col) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 return FAIL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 lbuf = ml_get_buf(curwin->w_buffer, VIsual.lnum, FALSE); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 len = epos->col - spos->col; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 if (*p_sel != 'e') |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 len += MB_PTR2LEN(lbuf + epos->col); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 lbuf = vim_strnsave(lbuf + spos->col, len); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 lnum = spos->lnum; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 col = spos->col; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 else |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
99 // Find the word under the cursor. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 ++emsg_off; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 len = find_ident_at_pos(wp, lnum, (colnr_T)col, &lbuf, |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
102 flags); |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 --emsg_off; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 if (len == 0) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 return FAIL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 lbuf = vim_strnsave(lbuf, len); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
110 if (winp != NULL) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
111 *winp = wp; |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
112 if (lnump != NULL) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
113 *lnump = lnum; |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 *textp = lbuf; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 *colp = col; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 return OK; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 return FAIL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 } |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
122 #endif |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
123 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
124 #if defined(FEAT_BEVAL) || defined(PROTO) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
125 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
126 /* |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
127 * Get the text and position to be evaluated for "beval". |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
128 * If "getword" is TRUE the returned text is not the whole line but the |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
129 * relevant word in allocated memory. |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
130 * Returns OK or FAIL. |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
131 */ |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
132 int |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
133 get_beval_info( |
17302
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
134 BalloonEval *beval, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
135 int getword, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
136 win_T **winp, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
137 linenr_T *lnump, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
138 char_u **textp, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
139 int *colp) |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
140 { |
17302
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
141 int row = mouse_row; |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
142 int col = mouse_col; |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
143 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
144 # ifdef FEAT_GUI |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
145 if (gui.in_use) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
146 { |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
147 row = Y_2_ROW(beval->y); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
148 col = X_2_COL(beval->x); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
149 } |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
150 #endif |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
151 if (find_word_under_cursor(row, col, getword, |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
152 FIND_IDENT + FIND_STRING + FIND_EVAL, |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
153 winp, lnump, textp, colp) == OK) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
154 { |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
155 #ifdef FEAT_VARTABS |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
156 vim_free(beval->vts); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
157 beval->vts = tabstop_copy((*winp)->w_buffer->b_p_vts_array); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
158 if ((*winp)->w_buffer->b_p_vts_array != NULL && beval->vts == NULL) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
159 { |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
160 if (getword) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
161 vim_free(*textp); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
162 return FAIL; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
163 } |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
164 #endif |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
165 beval->ts = (*winp)->w_buffer->b_p_ts; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
166 return OK; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
167 } |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
168 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
169 return FAIL; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
170 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 /* |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
173 * Show a balloon with "mesg" or "list". |
17041
5ed4965ebc7b
patch 8.1.1520: popup windows are ignored when dealing with mouse position
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
174 * Hide the balloon when both are NULL. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 void |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12981
diff
changeset
|
177 post_balloon(BalloonEval *beval UNUSED, char_u *mesg, list_T *list UNUSED) |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 # ifdef FEAT_BEVAL_TERM |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 # ifdef FEAT_GUI |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 if (!gui.in_use) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 # endif |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
183 ui_post_balloon(mesg, list); |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 # endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 # ifdef FEAT_BEVAL_GUI |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 if (gui.in_use) |
17041
5ed4965ebc7b
patch 8.1.1520: popup windows are ignored when dealing with mouse position
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
187 // GUI can't handle a list |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 gui_mch_post_balloon(beval, mesg); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 # endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 /* |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 * Returns TRUE if the balloon eval has been enabled: |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 * 'ballooneval' for the GUI and 'balloonevalterm' for the terminal. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 * Also checks if the screen isn't scrolled up. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 int |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 can_use_beval(void) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 return (0 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 #ifdef FEAT_BEVAL_GUI |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 || (gui.in_use && p_beval) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 #ifdef FEAT_BEVAL_TERM |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 || ( |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 # ifdef FEAT_GUI |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 !gui.in_use && |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 # endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 p_bevalterm) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 ) && msg_scrolled == 0; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 /* |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 * Common code, invoked when the mouse is resting for a moment. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 void |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 general_beval_cb(BalloonEval *beval, int state UNUSED) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 #ifdef FEAT_EVAL |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 win_T *wp; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 int col; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 int use_sandbox; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 linenr_T lnum; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 char_u *text; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 static char_u *result = NULL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 long winnr = 0; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 char_u *bexpr; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 buf_T *save_curbuf; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 size_t len; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 win_T *cw; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 static int recursive = FALSE; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 /* Don't do anything when 'ballooneval' is off, messages scrolled the |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 * windows up or we have no beval area. */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 if (!can_use_beval() || beval == NULL) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 return; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 /* Don't do this recursively. Happens when the expression evaluation |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 * takes a long time and invokes something that checks for CTRL-C typed. */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 if (recursive) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 return; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 recursive = TRUE; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 #ifdef FEAT_EVAL |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 : wp->w_buffer->b_p_bexpr; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 if (*bexpr != NUL) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 /* Convert window pointer to number. */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 for (cw = firstwin; cw != wp; cw = cw->w_next) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 ++winnr; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 set_vim_var_nr(VV_BEVAL_BUFNR, (long)wp->w_buffer->b_fnum); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 set_vim_var_nr(VV_BEVAL_WINNR, winnr); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 set_vim_var_nr(VV_BEVAL_WINID, wp->w_id); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 set_vim_var_nr(VV_BEVAL_LNUM, (long)lnum); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 set_vim_var_nr(VV_BEVAL_COL, (long)(col + 1)); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 set_vim_var_string(VV_BEVAL_TEXT, text, -1); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 vim_free(text); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
265 /* |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 * Temporarily change the curbuf, so that we can determine whether |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 * the buffer-local balloonexpr option was set insecurely. |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 save_curbuf = curbuf; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 curbuf = wp->w_buffer; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 use_sandbox = was_set_insecurely((char_u *)"balloonexpr", |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 *curbuf->b_p_bexpr == NUL ? 0 : OPT_LOCAL); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
273 curbuf = save_curbuf; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 if (use_sandbox) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 ++sandbox; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 ++textlock; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 vim_free(result); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 result = eval_to_string(bexpr, NULL, TRUE); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 /* Remove one trailing newline, it is added when the result was a |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 * list and it's hardly ever useful. If the user really wants a |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 * trailing newline he can add two and one remains. */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 if (result != NULL) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 len = STRLEN(result); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
287 if (len > 0 && result[len - 1] == NL) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 result[len - 1] = NUL; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
289 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
290 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
291 if (use_sandbox) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
292 --sandbox; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
293 --textlock; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
294 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 if (result != NULL && result[0] != NUL) |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
297 post_balloon(beval, result, NULL); |
17310
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
298 |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
299 # ifdef FEAT_GUI |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
300 // The 'balloonexpr' evaluation may show something on the screen |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
301 // that requires a screen update. |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
302 if (gui.in_use && must_redraw) |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
303 redraw_after_callback(FALSE); |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
304 # endif |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
305 |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
306 recursive = FALSE; |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
307 return; |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
308 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
309 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 #ifdef FEAT_NETBEANS_INTG |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 if (bevalServers & BEVAL_NETBEANS) |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 netbeans_beval_cb(beval, state); |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 recursive = FALSE; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
317 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
318 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
319 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
320 |