annotate src/popupmnu.c @ 2559:7850c8c12347 vim73

Cleanup in :find completion code. Make it work for "./subdir" in 'path'.
author Bram Moolenaar <bram@vim.org>
date Fri, 13 Aug 2010 21:16:49 +0200
parents 6768ebd0bc04
children b2cfe84c96cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
2 *
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
4 *
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
8 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
9
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
10 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
11 * popupmnu.c: Popup menu (PUM)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
12 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
13 #include "vim.h"
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
14
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
15 #if defined(FEAT_INS_EXPAND) || defined(PROTO)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
16
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
17 static pumitem_T *pum_array = NULL; /* items of displayed pum */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
18 static int pum_size; /* nr of items in "pum_array" */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
19 static int pum_selected; /* index of selected item or -1 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
20 static int pum_first = 0; /* index of top item */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
21
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
22 static int pum_height; /* nr of displayed pum items */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
23 static int pum_width; /* width of displayed pum items */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
24 static int pum_base_width; /* width of pum items base */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
25 static int pum_kind_width; /* width of pum items kind column */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
26 static int pum_scrollbar; /* TRUE when scrollbar present */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
27
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
28 static int pum_row; /* top row of pum */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
29 static int pum_col; /* left column of pum */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
30
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
31 static int pum_do_redraw = FALSE; /* do redraw anyway */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
32
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
33 static int pum_set_selected __ARGS((int n, int repeat));
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
34
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
35 #define PUM_DEF_HEIGHT 10
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
36 #define PUM_DEF_WIDTH 15
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
37
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
38 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
39 * Show the popup menu with items "array[size]".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
40 * "array" must remain valid until pum_undisplay() is called!
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
41 * When possible the leftmost character is aligned with screen column "col".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
42 * The menu appears above the screen line "row" or at "row" + "height" - 1.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
43 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
44 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
45 pum_display(array, size, selected)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
46 pumitem_T *array;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
47 int size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
48 int selected; /* index of initially selected item, none if
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
49 out of range */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
50 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
51 int w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
52 int def_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
53 int max_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
54 int kind_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
55 int extra_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
56 int i;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
57 int top_clear;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
58 int row;
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
59 int context_lines;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
60 int col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
61 int above_row = cmdline_row;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
62 int redo_count = 0;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
63
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
64 redo:
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
65 def_width = PUM_DEF_WIDTH;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
66 max_width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
67 kind_width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
68 extra_width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
69
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
70 /* Pretend the pum is already there to avoid that must_redraw is set when
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
71 * 'cuc' is on. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
72 pum_array = (pumitem_T *)1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
73 validate_cursor_col();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
74 pum_array = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
75
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
76 row = curwin->w_wrow + W_WINROW(curwin);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
77
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
78 if (firstwin->w_p_pvw)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
79 top_clear = firstwin->w_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
80 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
81 top_clear = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
82
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
83 /* When the preview window is at the bottom stop just above it. Also
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
84 * avoid drawing over the status line so that it's clear there is a window
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
85 * boundary. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
86 if (lastwin->w_p_pvw)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
87 above_row -= lastwin->w_height + lastwin->w_status_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
88
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
89 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
90 * Figure out the size and position of the pum.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
91 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
92 if (size < PUM_DEF_HEIGHT)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
93 pum_height = size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
94 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
95 pum_height = PUM_DEF_HEIGHT;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
96 if (p_ph > 0 && pum_height > p_ph)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
97 pum_height = p_ph;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
98
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
99 /* Put the pum below "row" if possible. If there are few lines decide on
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
100 * where there is more room. */
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
101 if (row + 2 >= above_row - pum_height
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
102 && row > (above_row - top_clear) / 2)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
103 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
104 /* pum above "row" */
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
105
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
106 /* Leave two lines of context if possible */
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
107 if (curwin->w_wrow - curwin->w_cline_row >= 2)
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
108 context_lines = 2;
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
109 else
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
110 context_lines = curwin->w_wrow - curwin->w_cline_row;
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
111
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
112 if (row >= size + context_lines)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
113 {
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
114 pum_row = row - size - context_lines;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
115 pum_height = size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
116 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
117 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
118 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
119 pum_row = 0;
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
120 pum_height = row - context_lines;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
121 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
122 if (p_ph > 0 && pum_height > p_ph)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
123 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
124 pum_row += pum_height - p_ph;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
125 pum_height = p_ph;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
126 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
127 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
128 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
129 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
130 /* pum below "row" */
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
131
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
132 /* Leave two lines of context if possible */
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
133 if (curwin->w_cline_row + curwin->w_cline_height - curwin->w_wrow >= 3)
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
134 context_lines = 3;
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
135 else
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
136 context_lines = curwin->w_cline_row
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
137 + curwin->w_cline_height - curwin->w_wrow;
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
138
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
139 pum_row = row + context_lines;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
140 if (size > above_row - pum_row)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
141 pum_height = above_row - pum_row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
142 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
143 pum_height = size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
144 if (p_ph > 0 && pum_height > p_ph)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
145 pum_height = p_ph;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
146 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
147
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
148 /* don't display when we only have room for one line */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
149 if (pum_height < 1 || (pum_height == 1 && size > 1))
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
150 return;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
151
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
152 /* If there is a preview window at the top avoid drawing over it. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
153 if (firstwin->w_p_pvw
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
154 && pum_row < firstwin->w_height
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
155 && pum_height > firstwin->w_height + 4)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
156 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
157 pum_row += firstwin->w_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
158 pum_height -= firstwin->w_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
159 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
160
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
161 /* Compute the width of the widest match and the widest extra. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
162 for (i = 0; i < size; ++i)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
163 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
164 w = vim_strsize(array[i].pum_text);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
165 if (max_width < w)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
166 max_width = w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
167 if (array[i].pum_kind != NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
168 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
169 w = vim_strsize(array[i].pum_kind) + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
170 if (kind_width < w)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
171 kind_width = w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
172 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
173 if (array[i].pum_extra != NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
174 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
175 w = vim_strsize(array[i].pum_extra) + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
176 if (extra_width < w)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
177 extra_width = w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
178 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
179 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
180 pum_base_width = max_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
181 pum_kind_width = kind_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
182
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
183 /* Calculate column */
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
184 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
185 if (curwin->w_p_rl)
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1622
diff changeset
186 col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol - 1;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
187 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
188 #endif
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1622
diff changeset
189 col = W_WINCOL(curwin) + curwin->w_wcol;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
190
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
191 /* if there are more items than room we need a scrollbar */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
192 if (pum_height < size)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
193 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
194 pum_scrollbar = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
195 ++max_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
196 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
197 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
198 pum_scrollbar = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
199
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
200 if (def_width < max_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
201 def_width = max_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
202
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
203 if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
204 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
205 && !curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
206 || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
207 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
208 ))
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
209 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
210 /* align pum column with "col" */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
211 pum_col = col;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
212
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
213 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
214 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
215 pum_width = pum_col - pum_scrollbar + 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
216 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
217 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
218 pum_width = Columns - pum_col - pum_scrollbar;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
219
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
220 if (pum_width > max_width + kind_width + extra_width + 1
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
221 && pum_width > PUM_DEF_WIDTH)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
222 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
223 pum_width = max_width + kind_width + extra_width + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
224 if (pum_width < PUM_DEF_WIDTH)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
225 pum_width = PUM_DEF_WIDTH;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
226 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
227 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
228 else if (Columns < def_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
229 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
230 /* not enough room, will use what we have */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
231 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
232 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
233 pum_col = Columns - 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
234 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
235 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
236 pum_col = 0;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
237 pum_width = Columns - 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
238 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
239 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
240 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
241 if (max_width > PUM_DEF_WIDTH)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
242 max_width = PUM_DEF_WIDTH; /* truncate */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
243 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
244 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
245 pum_col = max_width - 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
246 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
247 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
248 pum_col = Columns - max_width;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
249 pum_width = max_width - pum_scrollbar;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
250 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
251
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
252 pum_array = array;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
253 pum_size = size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
254
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
255 /* Set selected item and redraw. If the window size changed need to redo
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
256 * the positioning. Limit this to two times, when there is not much
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
257 * room the window size will keep changing. */
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
258 if (pum_set_selected(selected, redo_count) && ++redo_count <= 2)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
259 goto redo;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
260 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
261
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
262 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
263 * Redraw the popup menu, using "pum_first" and "pum_selected".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
264 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
265 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
266 pum_redraw()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
267 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
268 int row = pum_row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
269 int col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
270 int attr_norm = highlight_attr[HLF_PNI];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
271 int attr_select = highlight_attr[HLF_PSI];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
272 int attr_scroll = highlight_attr[HLF_PSB];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
273 int attr_thumb = highlight_attr[HLF_PST];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
274 int attr;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
275 int i;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
276 int idx;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
277 char_u *s;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
278 char_u *p = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
279 int totwidth, width, w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
280 int thumb_pos = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
281 int thumb_heigth = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
282 int round;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
283 int n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
284
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
285 if (pum_scrollbar)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
286 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
287 thumb_heigth = pum_height * pum_height / pum_size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
288 if (thumb_heigth == 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
289 thumb_heigth = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
290 thumb_pos = (pum_first * (pum_height - thumb_heigth)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
291 + (pum_size - pum_height) / 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
292 / (pum_size - pum_height);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
293 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
294
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
295 for (i = 0; i < pum_height; ++i)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
296 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
297 idx = i + pum_first;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
298 attr = (idx == pum_selected) ? attr_select : attr_norm;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
299
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
300 /* prepend a space if there is room */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
301 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
302 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
303 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
304 if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
305 screen_putchar(' ', row, pum_col + 1, attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
306 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
307 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
308 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
309 if (pum_col > 0)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
310 screen_putchar(' ', row, pum_col - 1, attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
311
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
312 /* Display each entry, use two spaces for a Tab.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
313 * Do this 3 times: For the main text, kind and extra info */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
314 col = pum_col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
315 totwidth = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
316 for (round = 1; round <= 3; ++round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
317 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
318 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
319 s = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
320 switch (round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
321 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
322 case 1: p = pum_array[idx].pum_text; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
323 case 2: p = pum_array[idx].pum_kind; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
324 case 3: p = pum_array[idx].pum_extra; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
325 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
326 if (p != NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
327 for ( ; ; mb_ptr_adv(p))
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
328 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
329 if (s == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
330 s = p;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
331 w = ptr2cells(p);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
332 if (*p == NUL || *p == TAB || totwidth + w > pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
333 {
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
334 /* Display the text that fits or comes before a Tab.
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
335 * First convert it to printable characters. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
336 char_u *st;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
337 int saved = *p;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
338
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
339 *p = NUL;
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
340 st = transstr(s);
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
341 *p = saved;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
342 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
343 if (curwin->w_p_rl)
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
344 {
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
345 if (st != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
346 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
347 char_u *rt = reverse_text(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
348
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
349 if (rt != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
350 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
351 char_u *rt_start = rt;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
352 int size;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
353
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
354 size = vim_strsize(rt);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
355 if (size > pum_width)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
356 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
357 do
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
358 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
359 size -= has_mbyte
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
360 ? (*mb_ptr2cells)(rt) : 1;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
361 mb_ptr_adv(rt);
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
362 } while (size > pum_width);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
363
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
364 if (size < pum_width)
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
365 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
366 /* Most left character requires
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
367 * 2-cells but only 1 cell is
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
368 * available on screen. Put a
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
369 * '<' on the left of the pum
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
370 * item */
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
371 *(--rt) = '<';
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
372 size++;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
373 }
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
374 }
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
375 screen_puts_len(rt, (int)STRLEN(rt),
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
376 row, col - size + 1, attr);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
377 vim_free(rt_start);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
378 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
379 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
380 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
381 col -= width;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
382 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
383 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
384 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
385 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
386 if (st != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
387 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
388 screen_puts_len(st, (int)STRLEN(st), row, col,
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
389 attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
390 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
391 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
392 col += width;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
393 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
394
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
395 if (*p != TAB)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
396 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
397
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
398 /* Display two spaces for a Tab. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
399 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
400 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
401 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
402 screen_puts_len((char_u *)" ", 2, row, col - 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
403 attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
404 col -= 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
405 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
406 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
407 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
408 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
409 screen_puts_len((char_u *)" ", 2, row, col, attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
410 col += 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
411 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
412 totwidth += 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
413 s = NULL; /* start text at next char */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
414 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
415 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
416 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
417 width += w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
418 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
419
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
420 if (round > 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
421 n = pum_kind_width + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
422 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
423 n = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
424
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
425 /* Stop when there is nothing more to display. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
426 if (round == 3
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
427 || (round == 2 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
428 || (round == 1 && pum_array[idx].pum_kind == NULL
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
429 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
430 || pum_base_width + n >= pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
431 break;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
432 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
433 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
434 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
435 screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
436 col + 1, ' ', ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
437 col = pum_col - pum_base_width - n + 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
438 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
439 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
440 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
441 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
442 screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
443 ' ', ' ', attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
444 col = pum_col + pum_base_width + n;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
445 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
446 totwidth = pum_base_width + n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
447 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
448
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
449 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
450 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
451 screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
452 ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
453 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
454 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
455 screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
456 attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
457 if (pum_scrollbar > 0)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
458 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
459 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
460 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
461 screen_putchar(' ', row, pum_col - pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
462 i >= thumb_pos && i < thumb_pos + thumb_heigth
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
463 ? attr_thumb : attr_scroll);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
464 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
465 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
466 screen_putchar(' ', row, pum_col + pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
467 i >= thumb_pos && i < thumb_pos + thumb_heigth
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
468 ? attr_thumb : attr_scroll);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
469 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
470
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
471 ++row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
472 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
473 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
474
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
475 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
476 * Set the index of the currently selected item. The menu will scroll when
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
477 * necessary. When "n" is out of range don't scroll.
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
478 * This may be repeated when the preview window is used:
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
479 * "repeat" == 0: open preview window normally
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
480 * "repeat" == 1: open preview window but don't set the size
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
481 * "repeat" == 2: don't open preview window
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
482 * Returns TRUE when the window was resized and the location of the popup menu
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
483 * must be recomputed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
484 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
485 static int
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
486 pum_set_selected(n, repeat)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
487 int n;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
488 int repeat;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
489 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
490 int resized = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
491 int context = pum_height / 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
492
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
493 pum_selected = n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
494
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
495 if (pum_selected >= 0 && pum_selected < pum_size)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
496 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
497 if (pum_first > pum_selected - 4)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
498 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
499 /* scroll down; when we did a jump it's probably a PageUp then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
500 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
501 if (pum_first > pum_selected - 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
502 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
503 pum_first -= pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
504 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
505 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
506 else if (pum_first > pum_selected)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
507 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
508 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
509 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
510 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
511 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
512 else if (pum_first < pum_selected - pum_height + 5)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
513 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
514 /* scroll up; when we did a jump it's probably a PageDown then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
515 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
516 if (pum_first < pum_selected - pum_height + 1 + 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
517 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
518 pum_first += pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
519 if (pum_first < pum_selected - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
520 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
521 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
522 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
523 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
524 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
525
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
526 /* Give a few lines of context when possible. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
527 if (context > 3)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
528 context = 3;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
529 if (pum_height > 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
530 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
531 if (pum_first > pum_selected - context)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
532 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
533 /* scroll down */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
534 pum_first = pum_selected - context;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
535 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
536 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
537 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
538 else if (pum_first < pum_selected + context - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
539 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
540 /* scroll up */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
541 pum_first = pum_selected + context - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
542 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
543 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
544
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
545 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
546 /*
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
547 * Show extra info in the preview window if there is something and
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
548 * 'completeopt' contains "preview".
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
549 * Skip this when tried twice already.
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
550 * Skip this also when there is not much room.
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
551 * NOTE: Be very careful not to sync undo!
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
552 */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
553 if (pum_array[pum_selected].pum_info != NULL
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
554 && Rows > 10
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
555 && repeat <= 1
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
556 && vim_strchr(p_cot, 'p') != NULL)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
557 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
558 win_T *curwin_save = curwin;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
559 int res = OK;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
560
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
561 /* Open a preview window. 3 lines by default. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
562 g_do_tagpreview = 3;
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
563 resized = prepare_tagpreview(FALSE);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
564 g_do_tagpreview = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
565
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
566 if (curwin->w_p_pvw)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
567 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
568 if (curbuf->b_fname == NULL
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
569 && curbuf->b_p_bt[0] == 'n' && curbuf->b_p_bt[2] == 'f'
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
570 && curbuf->b_p_bh[0] == 'w')
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
571 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
572 /* Already a "wipeout" buffer, make it empty. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
573 while (!bufempty())
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
574 ml_delete((linenr_T)1, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
575 }
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
576 else
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
577 {
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
578 /* Don't want to sync undo in the current buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
579 ++no_u_sync;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1668
diff changeset
580 res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
581 --no_u_sync;
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
582 if (res == OK)
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
583 {
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
584 /* Edit a new, empty buffer. Set options for a "wipeout"
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
585 * buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
586 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
587 set_option_value((char_u *)"bt", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
588 (char_u *)"nofile", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
589 set_option_value((char_u *)"bh", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
590 (char_u *)"wipe", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
591 set_option_value((char_u *)"diff", 0L,
1302
7281a86ae640 updated for version 7.1-016
vimboss
parents: 1097
diff changeset
592 NULL, OPT_LOCAL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
593 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
594 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
595 if (res == OK)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
596 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
597 char_u *p, *e;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
598 linenr_T lnum = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
599
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
600 for (p = pum_array[pum_selected].pum_info; *p != NUL; )
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
601 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
602 e = vim_strchr(p, '\n');
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
603 if (e == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
604 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
605 ml_append(lnum++, p, 0, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
606 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
607 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
608 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
609 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
610 *e = NUL;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 825
diff changeset
611 ml_append(lnum++, p, (int)(e - p + 1), FALSE);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
612 *e = '\n';
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
613 p = e + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
614 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
615 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
616
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
617 /* Increase the height of the preview window to show the
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
618 * text, but no more than 'previewheight' lines. */
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
619 if (repeat == 0)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
620 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
621 if (lnum > p_pvh)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
622 lnum = p_pvh;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
623 if (curwin->w_height < lnum)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
624 {
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
625 win_setheight((int)lnum);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
626 resized = TRUE;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
627 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
628 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
629
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
630 curbuf->b_changed = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
631 curbuf->b_p_ma = FALSE;
2113
85ad19790706 updated for version 7.2.396
Bram Moolenaar <bram@zimbu.org>
parents: 2056
diff changeset
632 curwin->w_cursor.lnum = 1;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
633 curwin->w_cursor.col = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
634
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
635 if (curwin != curwin_save && win_valid(curwin_save))
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
636 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
637 /* Return cursor to where we were */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
638 validate_cursor();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
639 redraw_later(SOME_VALID);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
640
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
641 /* When the preview window was resized we need to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
642 * update the view on the buffer. Only go back to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
643 * the window when needed, otherwise it will always be
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
644 * redraw. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
645 if (resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
646 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
647 win_enter(curwin_save, TRUE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
648 update_topline();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
649 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
650
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
651 /* Update the screen before drawing the popup menu.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
652 * Enable updating the status lines. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
653 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
654 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
655 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
656
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
657 if (!resized && win_valid(curwin_save))
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
658 win_enter(curwin_save, TRUE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
659
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
660 /* May need to update the screen again when there are
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
661 * autocommands involved. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
662 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
663 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
664 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
665 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
666 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
667 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
668 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
669 #endif
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
670 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
671
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
672 /* Never display more than we have */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
673 if (pum_first > pum_size - pum_height)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
674 pum_first = pum_size - pum_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
675
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
676 if (!resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
677 pum_redraw();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
678
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
679 return resized;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
680 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
681
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
682 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
683 * Undisplay the popup menu (later).
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
684 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
685 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
686 pum_undisplay()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
687 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
688 pum_array = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
689 redraw_all_later(SOME_VALID);
940
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
690 #ifdef FEAT_WINDOWS
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
691 redraw_tabline = TRUE;
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
692 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
693 status_redraw_all();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
694 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
695
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
696 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
697 * Clear the popup menu. Currently only resets the offset to the first
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
698 * displayed item.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
699 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
700 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
701 pum_clear()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
702 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
703 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
704 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
705
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
706 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
707 * Return TRUE if the popup menu is displayed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
708 * Overruled when "pum_do_redraw" is set, used to redraw the status lines.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
709 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
710 int
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
711 pum_visible()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
712 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
713 return !pum_do_redraw && pum_array != NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
714 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
715
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
716 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
717 * Return the height of the popup menu, the number of entries visible.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
718 * Only valid when pum_visible() returns TRUE!
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
719 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
720 int
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
721 pum_get_height()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
722 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
723 return pum_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
724 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
725
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
726 #endif