Mercurial > vim
annotate src/beval.c @ 32395:2ed95122d59c v9.0.1529
patch 9.0.1529: code style test doesn't check for space after "if"
Commit: https://github.com/vim/vim/commit/c9471b18728b1b37c04845ca2bc59fc981308b2d
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 9 15:00:00 2023 +0100
patch 9.0.1529: code style test doesn't check for space after "if"
Problem: Code style test doesn't check for space after "if".
Solution: Add a test for space.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 May 2023 16:15:05 +0200 |
parents | bea4ebf594c6 |
children | 8fc442c731ca |
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 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18757
diff
changeset
|
13 #if defined(FEAT_BEVAL) || defined(FEAT_PROP_POPUP) || defined(PROTO) |
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, |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17310
diff
changeset
|
30 int *colp, // column where mouse hovers, can be NULL |
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17310
diff
changeset
|
31 int *startcolp) // column where text starts, can be NULL |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
32 { |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
33 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
|
34 int col = mousecol; |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17310
diff
changeset
|
35 int scol; |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17041
diff
changeset
|
40 *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
|
41 wp = mouse_find_win(&row, &col, FAIL_POPUP); |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
42 if (wp == NULL || row < 0 || row >= wp->w_height || col >= wp->w_width) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
43 return FAIL; |
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 |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
45 // Found a window and the cursor is in the text. Now find the line |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
46 // number. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
47 if (mouse_comp_pos(wp, &row, &col, &lnum, NULL)) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
48 return FAIL; // position is below the last 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
|
49 |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
50 // Not past end of the file. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
51 lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
52 if (col > win_linetabsize(wp, lnum, lbuf, (colnr_T)MAXCOL)) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
53 return FAIL; // 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
|
54 |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
55 // Not past end of line. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
56 if (getword) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
57 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
58 // For Netbeans we get the relevant part of the line |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
59 // instead of the whole line. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
60 int len; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
61 pos_T *spos = NULL, *epos = 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
|
62 |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
63 if (VIsual_active) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
64 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
65 if (LT_POS(VIsual, curwin->w_cursor)) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
66 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
67 spos = &VIsual; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
68 epos = &curwin->w_cursor; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
69 } |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
70 else |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
71 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
72 spos = &curwin->w_cursor; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
73 epos = &VIsual; |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 } |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
76 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
77 col = vcol2col(wp, lnum, col); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
78 scol = col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
79 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
80 if (VIsual_active |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
81 && wp->w_buffer == curwin->w_buffer |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
82 && (lnum == spos->lnum |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
83 ? col >= (int)spos->col |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
84 : lnum > spos->lnum) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
85 && (lnum == epos->lnum |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
86 ? col <= (int)epos->col |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
87 : lnum < epos->lnum)) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
88 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
89 // Visual mode and pointing to the line with the |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
90 // Visual selection: return selected text, with a |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
91 // maximum of one line. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
92 if (spos->lnum != epos->lnum || spos->col == epos->col) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
93 return FAIL; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
94 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
95 lbuf = ml_get_buf(curwin->w_buffer, VIsual.lnum, FALSE); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
96 len = epos->col - spos->col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
97 if (*p_sel != 'e') |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
98 len += mb_ptr2len(lbuf + epos->col); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
99 lbuf = vim_strnsave(lbuf + spos->col, len); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
100 lnum = spos->lnum; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
101 col = spos->col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
102 scol = col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
103 } |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
104 else |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
105 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
106 // Find the word under the cursor. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
107 ++emsg_off; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
108 len = find_ident_at_pos(wp, lnum, (colnr_T)col, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
109 &lbuf, &scol, flags); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
110 --emsg_off; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
111 if (len == 0) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
112 return FAIL; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
113 lbuf = vim_strnsave(lbuf, len); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
114 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 } |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
116 else |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
117 scol = col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
118 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
119 if (winp != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
120 *winp = wp; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
121 if (lnump != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
122 *lnump = lnum; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
123 *textp = lbuf; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
124 if (colp != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
125 *colp = col; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
126 if (startcolp != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
127 *startcolp = scol; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
128 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
129 return OK; |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 } |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
131 #endif |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
132 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
133 #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
|
134 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
135 /* |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
136 * 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
|
137 * 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
|
138 * 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
|
139 * 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
|
140 */ |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
141 int |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
142 get_beval_info( |
17302
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
143 BalloonEval *beval, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
144 int getword, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
145 win_T **winp, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
146 linenr_T *lnump, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
147 char_u **textp, |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
148 int *colp) |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
149 { |
17302
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
150 int row = mouse_row; |
e0d727872758
patch 8.1.1650: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
17298
diff
changeset
|
151 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
|
152 |
26443
fee1e854e183
patch 8.2.3752: build error when using Photon GUI
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
153 # ifdef FEAT_BEVAL_GUI |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
154 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
|
155 { |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
156 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
|
157 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
|
158 } |
26443
fee1e854e183
patch 8.2.3752: build error when using Photon GUI
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
159 # endif |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
160 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
|
161 FIND_IDENT + FIND_STRING + FIND_EVAL, |
17316
8813e1626e0a
patch 8.1.1657: Terminal: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17310
diff
changeset
|
162 winp, lnump, textp, colp, NULL) == OK) |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
163 { |
26443
fee1e854e183
patch 8.2.3752: build error when using Photon GUI
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
164 # ifdef FEAT_VARTABS |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 { |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
169 if (getword) |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
170 vim_free(*textp); |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
171 return FAIL; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
172 } |
26443
fee1e854e183
patch 8.2.3752: build error when using Photon GUI
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
173 # endif |
17298
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
174 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
|
175 return OK; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
176 } |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
177 |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
178 return FAIL; |
3d90ae62deca
patch 8.1.1648: MS-Windows: build error with normal feaures
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
179 } |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 /* |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
182 * 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
|
183 * 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
|
184 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 void |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
12981
diff
changeset
|
186 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
|
187 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 # 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
|
189 # 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
|
190 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
|
191 # endif |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
192 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
|
193 # endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 # 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
|
195 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
|
196 // 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
|
197 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
|
198 # endif |
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 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 /* |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 * 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
|
203 * '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
|
204 * 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
|
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 int |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 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
|
208 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 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
|
210 #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
|
211 || (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
|
212 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 #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
|
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 # 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
|
216 !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
|
217 # endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 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
|
219 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 ) && 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
|
221 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
223 # ifdef FEAT_EVAL |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
224 /* |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
225 * Evaluate the expression 'bexpr' and set the text in the balloon 'beval'. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
226 */ |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
227 static void |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
228 bexpr_eval( |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
229 BalloonEval *beval, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
230 char_u *bexpr, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
231 win_T *wp, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
232 linenr_T lnum, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
233 int col, |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
234 char_u *text) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
235 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
236 win_T *cw; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
237 long winnr = 0; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
238 buf_T *save_curbuf; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
239 int use_sandbox; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
240 static char_u *result = NULL; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
241 size_t len; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
242 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
243 sctx_T save_sctx = current_sctx; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
244 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
245 // Convert window pointer to number. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
246 for (cw = firstwin; cw != wp; cw = cw->w_next) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
247 ++winnr; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
248 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
249 set_vim_var_nr(VV_BEVAL_BUFNR, (long)wp->w_buffer->b_fnum); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
250 set_vim_var_nr(VV_BEVAL_WINNR, winnr); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
251 set_vim_var_nr(VV_BEVAL_WINID, wp->w_id); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
252 set_vim_var_nr(VV_BEVAL_LNUM, (long)lnum); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
253 set_vim_var_nr(VV_BEVAL_COL, (long)(col + 1)); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
254 set_vim_var_string(VV_BEVAL_TEXT, text, -1); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
255 vim_free(text); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
256 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
257 /* |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
258 * Temporarily change the curbuf, so that we can determine whether |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
259 * the buffer-local balloonexpr option was set insecurely. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
260 */ |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
261 save_curbuf = curbuf; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
262 curbuf = wp->w_buffer; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
263 use_sandbox = was_set_insecurely((char_u *)"balloonexpr", |
32295
bea4ebf594c6
patch 9.0.1479: small source file problems; outdated list of distrib. files
Bram Moolenaar <Bram@vim.org>
parents:
30598
diff
changeset
|
264 *curbuf->b_p_bexpr == NUL ? 0 : OPT_LOCAL); |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
265 curbuf = save_curbuf; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
266 if (use_sandbox) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
267 ++sandbox; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
268 ++textlock; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
269 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
270 if (bexpr == p_bexpr) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
271 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
272 sctx_T *sp = get_option_sctx("balloonexpr"); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
273 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
274 if (sp != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
275 current_sctx = *sp; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
276 } |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
277 else |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
278 current_sctx = curbuf->b_p_script_ctx[BV_BEXPR]; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
279 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
280 vim_free(result); |
30598
37aa9fd2ed72
patch 9.0.0634: evaluating "expr" options has more overhead than needed
Bram Moolenaar <Bram@vim.org>
parents:
30531
diff
changeset
|
281 result = eval_to_string(bexpr, TRUE, TRUE); |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
282 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
283 // Remove one trailing newline, it is added when the result was a |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
284 // list and it's hardly ever useful. If the user really wants a |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
285 // trailing newline he can add two and one remains. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
286 if (result != NULL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
287 { |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
288 len = STRLEN(result); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
289 if (len > 0 && result[len - 1] == NL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
290 result[len - 1] = NUL; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
291 } |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
292 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
293 if (use_sandbox) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
294 --sandbox; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
295 --textlock; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
296 current_sctx = save_sctx; |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
297 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
298 set_vim_var_string(VV_BEVAL_TEXT, NULL, -1); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
299 if (result != NULL && result[0] != NUL) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
300 post_balloon(beval, result, NULL); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
301 |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
302 // The 'balloonexpr' evaluation may show something on the screen |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
303 // that requires a screen update. |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
304 if (must_redraw) |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
305 redraw_after_callback(FALSE, FALSE); |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
306 } |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
307 # endif |
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
308 |
12871
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 * 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
|
311 */ |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 void |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 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
|
314 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 #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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
322 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
|
323 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
324 // Don't do anything when 'ballooneval' is off, messages scrolled the |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
325 // windows up or we have no beval area. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 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
|
327 return; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
328 |
18757
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
329 // Don't do this recursively. Happens when the expression evaluation |
c469e1930456
patch 8.1.2368: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
330 // takes a long time and invokes something that checks for CTRL-C typed. |
12871
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 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
|
332 return; |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
333 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
|
334 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
335 #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
|
336 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
|
337 { |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 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
|
339 : 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
|
340 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
|
341 { |
30531
2650a01b8bbc
patch 9.0.0601: too much indent
Bram Moolenaar <Bram@vim.org>
parents:
29451
diff
changeset
|
342 bexpr_eval(beval, bexpr, wp, lnum, col, text); |
17310
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
343 recursive = FALSE; |
1b0b90f1d95e
patch 8.1.1654: GUI: screen updates from 'balloonexpr' are not displayed
Bram Moolenaar <Bram@vim.org>
parents:
17302
diff
changeset
|
344 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
|
345 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 #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
|
349 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
|
350 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
|
351 #endif |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 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
|
354 } |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 |
1a450ce6980c
patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 #endif |