Mercurial > vim
annotate src/popupmenu.c @ 29301:fb375f0c6ea7 v8.2.5167
patch 8.2.5167: get(Fn, 'name') on funcref returns special byte code
Commit: https://github.com/vim/vim/commit/1ae8c262df7083dfb4b41485508951c50eccc84c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 27 11:45:52 2022 +0100
patch 8.2.5167: get(Fn, 'name') on funcref returns special byte code
Problem: get(Fn, 'name') on funcref returns special byte code.
Solution: Use the printable name.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 27 Jun 2022 13:00:07 +0200 |
parents | d770568e6c98 |
children | 86eac190ec42 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
8220
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
800 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
18174
1ec6539cef68
patch 8.1.2082: some files have a weird name to fit in 8.3 characters
Bram Moolenaar <Bram@vim.org>
parents:
17950
diff
changeset
|
11 * popupmenu.c: Popup menu (PUM) |
800 | 12 */ |
13 #include "vim.h" | |
14 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
15 static pumitem_T *pum_array = NULL; // items of displayed pum |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
16 static int pum_size; // nr of items in "pum_array" |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
17 static int pum_selected; // index of selected item or -1 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
18 static int pum_first = 0; // index of top item |
800 | 19 |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
20 static int call_update_screen = FALSE; |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
21 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
22 static int pum_height; // nr of displayed pum items |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
23 static int pum_width; // width of displayed pum items |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
24 static int pum_base_width; // width of pum items base |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
25 static int pum_kind_width; // width of pum items kind column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
26 static int pum_extra_width; // width of extra stuff |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
27 static int pum_scrollbar; // TRUE when scrollbar present |
800 | 28 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
29 static int pum_row; // top row of pum |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
30 static int pum_col; // left column of pum |
800 | 31 |
14095
f452c4aeb837
patch 8.1.0065: balloon displayed at the wrong position
Christian Brabandt <cb@256bit.org>
parents:
14089
diff
changeset
|
32 static win_T *pum_window = NULL; |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
33 static int pum_win_row; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
34 static int pum_win_height; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
35 static int pum_win_col; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
36 static int pum_win_wcol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
37 static int pum_win_width; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
38 |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
39 // Some parts are not updated when a popup menu is visible. Setting this flag |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
40 // makes pum_visible() return FALSE even when there is a popup menu. |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
41 static int pum_pretend_not_visible = FALSE; |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
42 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7181
diff
changeset
|
43 static int pum_set_selected(int n, int repeat); |
800 | 44 |
45 #define PUM_DEF_HEIGHT 10 | |
46 | |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
47 static void |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
48 pum_compute_size(void) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
49 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
50 int i; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
51 int w; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
52 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
53 // Compute the width of the widest match and the widest extra. |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
54 pum_base_width = 0; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
55 pum_kind_width = 0; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
56 pum_extra_width = 0; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
57 for (i = 0; i < pum_size; ++i) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
58 { |
20245
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
59 if (pum_array[i].pum_text != NULL) |
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
60 { |
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
61 w = vim_strsize(pum_array[i].pum_text); |
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
62 if (pum_base_width < w) |
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
63 pum_base_width = w; |
43ae8e2fd4c4
patch 8.2.0678: rare crash for popup menu
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
64 } |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
65 if (pum_array[i].pum_kind != NULL) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
66 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
67 w = vim_strsize(pum_array[i].pum_kind) + 1; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
68 if (pum_kind_width < w) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
69 pum_kind_width = w; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
70 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
71 if (pum_array[i].pum_extra != NULL) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
72 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
73 w = vim_strsize(pum_array[i].pum_extra) + 1; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
74 if (pum_extra_width < w) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
75 pum_extra_width = w; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
76 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
77 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
78 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
79 |
800 | 80 /* |
81 * Show the popup menu with items "array[size]". | |
82 * "array" must remain valid until pum_undisplay() is called! | |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
83 * When possible the leftmost character is aligned with cursor column. |
800 | 84 * The menu appears above the screen line "row" or at "row" + "height" - 1. |
85 */ | |
86 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
87 pum_display( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
88 pumitem_T *array, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
89 int size, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
90 int selected) // index of initially selected item, none if |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
91 // out of range |
800 | 92 { |
93 int def_width; | |
94 int max_width; | |
1622 | 95 int context_lines; |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
96 int cursor_col; |
10326
7d10572eaba4
commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents:
10302
diff
changeset
|
97 int above_row; |
7d10572eaba4
commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents:
10302
diff
changeset
|
98 int below_row; |
838 | 99 int redo_count = 0; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
100 #if defined(FEAT_QUICKFIX) |
10326
7d10572eaba4
commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents:
10302
diff
changeset
|
101 win_T *pvwin; |
10332
4d98f501d1c5
commit https://github.com/vim/vim/commit/aab3383e70456f054fe9d0963fe3eb45994aa5e7
Christian Brabandt <cb@256bit.org>
parents:
10326
diff
changeset
|
102 #endif |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
103 #ifdef FEAT_RIGHTLEFT |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
104 int right_left = State == MODE_CMDLINE ? FALSE : curwin->w_p_rl; |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
105 #endif |
800 | 106 |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
107 do |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
108 { |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
109 def_width = p_pw; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
110 above_row = 0; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
111 below_row = cmdline_row; |
800 | 112 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
113 // Pretend the pum is already there to avoid that must_redraw is set |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
114 // when 'cuc' is on. |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
115 pum_array = (pumitem_T *)1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
116 validate_cursor_col(); |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
117 pum_array = NULL; |
800 | 118 |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
119 // Remember the essential parts of the window position and size, so we |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
120 // can decide when to reposition the popup menu. |
14095
f452c4aeb837
patch 8.1.0065: balloon displayed at the wrong position
Christian Brabandt <cb@256bit.org>
parents:
14089
diff
changeset
|
121 pum_window = curwin; |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
122 if (State == MODE_CMDLINE) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27597
diff
changeset
|
123 // cmdline completion popup menu |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
124 pum_win_row = cmdline_row; |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
125 else |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
126 pum_win_row = curwin->w_wrow + W_WINROW(curwin); |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
127 pum_win_height = curwin->w_height; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
128 pum_win_col = curwin->w_wincol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
129 pum_win_wcol = curwin->w_wcol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
130 pum_win_width = curwin->w_width; |
800 | 131 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
132 #if defined(FEAT_QUICKFIX) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
133 FOR_ALL_WINDOWS(pvwin) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
134 if (pvwin->w_p_pvw) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
135 break; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
136 if (pvwin != NULL) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
137 { |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
138 if (W_WINROW(pvwin) < W_WINROW(curwin)) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
139 above_row = W_WINROW(pvwin) + pvwin->w_height; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
140 else if (W_WINROW(pvwin) > W_WINROW(curwin) + curwin->w_height) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
141 below_row = W_WINROW(pvwin); |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
142 } |
8220
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
143 #endif |
800 | 144 |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
145 /* |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
146 * Figure out the size and position of the pum. |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
147 */ |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
148 if (size < PUM_DEF_HEIGHT) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
149 pum_height = size; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
150 else |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
151 pum_height = PUM_DEF_HEIGHT; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
152 if (p_ph > 0 && pum_height > p_ph) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
153 pum_height = p_ph; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
154 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
155 // Put the pum below "pum_win_row" if possible. If there are few lines |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
156 // decide on where there is more room. |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
157 if (pum_win_row + 2 >= below_row - pum_height |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
158 && pum_win_row - above_row > (below_row - above_row) / 2) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
159 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
160 // pum above "pum_win_row" |
800 | 161 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
162 if (State == MODE_CMDLINE) |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
163 // for cmdline pum, no need for context lines |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
164 context_lines = 0; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
165 else |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
166 { |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
167 // Leave two lines of context if possible |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
168 if (curwin->w_wrow - curwin->w_cline_row >= 2) |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
169 context_lines = 2; |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
170 else |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
171 context_lines = curwin->w_wrow - curwin->w_cline_row; |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
172 } |
1622 | 173 |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
174 if (pum_win_row >= size + context_lines) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
175 { |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
176 pum_row = pum_win_row - size - context_lines; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
177 pum_height = size; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
178 } |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
179 else |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
180 { |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
181 pum_row = 0; |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
182 pum_height = pum_win_row - context_lines; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
183 } |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
184 if (p_ph > 0 && pum_height > p_ph) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
185 { |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
186 pum_row += pum_height - p_ph; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
187 pum_height = p_ph; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
188 } |
800 | 189 } |
190 else | |
191 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
192 // pum below "pum_win_row" |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
193 |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
194 if (State == MODE_CMDLINE) |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
195 // for cmdline pum, no need for context lines |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
196 context_lines = 0; |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
197 else |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
198 { |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
199 // Leave two lines of context if possible |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
200 validate_cheight(); |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
201 if (curwin->w_cline_row |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
202 + curwin->w_cline_height - curwin->w_wrow >= 3) |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
203 context_lines = 3; |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
204 else |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
205 context_lines = curwin->w_cline_row |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
206 + curwin->w_cline_height - curwin->w_wrow; |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
207 } |
1622 | 208 |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
209 pum_row = pum_win_row + context_lines; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
210 if (size > below_row - pum_row) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
211 pum_height = below_row - pum_row; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
212 else |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
213 pum_height = size; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
214 if (p_ph > 0 && pum_height > p_ph) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
215 pum_height = p_ph; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
216 } |
1622 | 217 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
218 // don't display when we only have room for one line |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
219 if (pum_height < 1 || (pum_height == 1 && size > 1)) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
220 return; |
800 | 221 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
222 #if defined(FEAT_QUICKFIX) |
15087
6a74cde86252
patch 8.1.0554: popup menu overlaps with preview window
Bram Moolenaar <Bram@vim.org>
parents:
14952
diff
changeset
|
223 // If there is a preview window above avoid drawing over it. |
6a74cde86252
patch 8.1.0554: popup menu overlaps with preview window
Bram Moolenaar <Bram@vim.org>
parents:
14952
diff
changeset
|
224 if (pvwin != NULL && pum_row < above_row && pum_height > above_row) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
225 { |
15087
6a74cde86252
patch 8.1.0554: popup menu overlaps with preview window
Bram Moolenaar <Bram@vim.org>
parents:
14952
diff
changeset
|
226 pum_row = above_row; |
6a74cde86252
patch 8.1.0554: popup menu overlaps with preview window
Bram Moolenaar <Bram@vim.org>
parents:
14952
diff
changeset
|
227 pum_height = pum_win_row - above_row; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
228 } |
8220
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
229 #endif |
800 | 230 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
231 pum_array = array; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
232 pum_size = size; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
233 pum_compute_size(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
234 max_width = pum_base_width; |
800 | 235 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
236 // Calculate column |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
237 #ifdef FEAT_WILDMENU |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28457
diff
changeset
|
238 if (State == MODE_CMDLINE) |
27626
95d6e3c9aa1e
patch 8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Bram Moolenaar <Bram@vim.org>
parents:
27597
diff
changeset
|
239 // cmdline completion popup menu |
27597
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
240 cursor_col = cmdline_compl_startcol(); |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
241 else |
4eb2bf8b2f27
patch 8.2.4325: 'wildmenu' only shows few matches
Bram Moolenaar <Bram@vim.org>
parents:
26887
diff
changeset
|
242 #endif |
1344 | 243 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
244 if (right_left) |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
245 cursor_col = curwin->w_wincol + curwin->w_width |
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
246 - curwin->w_wcol - 1; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
247 else |
1344 | 248 #endif |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
249 cursor_col = curwin->w_wincol + curwin->w_wcol; |
1344 | 250 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
251 // if there are more items than room we need a scrollbar |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
252 if (pum_height < size) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
253 { |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
254 pum_scrollbar = 1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
255 ++max_width; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
256 } |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
257 else |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
258 pum_scrollbar = 0; |
800 | 259 |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
260 if (def_width < max_width) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
261 def_width = max_width; |
800 | 262 |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
263 if (((cursor_col < Columns - p_pw || cursor_col < Columns - max_width) |
1344 | 264 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
265 && !right_left) |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
266 || (right_left && (cursor_col > p_pw || cursor_col > max_width) |
1344 | 267 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
268 )) |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
269 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
270 // align pum with "cursor_col" |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
271 pum_col = cursor_col; |
1344 | 272 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
273 // start with the maximum space available |
1344 | 274 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
275 if (right_left) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
276 pum_width = pum_col - pum_scrollbar + 1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
277 else |
1344 | 278 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
279 pum_width = Columns - pum_col - pum_scrollbar; |
1344 | 280 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
281 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1 |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
282 && pum_width > p_pw) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
283 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
284 // the width is more than needed for the items, make it |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
285 // narrower |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
286 pum_width = max_width + pum_kind_width + pum_extra_width + 1; |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
287 if (pum_width < p_pw) |
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
288 pum_width = p_pw; |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
289 } |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
290 else if (((cursor_col > p_pw || cursor_col > max_width) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
291 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
292 && !right_left) |
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
293 || (right_left && (cursor_col < Columns - p_pw |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
294 || cursor_col < Columns - max_width) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
295 #endif |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
296 )) |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
297 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
298 // align pum edge with "cursor_col" |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
299 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
300 if (right_left |
13328
2c639a9a4def
patch 8.0.1538: popupmenu is too far left when completion is long
Christian Brabandt <cb@256bit.org>
parents:
13296
diff
changeset
|
301 && W_ENDCOL(curwin) < max_width + pum_scrollbar + 1) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
302 { |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
303 pum_col = cursor_col + max_width + pum_scrollbar + 1; |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
304 if (pum_col >= Columns) |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
305 pum_col = Columns - 1; |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
306 } |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
307 else if (!right_left) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
308 #endif |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
309 { |
13331
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
310 if (curwin->w_wincol > Columns - max_width - pum_scrollbar |
1ba4f926247c
patch 8.0.1540: popup menu positioning fails with longer string
Christian Brabandt <cb@256bit.org>
parents:
13328
diff
changeset
|
311 && max_width <= p_pw) |
13296
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
312 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
313 // use full width to end of the screen |
13296
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
314 pum_col = Columns - max_width - pum_scrollbar; |
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
315 if (pum_col < 0) |
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
316 pum_col = 0; |
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
317 } |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
318 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
319 |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
320 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
321 if (right_left) |
13296
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
322 pum_width = pum_col - pum_scrollbar + 1; |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
323 else |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
324 #endif |
13296
67345bc7fe31
patch 8.0.1522: popup menu is positioned in the wrong place
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
325 pum_width = Columns - pum_col - pum_scrollbar; |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
326 |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
327 if (pum_width < p_pw) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
328 { |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
329 pum_width = p_pw; |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
330 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
331 if (right_left) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
332 { |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
333 if (pum_width > pum_col) |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
334 pum_width = pum_col; |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
335 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
336 else |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
337 #endif |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
338 { |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
339 if (pum_width >= Columns - pum_col) |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
340 pum_width = Columns - pum_col - 1; |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
341 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
342 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
343 else if (pum_width > max_width + pum_kind_width |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
344 + pum_extra_width + 1 |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
345 && pum_width > p_pw) |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
346 { |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
347 pum_width = max_width + pum_kind_width |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
348 + pum_extra_width + 1; |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
349 if (pum_width < p_pw) |
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
350 pum_width = p_pw; |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
351 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
352 } |
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
353 |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
354 } |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
355 else if (Columns < def_width) |
800 | 356 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
357 // not enough room, will use what we have |
1344 | 358 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
359 if (right_left) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
360 pum_col = Columns - 1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
361 else |
1344 | 362 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
363 pum_col = 0; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
364 pum_width = Columns - 1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
365 } |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
366 else |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
367 { |
13242
5b0faf628a55
patch 8.0.1495: having 'pumwidth' default to zero has no merit
Christian Brabandt <cb@256bit.org>
parents:
13234
diff
changeset
|
368 if (max_width > p_pw) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
369 max_width = p_pw; // truncate |
1344 | 370 #ifdef FEAT_RIGHTLEFT |
28259
0f1a0bef2c02
patch 8.2.4655: cmdline completion popup menu positioned wrong
Bram Moolenaar <Bram@vim.org>
parents:
27626
diff
changeset
|
371 if (right_left) |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
372 pum_col = max_width - 1; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
373 else |
1344 | 374 #endif |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
375 pum_col = Columns - max_width; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
376 pum_width = max_width - pum_scrollbar; |
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
377 } |
800 | 378 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
379 // Set selected item and redraw. If the window size changed need to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
380 // redo the positioning. Limit this to two times, when there is not |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
381 // much room the window size will keep changing. |
12566
33a900199c25
patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
382 } while (pum_set_selected(selected, redo_count) && ++redo_count <= 2); |
22896
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
383 |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
384 pum_redraw(); |
800 | 385 } |
386 | |
387 /* | |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
388 * Set a flag that when pum_redraw() is called it first calls update_screen(). |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
389 * This will avoid clearing and redrawing the popup menu, prevent flicker. |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
390 */ |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
391 void |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
392 pum_call_update_screen() |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
393 { |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
394 call_update_screen = TRUE; |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
395 |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
396 // Update the cursor position to be able to compute the popup menu |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
397 // position. The cursor line length may have changed because of the |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
398 // inserted completion. |
15683
adc6442118b8
patch 8.1.0849: cursorline highlight is not always updated
Bram Moolenaar <Bram@vim.org>
parents:
15521
diff
changeset
|
399 curwin->w_valid &= ~(VALID_CROW|VALID_CHEIGHT); |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
400 validate_cursor(); |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
401 } |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
402 |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
403 /* |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
404 * Return TRUE if we are going to redraw the popup menu and the screen position |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
405 * "row"/"col" is under the popup menu. |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
406 */ |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
407 int |
26165
7b07f361b1d4
patch 8.2.3614: zindex of popup windows not used when redrawing popup menu
Bram Moolenaar <Bram@vim.org>
parents:
24551
diff
changeset
|
408 pum_under_menu(int row, int col, int only_redrawing) |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
409 { |
26165
7b07f361b1d4
patch 8.2.3614: zindex of popup windows not used when redrawing popup menu
Bram Moolenaar <Bram@vim.org>
parents:
24551
diff
changeset
|
410 return (!only_redrawing || pum_will_redraw) |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
411 && row >= pum_row |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
412 && row < pum_row + pum_height |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
413 && col >= pum_col - 1 |
24527
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
414 && col < pum_col + pum_width + pum_scrollbar; |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
415 } |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
416 |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
417 /* |
800 | 418 * Redraw the popup menu, using "pum_first" and "pum_selected". |
419 */ | |
420 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
421 pum_redraw(void) |
800 | 422 { |
423 int row = pum_row; | |
424 int col; | |
425 int attr_norm = highlight_attr[HLF_PNI]; | |
426 int attr_select = highlight_attr[HLF_PSI]; | |
427 int attr_scroll = highlight_attr[HLF_PSB]; | |
428 int attr_thumb = highlight_attr[HLF_PST]; | |
429 int attr; | |
430 int i; | |
431 int idx; | |
432 char_u *s; | |
433 char_u *p = NULL; | |
434 int totwidth, width, w; | |
435 int thumb_pos = 0; | |
15967
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
436 int thumb_height = 1; |
800 | 437 int round; |
438 int n; | |
439 | |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
440 if (call_update_screen) |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
441 { |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
442 call_update_screen = FALSE; |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
443 // Do not redraw in pum_may_redraw() and don't draw in the area where |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
444 // the popup menu will be. |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
445 pum_will_redraw = TRUE; |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
446 update_screen(0); |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
447 pum_will_redraw = FALSE; |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
448 } |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
449 |
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
450 // never display more than we have |
5444 | 451 if (pum_first > pum_size - pum_height) |
452 pum_first = pum_size - pum_height; | |
453 | |
800 | 454 if (pum_scrollbar) |
455 { | |
15967
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
456 thumb_height = pum_height * pum_height / pum_size; |
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
457 if (thumb_height == 0) |
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
458 thumb_height = 1; |
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
459 thumb_pos = (pum_first * (pum_height - thumb_height) |
800 | 460 + (pum_size - pum_height) / 2) |
461 / (pum_size - pum_height); | |
462 } | |
463 | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
464 #ifdef FEAT_PROP_POPUP |
16986
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
465 // The popup menu is drawn over popup menus with zindex under |
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
466 // POPUPMENU_ZINDEX. |
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
467 screen_zindex = POPUPMENU_ZINDEX; |
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
468 #endif |
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
469 |
800 | 470 for (i = 0; i < pum_height; ++i) |
471 { | |
472 idx = i + pum_first; | |
473 attr = (idx == pum_selected) ? attr_select : attr_norm; | |
474 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
475 // prepend a space if there is room |
1344 | 476 #ifdef FEAT_RIGHTLEFT |
477 if (curwin->w_p_rl) | |
478 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
479 if (pum_col < curwin->w_wincol + curwin->w_width - 1) |
1344 | 480 screen_putchar(' ', row, pum_col + 1, attr); |
481 } | |
482 else | |
483 #endif | |
484 if (pum_col > 0) | |
485 screen_putchar(' ', row, pum_col - 1, attr); | |
800 | 486 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
487 // Display each entry, use two spaces for a Tab. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
488 // Do this 3 times: For the main text, kind and extra info |
800 | 489 col = pum_col; |
490 totwidth = 0; | |
491 for (round = 1; round <= 3; ++round) | |
492 { | |
493 width = 0; | |
494 s = NULL; | |
495 switch (round) | |
496 { | |
497 case 1: p = pum_array[idx].pum_text; break; | |
498 case 2: p = pum_array[idx].pum_kind; break; | |
499 case 3: p = pum_array[idx].pum_extra; break; | |
500 } | |
501 if (p != NULL) | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
502 for ( ; ; MB_PTR_ADV(p)) |
800 | 503 { |
504 if (s == NULL) | |
505 s = p; | |
506 w = ptr2cells(p); | |
507 if (*p == NUL || *p == TAB || totwidth + w > pum_width) | |
508 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
509 // Display the text that fits or comes before a Tab. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
510 // First convert it to printable characters. |
1344 | 511 char_u *st; |
512 int saved = *p; | |
1097 | 513 |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
514 if (saved != NUL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
515 *p = NUL; |
1097 | 516 st = transstr(s); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
517 if (saved != NUL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
518 *p = saved; |
1344 | 519 #ifdef FEAT_RIGHTLEFT |
520 if (curwin->w_p_rl) | |
1097 | 521 { |
1344 | 522 if (st != NULL) |
523 { | |
524 char_u *rt = reverse_text(st); | |
525 | |
526 if (rt != NULL) | |
527 { | |
2056
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
528 char_u *rt_start = rt; |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
529 int size; |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
530 |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
531 size = vim_strsize(rt); |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
532 if (size > pum_width) |
1344 | 533 { |
2056
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
534 do |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
535 { |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
536 size -= has_mbyte |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
537 ? (*mb_ptr2cells)(rt) : 1; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11121
diff
changeset
|
538 MB_PTR_ADV(rt); |
2056
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
539 } while (size > pum_width); |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
540 |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
541 if (size < pum_width) |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
542 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
543 // Most left character requires |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
544 // 2-cells but only 1 cell is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
545 // available on screen. Put a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
546 // '<' on the left of the pum |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
547 // item |
2056
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
548 *(--rt) = '<'; |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
549 size++; |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
550 } |
1344 | 551 } |
2056
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
552 screen_puts_len(rt, (int)STRLEN(rt), |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
553 row, col - size + 1, attr); |
e9e3355861ba
updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents:
1743
diff
changeset
|
554 vim_free(rt_start); |
1344 | 555 } |
556 vim_free(st); | |
557 } | |
558 col -= width; | |
559 } | |
560 else | |
561 #endif | |
562 { | |
563 if (st != NULL) | |
564 { | |
22896
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
565 int size = (int)STRLEN(st); |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
566 int cells = (*mb_string2cells)(st, size); |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
567 |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
568 // only draw the text that fits |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
569 while (size > 0 |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
570 && col + cells > pum_width + pum_col) |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
571 { |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
572 --size; |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
573 if (has_mbyte) |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
574 { |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
575 size -= (*mb_head_off)(st, st + size); |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
576 cells -= (*mb_ptr2cells)(st + size); |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
577 } |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
578 else |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
579 --cells; |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
580 } |
6145a1232c3a
patch 8.2.1995: the popup menu can cause too much redrawing
Bram Moolenaar <Bram@vim.org>
parents:
22884
diff
changeset
|
581 screen_puts_len(st, size, row, col, attr); |
1344 | 582 vim_free(st); |
583 } | |
584 col += width; | |
1097 | 585 } |
800 | 586 |
587 if (*p != TAB) | |
588 break; | |
589 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
590 // Display two spaces for a Tab. |
1344 | 591 #ifdef FEAT_RIGHTLEFT |
592 if (curwin->w_p_rl) | |
593 { | |
594 screen_puts_len((char_u *)" ", 2, row, col - 1, | |
595 attr); | |
596 col -= 2; | |
597 } | |
598 else | |
599 #endif | |
600 { | |
601 screen_puts_len((char_u *)" ", 2, row, col, attr); | |
602 col += 2; | |
603 } | |
800 | 604 totwidth += 2; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
605 s = NULL; // start text at next char |
800 | 606 width = 0; |
607 } | |
608 else | |
609 width += w; | |
610 } | |
611 | |
612 if (round > 1) | |
613 n = pum_kind_width + 1; | |
614 else | |
615 n = 1; | |
616 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
617 // Stop when there is nothing more to display. |
800 | 618 if (round == 3 |
619 || (round == 2 && pum_array[idx].pum_extra == NULL) | |
620 || (round == 1 && pum_array[idx].pum_kind == NULL | |
621 && pum_array[idx].pum_extra == NULL) | |
622 || pum_base_width + n >= pum_width) | |
623 break; | |
1344 | 624 #ifdef FEAT_RIGHTLEFT |
625 if (curwin->w_p_rl) | |
626 { | |
627 screen_fill(row, row + 1, pum_col - pum_base_width - n + 1, | |
628 col + 1, ' ', ' ', attr); | |
629 col = pum_col - pum_base_width - n + 1; | |
630 } | |
631 else | |
632 #endif | |
633 { | |
634 screen_fill(row, row + 1, col, pum_col + pum_base_width + n, | |
800 | 635 ' ', ' ', attr); |
1344 | 636 col = pum_col + pum_base_width + n; |
637 } | |
800 | 638 totwidth = pum_base_width + n; |
639 } | |
640 | |
1344 | 641 #ifdef FEAT_RIGHTLEFT |
642 if (curwin->w_p_rl) | |
643 screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ', | |
644 ' ', attr); | |
645 else | |
646 #endif | |
647 screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', | |
648 attr); | |
800 | 649 if (pum_scrollbar > 0) |
1344 | 650 { |
651 #ifdef FEAT_RIGHTLEFT | |
652 if (curwin->w_p_rl) | |
653 screen_putchar(' ', row, pum_col - pum_width, | |
15967
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
654 i >= thumb_pos && i < thumb_pos + thumb_height |
800 | 655 ? attr_thumb : attr_scroll); |
1344 | 656 else |
657 #endif | |
658 screen_putchar(' ', row, pum_col + pum_width, | |
15967
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15683
diff
changeset
|
659 i >= thumb_pos && i < thumb_pos + thumb_height |
1344 | 660 ? attr_thumb : attr_scroll); |
661 } | |
800 | 662 |
663 ++row; | |
664 } | |
16986
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
665 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
666 #ifdef FEAT_PROP_POPUP |
16986
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
667 screen_zindex = 0; |
03f3a9ca2770
patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
16845
diff
changeset
|
668 #endif |
800 | 669 } |
670 | |
18767
068337e86133
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
671 #if (defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)) || defined(PROTO) |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
672 /* |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
673 * Position the info popup relative to the popup menu item. |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
674 */ |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
675 void |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
676 pum_position_info_popup(win_T *wp) |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
677 { |
18665
7369756d05de
patch 8.1.2324: with of scrollbar in popup menu not taken into account
Bram Moolenaar <Bram@vim.org>
parents:
18560
diff
changeset
|
678 int col = pum_col + pum_width + pum_scrollbar + 1; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
679 int row = pum_row; |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
680 int botpos = POPPOS_BOTLEFT; |
21377
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
681 int used_maxwidth_opt = FALSE; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
682 |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
683 wp->w_popup_pos = POPPOS_TOPLEFT; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
684 if (Columns - col < 20 && Columns - col < pum_col) |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
685 { |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
686 col = pum_col - 1; |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
687 wp->w_popup_pos = POPPOS_TOPRIGHT; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
688 botpos = POPPOS_BOTRIGHT; |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
689 wp->w_maxwidth = pum_col - 1; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
690 } |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
691 else |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
692 wp->w_maxwidth = Columns - col + 1; |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
693 wp->w_maxwidth -= popup_extra_width(wp); |
21377
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
694 if (wp->w_maxwidth_opt > 0 && wp->w_maxwidth > wp->w_maxwidth_opt) |
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
695 { |
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
696 // option value overrules computed value |
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
697 wp->w_maxwidth = wp->w_maxwidth_opt; |
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
698 used_maxwidth_opt = TRUE; |
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
699 } |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
700 |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
701 row -= popup_top_extra(wp); |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
702 if (wp->w_popup_flags & POPF_INFO_MENU) |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
703 { |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
704 if (pum_row < pum_win_row) |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
705 { |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
706 // menu above cursor line, align with bottom |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
707 row += pum_height; |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
708 wp->w_popup_pos = botpos; |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
709 } |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
710 else |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
711 // menu below cursor line, align with top |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
712 row += 1; |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
713 } |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
714 else |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
715 // align with the selected item |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
716 row += pum_selected - pum_first + 1; |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
717 |
18823
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
718 wp->w_popup_flags &= ~POPF_HIDDEN; |
21377
47f25a0c5a42
patch 8.2.1239: "maxwidth" in 'completepopup' not obeyed
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
719 if (wp->w_maxwidth < 10 && !used_maxwidth_opt) |
18823
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
720 // The popup is not going to fit or will overlap with the cursor |
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
721 // position, hide the popup. |
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
722 wp->w_popup_flags |= POPF_HIDDEN; |
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
723 else |
ae2bd5ec98d0
patch 8.1.2399: info popup on top of cursor if it doesn't fit
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
724 popup_set_wantpos_rowcol(wp, row, col); |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
725 } |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
726 #endif |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
727 |
800 | 728 /* |
729 * Set the index of the currently selected item. The menu will scroll when | |
730 * necessary. When "n" is out of range don't scroll. | |
838 | 731 * This may be repeated when the preview window is used: |
732 * "repeat" == 0: open preview window normally | |
733 * "repeat" == 1: open preview window but don't set the size | |
734 * "repeat" == 2: don't open preview window | |
800 | 735 * Returns TRUE when the window was resized and the location of the popup menu |
736 * must be recomputed. | |
737 */ | |
738 static int | |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17811
diff
changeset
|
739 pum_set_selected(int n, int repeat UNUSED) |
800 | 740 { |
741 int resized = FALSE; | |
742 int context = pum_height / 2; | |
17799
87c5c07a4cac
patch 8.1.1896: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
743 #ifdef FEAT_QUICKFIX |
17775
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
744 int prev_selected = pum_selected; |
17799
87c5c07a4cac
patch 8.1.1896: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
17775
diff
changeset
|
745 #endif |
18767
068337e86133
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
746 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
747 int has_info = FALSE; |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
748 #endif |
800 | 749 |
750 pum_selected = n; | |
751 | |
752 if (pum_selected >= 0 && pum_selected < pum_size) | |
753 { | |
754 if (pum_first > pum_selected - 4) | |
755 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
756 // scroll down; when we did a jump it's probably a PageUp then |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
757 // scroll a whole page |
800 | 758 if (pum_first > pum_selected - 2) |
759 { | |
760 pum_first -= pum_height - 2; | |
761 if (pum_first < 0) | |
762 pum_first = 0; | |
763 else if (pum_first > pum_selected) | |
764 pum_first = pum_selected; | |
765 } | |
766 else | |
767 pum_first = pum_selected; | |
768 } | |
769 else if (pum_first < pum_selected - pum_height + 5) | |
770 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
771 // scroll up; when we did a jump it's probably a PageDown then |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
772 // scroll a whole page |
800 | 773 if (pum_first < pum_selected - pum_height + 1 + 2) |
774 { | |
775 pum_first += pum_height - 2; | |
776 if (pum_first < pum_selected - pum_height + 1) | |
777 pum_first = pum_selected - pum_height + 1; | |
778 } | |
779 else | |
780 pum_first = pum_selected - pum_height + 1; | |
781 } | |
782 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
783 // Give a few lines of context when possible. |
800 | 784 if (context > 3) |
785 context = 3; | |
786 if (pum_height > 2) | |
787 { | |
788 if (pum_first > pum_selected - context) | |
789 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
790 // scroll down |
800 | 791 pum_first = pum_selected - context; |
792 if (pum_first < 0) | |
793 pum_first = 0; | |
794 } | |
795 else if (pum_first < pum_selected + context - pum_height + 1) | |
796 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
797 // scroll up |
800 | 798 pum_first = pum_selected + context - pum_height + 1; |
799 } | |
800 } | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
801 // adjust for the number of lines displayed |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
802 if (pum_first > pum_size - pum_height) |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
803 pum_first = pum_size - pum_height; |
800 | 804 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
805 #if defined(FEAT_QUICKFIX) |
816 | 806 /* |
807 * Show extra info in the preview window if there is something and | |
18665
7369756d05de
patch 8.1.2324: with of scrollbar in popup menu not taken into account
Bram Moolenaar <Bram@vim.org>
parents:
18560
diff
changeset
|
808 * 'completeopt' contains "preview" or "popup" or "popuphidden". |
838 | 809 * Skip this when tried twice already. |
810 * Skip this also when there is not much room. | |
816 | 811 * NOTE: Be very careful not to sync undo! |
812 */ | |
800 | 813 if (pum_array[pum_selected].pum_info != NULL |
838 | 814 && Rows > 10 |
815 && repeat <= 1 | |
816 && vim_strchr(p_cot, 'p') != NULL) | |
800 | 817 { |
818 win_T *curwin_save = curwin; | |
12690
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
819 tabpage_T *curtab_save = curtab; |
800 | 820 int res = OK; |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
821 # ifdef FEAT_PROP_POPUP |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
822 use_popup_T use_popup; |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
823 # else |
18759
592c7b56db69
patch 8.1.2369: cannot build with quickfix and without text properties
Bram Moolenaar <Bram@vim.org>
parents:
18667
diff
changeset
|
824 # define use_popup USEPOPUP_NONE |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
825 # endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
826 # ifdef FEAT_PROP_POPUP |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
827 has_info = TRUE; |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
828 if (strstr((char *)p_cot, "popuphidden") != NULL) |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
829 use_popup = USEPOPUP_HIDDEN; |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
830 else if (strstr((char *)p_cot, "popup") != NULL) |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
831 use_popup = USEPOPUP_NORMAL; |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
832 else |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
833 use_popup = USEPOPUP_NONE; |
22884
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
834 if (use_popup != USEPOPUP_NONE) |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
835 // don't use WinEnter or WinLeave autocommands for the info |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
836 // popup |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
837 block_autocmds(); |
17950
bb0e25a8b5d7
patch 8.1.1971: manually enabling features causes build errors
Bram Moolenaar <Bram@vim.org>
parents:
17819
diff
changeset
|
838 # endif |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
839 // Open a preview window and set "curwin" to it. |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
840 // 3 lines by default, prefer 'previewheight' if set and smaller. |
800 | 841 g_do_tagpreview = 3; |
2622 | 842 if (p_pvh > 0 && p_pvh < g_do_tagpreview) |
843 g_do_tagpreview = p_pvh; | |
6043 | 844 ++RedrawingDisabled; |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
845 // Prevent undo sync here, if an autocommand syncs undo weird |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
846 // things can happen to the undo tree. |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
847 ++no_u_sync; |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
848 resized = prepare_tagpreview(FALSE, FALSE, use_popup); |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
849 --no_u_sync; |
6043 | 850 --RedrawingDisabled; |
800 | 851 g_do_tagpreview = 0; |
852 | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
853 if (curwin->w_p_pvw |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
854 # ifdef FEAT_PROP_POPUP |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
855 || (curwin->w_popup_flags & POPF_INFO) |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
856 # endif |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
857 ) |
800 | 858 { |
10302
210af8588e8a
commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
859 if (!resized |
210af8588e8a
commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
860 && curbuf->b_nwindows == 1 |
210af8588e8a
commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
861 && curbuf->b_fname == NULL |
17095
10e0d7d96cb0
patch 8.1.1547: functionality of bt_nofile() is confusing
Bram Moolenaar <Bram@vim.org>
parents:
16986
diff
changeset
|
862 && bt_nofile(curbuf) |
800 | 863 && curbuf->b_p_bh[0] == 'w') |
864 { | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
865 // Already a "wipeout" buffer, make it empty. |
11121
778c10516955
patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10410
diff
changeset
|
866 while (!BUFEMPTY()) |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20392
diff
changeset
|
867 ml_delete((linenr_T)1); |
800 | 868 } |
825 | 869 else |
800 | 870 { |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
871 // Don't want to sync undo in the current buffer. |
825 | 872 ++no_u_sync; |
1743 | 873 res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL); |
825 | 874 --no_u_sync; |
875 if (res == OK) | |
876 { | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
877 // Edit a new, empty buffer. Set options for a "wipeout" |
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
878 // buffer. |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
879 set_option_value_give_err((char_u *)"swf", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
880 0L, NULL, OPT_LOCAL); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
881 set_option_value_give_err((char_u *)"bl", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
882 0L, NULL, OPT_LOCAL); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
883 set_option_value_give_err((char_u *)"bt", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
884 0L, (char_u *)"nofile", OPT_LOCAL); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
885 set_option_value_give_err((char_u *)"bh", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
886 0L, (char_u *)"wipe", OPT_LOCAL); |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
887 set_option_value_give_err((char_u *)"diff", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
28259
diff
changeset
|
888 0L, NULL, OPT_LOCAL); |
825 | 889 } |
800 | 890 } |
891 if (res == OK) | |
892 { | |
893 char_u *p, *e; | |
894 linenr_T lnum = 0; | |
895 | |
896 for (p = pum_array[pum_selected].pum_info; *p != NUL; ) | |
897 { | |
898 e = vim_strchr(p, '\n'); | |
899 if (e == NULL) | |
900 { | |
901 ml_append(lnum++, p, 0, FALSE); | |
902 break; | |
903 } | |
904 else | |
905 { | |
906 *e = NUL; | |
835 | 907 ml_append(lnum++, p, (int)(e - p + 1), FALSE); |
800 | 908 *e = '\n'; |
909 p = e + 1; | |
910 } | |
911 } | |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
912 // delete the empty last line |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20392
diff
changeset
|
913 ml_delete(curbuf->b_ml.ml_line_count); |
800 | 914 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
915 // Increase the height of the preview window to show the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
916 // text, but no more than 'previewheight' lines. |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
917 if (repeat == 0 && use_popup == USEPOPUP_NONE) |
800 | 918 { |
838 | 919 if (lnum > p_pvh) |
920 lnum = p_pvh; | |
921 if (curwin->w_height < lnum) | |
922 { | |
923 win_setheight((int)lnum); | |
924 resized = TRUE; | |
925 } | |
800 | 926 } |
927 | |
928 curbuf->b_changed = 0; | |
929 curbuf->b_p_ma = FALSE; | |
17775
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
930 if (pum_selected != prev_selected) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
931 { |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
932 # ifdef FEAT_PROP_POPUP |
17775
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
933 curwin->w_firstline = 1; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
934 # endif |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
935 curwin->w_topline = 1; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
936 } |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
937 else if (curwin->w_topline > curbuf->b_ml.ml_line_count) |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
938 curwin->w_topline = curbuf->b_ml.ml_line_count; |
b423bd231f33
patch 8.1.1884: cannot use mouse scroll wheel in popup in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
939 curwin->w_cursor.lnum = curwin->w_topline; |
800 | 940 curwin->w_cursor.col = 0; |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
941 # ifdef FEAT_PROP_POPUP |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
942 if (use_popup != USEPOPUP_NONE) |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
943 { |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
944 pum_position_info_popup(curwin); |
17819
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
945 if (win_valid(curwin_save)) |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
946 redraw_win_later(curwin_save, SOME_VALID); |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
947 } |
1f74a3c600a3
patch 8.1.1906: info popup size is sometimes incorrect
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
948 # endif |
12690
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
949 if ((curwin != curwin_save && win_valid(curwin_save)) |
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
950 || (curtab != curtab_save |
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
951 && valid_tabpage(curtab_save))) |
800 | 952 { |
24551
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
953 int save_redr_status; |
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
954 |
12690
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
955 if (curtab != curtab_save && valid_tabpage(curtab_save)) |
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
956 goto_tabpage_tp(curtab_save, FALSE, FALSE); |
fad36581f788
patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents:
12566
diff
changeset
|
957 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
958 // When the first completion is done and the preview |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
959 // window is not resized, skip the preview window's |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
960 // status line redrawing. |
6089 | 961 if (ins_compl_active() && !resized) |
962 curwin->w_redr_status = FALSE; | |
963 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
964 // Return cursor to where we were |
800 | 965 validate_cursor(); |
966 redraw_later(SOME_VALID); | |
967 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
968 // When the preview window was resized we need to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
969 // update the view on the buffer. Only go back to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
970 // the window when needed, otherwise it will always be |
18900
a9c47c623f4a
patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
971 // redrawn. |
17706
431d52b7f7d3
patch 8.1.1850: focus may remain in popup window
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
972 if (resized && win_valid(curwin_save)) |
800 | 973 { |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
974 ++no_u_sync; |
800 | 975 win_enter(curwin_save, TRUE); |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
976 --no_u_sync; |
800 | 977 update_topline(); |
978 } | |
979 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
980 // Update the screen before drawing the popup menu. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
981 // Enable updating the status lines. |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
982 pum_pretend_not_visible = TRUE; |
24551
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
983 |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
984 // But don't draw text at the new popup menu position, |
18900
a9c47c623f4a
patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
985 // it causes flicker. When resizing we need to draw |
a9c47c623f4a
patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
986 // anyway, the position may change later. |
24551
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
987 // Also do not redraw the status line of the original |
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
988 // current window here, to avoid it gets drawn with |
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
989 // StatusLineNC for a moment and cause flicker. |
18900
a9c47c623f4a
patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
990 pum_will_redraw = !resized; |
24551
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
991 save_redr_status = curwin_save->w_redr_status; |
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
992 curwin_save->w_redr_status = FALSE; |
800 | 993 update_screen(0); |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
994 pum_pretend_not_visible = FALSE; |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
995 pum_will_redraw = FALSE; |
24551
aa04faf1590d
patch 8.2.2815: status line flickers when redrawing popup menu info
Bram Moolenaar <Bram@vim.org>
parents:
24527
diff
changeset
|
996 curwin_save->w_redr_status = save_redr_status; |
800 | 997 |
816 | 998 if (!resized && win_valid(curwin_save)) |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
999 { |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
1000 # ifdef FEAT_PROP_POPUP |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
1001 win_T *wp = curwin; |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
1002 # endif |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
1003 ++no_u_sync; |
800 | 1004 win_enter(curwin_save, TRUE); |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
1005 --no_u_sync; |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
1006 # ifdef FEAT_PROP_POPUP |
18396
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
1007 if (use_popup == USEPOPUP_HIDDEN && win_valid(wp)) |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
1008 popup_hide(wp); |
ba5d8c5d77d7
patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents:
18251
diff
changeset
|
1009 # endif |
7181
ce8b286e89ef
commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents:
6089
diff
changeset
|
1010 } |
800 | 1011 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1012 // May need to update the screen again when there are |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1013 // autocommands involved. |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1014 pum_pretend_not_visible = TRUE; |
18900
a9c47c623f4a
patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents:
18892
diff
changeset
|
1015 pum_will_redraw = !resized; |
800 | 1016 update_screen(0); |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1017 pum_pretend_not_visible = FALSE; |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1018 pum_will_redraw = FALSE; |
15521
6d949e552e99
patch 8.1.0768: updating completions may cause the popup menu to flicker
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1019 call_update_screen = FALSE; |
800 | 1020 } |
1021 } | |
1022 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
1023 # if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
17706
431d52b7f7d3
patch 8.1.1850: focus may remain in popup window
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1024 if (WIN_IS_POPUP(curwin)) |
431d52b7f7d3
patch 8.1.1850: focus may remain in popup window
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1025 // can't keep focus in a popup window |
431d52b7f7d3
patch 8.1.1850: focus may remain in popup window
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1026 win_enter(firstwin, TRUE); |
431d52b7f7d3
patch 8.1.1850: focus may remain in popup window
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
1027 # endif |
22884
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
1028 # ifdef FEAT_PROP_POPUP |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
1029 if (use_popup != USEPOPUP_NONE) |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
1030 unblock_autocmds(); |
68dc849715b5
patch 8.2.1989: info popup triggers WinEnter and WinLeave autocommands
Bram Moolenaar <Bram@vim.org>
parents:
21377
diff
changeset
|
1031 # endif |
800 | 1032 } |
1033 #endif | |
1034 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
1035 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
1036 if (!has_info) |
17817
e8a7029efa40
patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents:
17815
diff
changeset
|
1037 // hide any popup info window |
e8a7029efa40
patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents:
17815
diff
changeset
|
1038 popup_hide_info(); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1039 #endif |
800 | 1040 |
1041 return resized; | |
1042 } | |
1043 | |
1044 /* | |
1045 * Undisplay the popup menu (later). | |
1046 */ | |
1047 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1048 pum_undisplay(void) |
800 | 1049 { |
1050 pum_array = NULL; | |
13944
ddf02a93796f
patch 8.0.1842: popup menu inside terminal window isn't cleared
Christian Brabandt <cb@256bit.org>
parents:
13427
diff
changeset
|
1051 redraw_all_later(NOT_VALID); |
940 | 1052 redraw_tabline = TRUE; |
800 | 1053 status_redraw_all(); |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18759
diff
changeset
|
1054 #if defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX) |
17817
e8a7029efa40
patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents:
17815
diff
changeset
|
1055 // hide any popup info window |
e8a7029efa40
patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents:
17815
diff
changeset
|
1056 popup_hide_info(); |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17706
diff
changeset
|
1057 #endif |
800 | 1058 } |
1059 | |
1060 /* | |
1061 * Clear the popup menu. Currently only resets the offset to the first | |
1062 * displayed item. | |
1063 */ | |
1064 void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1065 pum_clear(void) |
800 | 1066 { |
1067 pum_first = 0; | |
1068 } | |
1069 | |
1070 /* | |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1071 * Return TRUE if the popup menu is displayed. Used to avoid some redrawing |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1072 * that could overwrite it. Overruled when "pum_pretend_not_visible" is set, |
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1073 * used to redraw the status lines. |
800 | 1074 */ |
1075 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1076 pum_visible(void) |
800 | 1077 { |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1078 return !pum_pretend_not_visible && pum_array != NULL; |
800 | 1079 } |
1080 | |
1081 /* | |
24527
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1082 * Return TRUE if the popup can be redrawn in the same position. |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1083 */ |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1084 static int |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1085 pum_in_same_position(void) |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1086 { |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1087 return pum_window != curwin |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1088 || (pum_win_row == curwin->w_wrow + W_WINROW(curwin) |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1089 && pum_win_height == curwin->w_height |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1090 && pum_win_col == curwin->w_wincol |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1091 && pum_win_width == curwin->w_width); |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1092 } |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1093 |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1094 /* |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1095 * Return TRUE when pum_may_redraw() will call pum_redraw(). |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1096 * This means that the pum area should not be overwritten to avoid flicker. |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1097 */ |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1098 int |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1099 pum_redraw_in_same_position(void) |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1100 { |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1101 if (!pum_visible() || pum_will_redraw) |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1102 return FALSE; // nothing to do |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1103 |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1104 return pum_in_same_position(); |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1105 } |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1106 |
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1107 /* |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1108 * Reposition the popup menu to adjust for window layout changes. |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1109 */ |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1110 void |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1111 pum_may_redraw(void) |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1112 { |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1113 pumitem_T *array = pum_array; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1114 int len = pum_size; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1115 int selected = pum_selected; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1116 |
18858
539c05ea2d3a
patch 8.1.2415: popup menu flickers if an info popup is used
Bram Moolenaar <Bram@vim.org>
parents:
18823
diff
changeset
|
1117 if (!pum_visible() || pum_will_redraw) |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1118 return; // nothing to do |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1119 |
24527
a878e5e892cf
patch 8.2.2803: flicker when the popup menu has an info popup
Bram Moolenaar <Bram@vim.org>
parents:
23328
diff
changeset
|
1120 if (pum_in_same_position()) |
14089
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1121 { |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1122 // window position didn't change, redraw in the same position |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1123 pum_redraw(); |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1124 } |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1125 else |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1126 { |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1127 int wcol = curwin->w_wcol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1128 |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1129 // Window layout changed, recompute the position. |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1130 // Use the remembered w_wcol value, the cursor may have moved when a |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1131 // completion was inserted, but we want the menu in the same position. |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1132 pum_undisplay(); |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1133 curwin->w_wcol = pum_win_wcol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1134 curwin->w_valid |= VALID_WCOL; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1135 pum_display(array, len, selected); |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1136 curwin->w_wcol = wcol; |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1137 } |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1138 } |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1139 |
ae53a9274f50
patch 8.1.0062: popup menu broken if a callback changes the window layout
Christian Brabandt <cb@256bit.org>
parents:
13944
diff
changeset
|
1140 /* |
800 | 1141 * Return the height of the popup menu, the number of entries visible. |
1142 * Only valid when pum_visible() returns TRUE! | |
1143 */ | |
1144 int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1145 pum_get_height(void) |
800 | 1146 { |
1147 return pum_height; | |
1148 } | |
1149 | |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17811
diff
changeset
|
1150 #if defined(FEAT_EVAL) || defined(PROTO) |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1151 /* |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1152 * Add size information about the pum to "dict". |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1153 */ |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1154 void |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1155 pum_set_event_info(dict_T *dict) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1156 { |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1157 if (!pum_visible()) |
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1158 return; |
19673
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1159 (void)dict_add_number(dict, "height", pum_height); |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1160 (void)dict_add_number(dict, "width", pum_width); |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1161 (void)dict_add_number(dict, "row", pum_row); |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1162 (void)dict_add_number(dict, "col", pum_col); |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1163 (void)dict_add_number(dict, "size", pum_size); |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1164 (void)dict_add_bool(dict, "scrollbar", |
62ea983a9cb4
patch 8.2.0393: Coverity warns for not using return value
Bram Moolenaar <Bram@vim.org>
parents:
19201
diff
changeset
|
1165 pum_scrollbar ? VVAL_TRUE : VVAL_FALSE); |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1166 } |
17813
8ca20b0a3dc3
patch 8.1.1903: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
17811
diff
changeset
|
1167 #endif |
16268
0f65f2808470
patch 8.1.1138: plugins don't get notified when the popup menu changes
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
1168 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1169 #if defined(FEAT_BEVAL_TERM) || defined(FEAT_TERM_POPUP_MENU) || defined(PROTO) |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1170 static void |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1171 pum_position_at_mouse(int min_width) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1172 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1173 if (Rows - mouse_row > pum_size) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1174 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1175 // Enough space below the mouse row. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1176 pum_row = mouse_row + 1; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1177 if (pum_height > Rows - pum_row) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1178 pum_height = Rows - pum_row; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1179 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1180 else |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1181 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1182 // Show above the mouse row, reduce height if it does not fit. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1183 pum_row = mouse_row - pum_size; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1184 if (pum_row < 0) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1185 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1186 pum_height += pum_row; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1187 pum_row = 0; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1188 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1189 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1190 if (Columns - mouse_col >= pum_base_width |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1191 || Columns - mouse_col > min_width) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1192 // Enough space to show at mouse column. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1193 pum_col = mouse_col; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1194 else |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1195 // Not enough space, right align with window. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1196 pum_col = Columns - (pum_base_width > min_width |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1197 ? min_width : pum_base_width); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1198 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1199 pum_width = Columns - pum_col; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1200 if (pum_width > pum_base_width + 1) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1201 pum_width = pum_base_width + 1; |
14095
f452c4aeb837
patch 8.1.0065: balloon displayed at the wrong position
Christian Brabandt <cb@256bit.org>
parents:
14089
diff
changeset
|
1202 |
f452c4aeb837
patch 8.1.0065: balloon displayed at the wrong position
Christian Brabandt <cb@256bit.org>
parents:
14089
diff
changeset
|
1203 // Do not redraw at cursor position. |
f452c4aeb837
patch 8.1.0065: balloon displayed at the wrong position
Christian Brabandt <cb@256bit.org>
parents:
14089
diff
changeset
|
1204 pum_window = NULL; |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1205 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1206 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1207 #endif |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1208 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1209 #if defined(FEAT_BEVAL_TERM) || defined(PROTO) |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1210 static pumitem_T *balloon_array = NULL; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1211 static int balloon_arraysize; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1212 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1213 # define BALLOON_MIN_WIDTH 50 |
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1214 # define BALLOON_MIN_HEIGHT 10 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1215 |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1216 typedef struct { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1217 char_u *start; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1218 int bytelen; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1219 int cells; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1220 int indent; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1221 } balpart_T; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1222 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1223 /* |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1224 * Split a string into parts to display in the balloon. |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1225 * Aimed at output from gdb. Attempts to split at white space, preserve quoted |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1226 * strings and make a struct look good. |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1227 * Resulting array is stored in "array" and returns the size of the array. |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1228 */ |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1229 int |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1230 split_message(char_u *mesg, pumitem_T **array) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1231 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1232 garray_T ga; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1233 char_u *p; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1234 balpart_T *item; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1235 int quoted = FALSE; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1236 int height; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1237 int line; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1238 int item_idx; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1239 int indent = 0; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1240 int max_cells = 0; |
18560
81272918c0ea
patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
18396
diff
changeset
|
1241 int max_height = Rows / 2 - 1; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1242 int long_item_count = 0; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1243 int split_long_items = FALSE; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1244 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1245 ga_init2(&ga, sizeof(balpart_T), 20); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1246 p = mesg; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1247 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1248 while (*p != NUL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1249 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1250 if (ga_grow(&ga, 1) == FAIL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1251 goto failed; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1252 item = ((balpart_T *)ga.ga_data) + ga.ga_len; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1253 item->start = p; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1254 item->indent = indent; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1255 item->cells = indent * 2; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1256 ++ga.ga_len; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1257 while (*p != NUL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1258 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1259 if (*p == '"') |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1260 quoted = !quoted; |
18560
81272918c0ea
patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
18396
diff
changeset
|
1261 else if (*p == '\n') |
81272918c0ea
patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
18396
diff
changeset
|
1262 break; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1263 else if (*p == '\\' && p[1] != NUL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1264 ++p; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1265 else if (!quoted) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1266 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1267 if ((*p == ',' && p[1] == ' ') || *p == '{' || *p == '}') |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1268 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1269 // Looks like a good point to break. |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1270 if (*p == '{') |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1271 ++indent; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1272 else if (*p == '}' && indent > 0) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1273 --indent; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1274 ++item->cells; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1275 p = skipwhite(p + 1); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1276 break; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1277 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1278 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1279 item->cells += ptr2cells(p); |
18251
c8a53c0daeed
patch 8.1.2120: some MB_ macros are more complicated than necessary
Bram Moolenaar <Bram@vim.org>
parents:
18174
diff
changeset
|
1280 p += mb_ptr2len(p); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1281 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1282 item->bytelen = p - item->start; |
18560
81272918c0ea
patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
18396
diff
changeset
|
1283 if (*p == '\n') |
81272918c0ea
patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
18396
diff
changeset
|
1284 ++p; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1285 if (item->cells > max_cells) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1286 max_cells = item->cells; |
12940
5045d3076db0
patch 8.0.1346: crash when passing 50 char string to balloon_split()
Christian Brabandt <cb@256bit.org>
parents:
12883
diff
changeset
|
1287 long_item_count += (item->cells - 1) / BALLOON_MIN_WIDTH; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1288 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1289 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1290 height = 2 + ga.ga_len; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1291 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1292 // If there are long items and the height is below the limit: split lines |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1293 if (long_item_count > 0 && height + long_item_count <= max_height) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1294 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1295 split_long_items = TRUE; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1296 height += long_item_count; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1297 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1298 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1299 // Limit to half the window height, it has to fit above or below the mouse |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1300 // position. |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1301 if (height > max_height) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1302 height = max_height; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1303 *array = ALLOC_CLEAR_MULT(pumitem_T, height); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1304 if (*array == NULL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1305 goto failed; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1306 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1307 // Add an empty line above and below, looks better. |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1308 (*array)->pum_text = vim_strsave((char_u *)""); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1309 (*array + height - 1)->pum_text = vim_strsave((char_u *)""); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1310 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1311 for (line = 1, item_idx = 0; line < height - 1; ++item_idx) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1312 { |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1313 int skip; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1314 int thislen; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1315 int copylen; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1316 int ind; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1317 int cells; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1318 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1319 item = ((balpart_T *)ga.ga_data) + item_idx; |
18667
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1320 if (item->bytelen == 0) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1321 (*array)[line++].pum_text = vim_strsave((char_u *)""); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1322 else |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1323 for (skip = 0; skip < item->bytelen; skip += thislen) |
16429
a1229400434a
patch 8.1.1219: not checking for NULL return from alloc()
Bram Moolenaar <Bram@vim.org>
parents:
16268
diff
changeset
|
1324 { |
18667
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1325 if (split_long_items && item->cells >= BALLOON_MIN_WIDTH) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1326 { |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1327 cells = item->indent * 2; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1328 for (p = item->start + skip; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1329 p < item->start + item->bytelen; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1330 p += mb_ptr2len(p)) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1331 if ((cells += ptr2cells(p)) > BALLOON_MIN_WIDTH) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1332 break; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1333 thislen = p - (item->start + skip); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1334 } |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1335 else |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1336 thislen = item->bytelen; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1337 |
18667
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1338 // put indent at the start |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1339 p = alloc(thislen + item->indent * 2 + 1); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1340 if (p == NULL) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1341 { |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1342 for (line = 0; line <= height - 1; ++line) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1343 vim_free((*array)[line].pum_text); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1344 vim_free(*array); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1345 goto failed; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1346 } |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1347 for (ind = 0; ind < item->indent * 2; ++ind) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1348 p[ind] = ' '; |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1349 |
18667
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1350 // exclude spaces at the end of the string |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1351 for (copylen = thislen; copylen > 0; --copylen) |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1352 if (item->start[skip + copylen - 1] != ' ') |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1353 break; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1354 |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1355 vim_strncpy(p + ind, item->start + skip, copylen); |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1356 (*array)[line].pum_text = p; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1357 item->indent = 0; // wrapped line has no indent |
18667
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1358 ++line; |
de350001150c
patch 8.1.2325: crash when using balloon with empty line
Bram Moolenaar <Bram@vim.org>
parents:
18665
diff
changeset
|
1359 } |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1360 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1361 ga_clear(&ga); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1362 return height; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1363 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1364 failed: |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1365 ga_clear(&ga); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1366 return 0; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1367 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1368 |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1369 void |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1370 ui_remove_balloon(void) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1371 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1372 if (balloon_array != NULL) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1373 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1374 pum_undisplay(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1375 while (balloon_arraysize > 0) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1376 vim_free(balloon_array[--balloon_arraysize].pum_text); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13242
diff
changeset
|
1377 VIM_CLEAR(balloon_array); |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1378 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1379 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1380 |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1381 /* |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1382 * Terminal version of a balloon, uses the popup menu code. |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1383 */ |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1384 void |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1385 ui_post_balloon(char_u *mesg, list_T *list) |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1386 { |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1387 ui_remove_balloon(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1388 |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1389 if (mesg == NULL && list == NULL) |
16600
ff3c99bd1038
patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
1390 { |
ff3c99bd1038
patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
1391 pum_undisplay(); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1392 return; |
16600
ff3c99bd1038
patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
1393 } |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1394 if (list != NULL) |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1395 { |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1396 listitem_T *li; |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1397 int idx; |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1398 |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1399 balloon_arraysize = list->lv_len; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1400 balloon_array = ALLOC_CLEAR_MULT(pumitem_T, list->lv_len); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1401 if (balloon_array == NULL) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1402 return; |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20245
diff
changeset
|
1403 CHECK_LIST_MATERIALIZE(list); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1404 for (idx = 0, li = list->lv_first; li != NULL; li = li->li_next, ++idx) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1405 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15087
diff
changeset
|
1406 char_u *text = tv_get_string_chk(&li->li_tv); |
12883
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1407 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1408 balloon_array[idx].pum_text = vim_strsave( |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1409 text == NULL ? (char_u *)"" : text); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1410 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1411 } |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1412 else |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1413 balloon_arraysize = split_message(mesg, &balloon_array); |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1414 |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1415 if (balloon_arraysize > 0) |
058e93aee621
patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents:
12871
diff
changeset
|
1416 { |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1417 pum_array = balloon_array; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1418 pum_size = balloon_arraysize; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1419 pum_compute_size(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1420 pum_scrollbar = 0; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1421 pum_height = balloon_arraysize; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1422 |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1423 pum_position_at_mouse(BALLOON_MIN_WIDTH); |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1424 pum_selected = -1; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1425 pum_first = 0; |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1426 pum_redraw(); |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1427 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1428 } |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1429 |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1430 /* |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1431 * Called when the mouse moved, may remove any displayed balloon. |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1432 */ |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1433 void |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1434 ui_may_remove_balloon(void) |
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1435 { |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
1436 // For now: remove the balloon whenever the mouse moves to another screen |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
1437 // cell. |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
1438 ui_remove_balloon(); |
12865
ebb4f6c93598
patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents:
12690
diff
changeset
|
1439 } |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1440 #endif |
13234
6e972d830e13
patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents:
12940
diff
changeset
|
1441 |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1442 #if defined(FEAT_TERM_POPUP_MENU) || defined(PROTO) |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1443 /* |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1444 * Select the pum entry at the mouse position. |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1445 */ |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1446 static void |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1447 pum_select_mouse_pos(void) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1448 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1449 int idx = mouse_row - pum_row; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1450 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1451 if (idx < 0 || idx >= pum_size) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1452 pum_selected = -1; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1453 else if (*pum_array[idx].pum_text != NUL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1454 pum_selected = idx; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1455 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1456 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1457 /* |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1458 * Execute the currently selected popup menu item. |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1459 */ |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1460 static void |
13400
c415cdd49ea4
patch 8.0.1574: show cursor in wrong place when using popup menu
Christian Brabandt <cb@256bit.org>
parents:
13392
diff
changeset
|
1461 pum_execute_menu(vimmenu_T *menu, int mode) |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1462 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1463 vimmenu_T *mp; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1464 int idx = 0; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1465 exarg_T ea; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1466 |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19673
diff
changeset
|
1467 FOR_ALL_CHILD_MENUS(menu, mp) |
13400
c415cdd49ea4
patch 8.0.1574: show cursor in wrong place when using popup menu
Christian Brabandt <cb@256bit.org>
parents:
13392
diff
changeset
|
1468 if ((mp->modes & mp->enabled & mode) && idx++ == pum_selected) |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1469 { |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19934
diff
changeset
|
1470 CLEAR_FIELD(ea); |
14952
405309f9dd13
patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents:
14685
diff
changeset
|
1471 execute_menu(&ea, mp, -1); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1472 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1473 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1474 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1475 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1476 /* |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1477 * Open the terminal version of the popup menu and don't return until it is |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1478 * closed. |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1479 */ |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1480 void |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1481 pum_show_popupmenu(vimmenu_T *menu) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1482 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1483 vimmenu_T *mp; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1484 int idx = 0; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1485 pumitem_T *array; |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1486 # ifdef FEAT_BEVAL_TERM |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1487 int save_bevalterm = p_bevalterm; |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1488 # endif |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1489 int mode; |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1490 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1491 pum_undisplay(); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1492 pum_size = 0; |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1493 mode = get_menu_mode_flag(); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1494 |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19673
diff
changeset
|
1495 FOR_ALL_CHILD_MENUS(menu, mp) |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1496 if (menu_is_separator(mp->dname) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1497 || (mp->modes & mp->enabled & mode)) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1498 ++pum_size; |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1499 |
15375
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1500 // When there are only Terminal mode menus, using "popup Edit" results in |
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1501 // pum_size being zero. |
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1502 if (pum_size <= 0) |
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1503 { |
26887
612339679616
patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26165
diff
changeset
|
1504 emsg(e_menu_only_exists_in_another_mode); |
15375
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1505 return; |
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1506 } |
6012cc6936f7
patch 8.1.0695: internal error when using :popup
Bram Moolenaar <Bram@vim.org>
parents:
15324
diff
changeset
|
1507 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1508 array = ALLOC_CLEAR_MULT(pumitem_T, pum_size); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1509 if (array == NULL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1510 return; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1511 |
19934
3ff714d765ba
patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents:
19673
diff
changeset
|
1512 FOR_ALL_CHILD_MENUS(menu, mp) |
23328
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1513 { |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1514 char_u *s = NULL; |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1515 |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1516 // Make a copy of the text, the menu may be redefined in a callback. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1517 if (menu_is_separator(mp->dname)) |
23328
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1518 s = (char_u *)""; |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1519 else if (mp->modes & mp->enabled & mode) |
23328
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1520 s = mp->dname; |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1521 if (s != NULL) |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1522 { |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1523 s = vim_strsave(s); |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1524 if (s != NULL) |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1525 array[idx++].pum_text = s; |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1526 } |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1527 } |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1528 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1529 pum_array = array; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1530 pum_compute_size(); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1531 pum_scrollbar = 0; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1532 pum_height = pum_size; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1533 pum_position_at_mouse(20); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1534 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1535 pum_selected = -1; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1536 pum_first = 0; |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1537 # ifdef FEAT_BEVAL_TERM |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1538 p_bevalterm = TRUE; // track mouse movement |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1539 mch_setmouse(TRUE); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1540 # endif |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1541 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1542 for (;;) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1543 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1544 int c; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1545 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1546 pum_redraw(); |
13400
c415cdd49ea4
patch 8.0.1574: show cursor in wrong place when using popup menu
Christian Brabandt <cb@256bit.org>
parents:
13392
diff
changeset
|
1547 setcursor_mayforce(TRUE); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1548 out_flush(); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1549 |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1550 c = vgetc(); |
16845
d4c50bca8dbc
patch 8.1.1424: crash when popup menu is deleted while waiting for char
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1551 |
d4c50bca8dbc
patch 8.1.1424: crash when popup menu is deleted while waiting for char
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1552 // Bail out when typing Esc, CTRL-C or some callback closed the popup |
d4c50bca8dbc
patch 8.1.1424: crash when popup menu is deleted while waiting for char
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1553 // menu. |
d4c50bca8dbc
patch 8.1.1424: crash when popup menu is deleted while waiting for char
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
1554 if (c == ESC || c == Ctrl_C || pum_array == NULL) |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1555 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1556 else if (c == CAR || c == NL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1557 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1558 // enter: select current item, if any, and close |
13400
c415cdd49ea4
patch 8.0.1574: show cursor in wrong place when using popup menu
Christian Brabandt <cb@256bit.org>
parents:
13392
diff
changeset
|
1559 pum_execute_menu(menu, mode); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1560 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1561 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1562 else if (c == 'k' || c == K_UP || c == K_MOUSEUP) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1563 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1564 // cursor up: select previous item |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1565 while (pum_selected > 0) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1566 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1567 --pum_selected; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1568 if (*array[pum_selected].pum_text != NUL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1569 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1570 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1571 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1572 else if (c == 'j' || c == K_DOWN || c == K_MOUSEDOWN) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1573 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1574 // cursor down: select next item |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1575 while (pum_selected < pum_size - 1) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1576 { |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1577 ++pum_selected; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1578 if (*array[pum_selected].pum_text != NUL) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1579 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1580 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1581 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1582 else if (c == K_RIGHTMOUSE) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1583 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1584 // Right mouse down: reposition the menu. |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1585 vungetc(c); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1586 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1587 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1588 else if (c == K_LEFTDRAG || c == K_RIGHTDRAG || c == K_MOUSEMOVE) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1589 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1590 // mouse moved: select item in the mouse row |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1591 pum_select_mouse_pos(); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1592 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1593 else if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM || c == K_RIGHTRELEASE) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1594 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1595 // left mouse click: select clicked item, if any, and close; |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1596 // right mouse release: select clicked item, close if any |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1597 pum_select_mouse_pos(); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1598 if (pum_selected >= 0) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1599 { |
13400
c415cdd49ea4
patch 8.0.1574: show cursor in wrong place when using popup menu
Christian Brabandt <cb@256bit.org>
parents:
13392
diff
changeset
|
1600 pum_execute_menu(menu, mode); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1601 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1602 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1603 if (c == K_LEFTMOUSE || c == K_LEFTMOUSE_NM) |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1604 break; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1605 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1606 } |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1607 |
23328
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1608 for (idx = 0; idx < pum_size; ++idx) |
8e0ec52cad85
patch 8.2.2207: illegal memory access if popup menu items are changed
Bram Moolenaar <Bram@vim.org>
parents:
23154
diff
changeset
|
1609 vim_free(array[idx].pum_text); |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1610 vim_free(array); |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1611 pum_undisplay(); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1612 # ifdef FEAT_BEVAL_TERM |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1613 p_bevalterm = save_bevalterm; |
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1614 mch_setmouse(TRUE); |
17809
59f8948b7590
patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents:
17799
diff
changeset
|
1615 # endif |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1616 } |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1617 |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1618 void |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1619 pum_make_popup(char_u *path_name, int use_mouse_pos) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1620 { |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1621 vimmenu_T *menu; |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1622 |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1623 if (!use_mouse_pos) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1624 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1625 // Hack: set mouse position at the cursor so that the menu pops up |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
1626 // around there. |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1627 mouse_row = curwin->w_winrow + curwin->w_wrow; |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1628 mouse_col = curwin->w_wincol + curwin->w_wcol; |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1629 } |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1630 |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1631 menu = gui_find_menu(path_name); |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1632 if (menu != NULL) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1633 pum_show_popupmenu(menu); |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13369
diff
changeset
|
1634 } |
13369
244ff1b6d2ad
patch 8.0.1558: no right-click menu in a terminal
Christian Brabandt <cb@256bit.org>
parents:
13331
diff
changeset
|
1635 #endif |