annotate src/popupmnu.c @ 6024:b4962cf3a1c0 v7.4.352

updated for version 7.4.352 Problem: With 'linebreak' a tab causes a missing line break. Solution: Count a tab for what it's worth also for shorter lines. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 02 Jul 2014 19:37:42 +0200
parents d563839a9be0
children a97e5b9dbc26
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
5444
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
285 /* Never display more than we have */
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
286 if (pum_first > pum_size - pum_height)
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
287 pum_first = pum_size - pum_height;
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
288
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
289 if (pum_scrollbar)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
290 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
291 thumb_heigth = pum_height * pum_height / pum_size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
292 if (thumb_heigth == 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
293 thumb_heigth = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
294 thumb_pos = (pum_first * (pum_height - thumb_heigth)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
295 + (pum_size - pum_height) / 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
296 / (pum_size - pum_height);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
297 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
298
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
299 for (i = 0; i < pum_height; ++i)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
300 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
301 idx = i + pum_first;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
302 attr = (idx == pum_selected) ? attr_select : attr_norm;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
303
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
304 /* prepend a space if there is room */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
305 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
306 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
307 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
308 if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
309 screen_putchar(' ', row, pum_col + 1, attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
310 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
311 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
312 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
313 if (pum_col > 0)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
314 screen_putchar(' ', row, pum_col - 1, attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
315
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
316 /* Display each entry, use two spaces for a Tab.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
317 * Do this 3 times: For the main text, kind and extra info */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
318 col = pum_col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
319 totwidth = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
320 for (round = 1; round <= 3; ++round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
321 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
322 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
323 s = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
324 switch (round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
325 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
326 case 1: p = pum_array[idx].pum_text; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
327 case 2: p = pum_array[idx].pum_kind; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
328 case 3: p = pum_array[idx].pum_extra; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
329 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
330 if (p != NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
331 for ( ; ; mb_ptr_adv(p))
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
332 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
333 if (s == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
334 s = p;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
335 w = ptr2cells(p);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
336 if (*p == NUL || *p == TAB || totwidth + w > pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
337 {
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
338 /* Display the text that fits or comes before a Tab.
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
339 * First convert it to printable characters. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
340 char_u *st;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
341 int saved = *p;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
342
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
343 *p = NUL;
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
344 st = transstr(s);
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
345 *p = saved;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
346 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
347 if (curwin->w_p_rl)
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
348 {
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
349 if (st != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
350 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
351 char_u *rt = reverse_text(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
352
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
353 if (rt != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
354 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
355 char_u *rt_start = rt;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
356 int size;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
357
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
358 size = vim_strsize(rt);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
359 if (size > pum_width)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
360 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
361 do
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
362 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
363 size -= has_mbyte
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
364 ? (*mb_ptr2cells)(rt) : 1;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
365 mb_ptr_adv(rt);
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
366 } while (size > pum_width);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
367
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
368 if (size < pum_width)
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
369 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
370 /* Most left character requires
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
371 * 2-cells but only 1 cell is
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
372 * available on screen. Put a
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
373 * '<' on the left of the pum
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
374 * item */
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
375 *(--rt) = '<';
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
376 size++;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
377 }
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
378 }
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
379 screen_puts_len(rt, (int)STRLEN(rt),
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
380 row, col - size + 1, attr);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
381 vim_free(rt_start);
1344
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 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
384 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
385 col -= width;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
386 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
387 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
388 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
389 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
390 if (st != NULL)
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 screen_puts_len(st, (int)STRLEN(st), row, col,
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
393 attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
394 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
395 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
396 col += width;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
397 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
398
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
399 if (*p != TAB)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
400 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
401
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
402 /* Display two spaces for a Tab. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
403 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
404 if (curwin->w_p_rl)
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 screen_puts_len((char_u *)" ", 2, row, col - 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
407 attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
408 col -= 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
409 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
410 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
411 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
412 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
413 screen_puts_len((char_u *)" ", 2, row, col, attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
414 col += 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
415 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
416 totwidth += 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
417 s = NULL; /* start text at next char */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
418 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
419 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
420 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
421 width += w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
422 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
423
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
424 if (round > 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
425 n = pum_kind_width + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
426 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
427 n = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
428
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
429 /* Stop when there is nothing more to display. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
430 if (round == 3
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
431 || (round == 2 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
432 || (round == 1 && pum_array[idx].pum_kind == NULL
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
433 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
434 || pum_base_width + n >= pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
435 break;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
436 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
437 if (curwin->w_p_rl)
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 screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
440 col + 1, ' ', ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
441 col = pum_col - pum_base_width - n + 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
442 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
443 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
444 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
445 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
446 screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
447 ' ', ' ', attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
448 col = pum_col + pum_base_width + n;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
449 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
450 totwidth = pum_base_width + n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
451 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
452
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
453 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
454 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
455 screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
456 ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
457 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
458 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
459 screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
460 attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
461 if (pum_scrollbar > 0)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
462 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
463 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
464 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
465 screen_putchar(' ', row, pum_col - pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
466 i >= thumb_pos && i < thumb_pos + thumb_heigth
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
467 ? attr_thumb : attr_scroll);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
468 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
469 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
470 screen_putchar(' ', row, pum_col + pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
471 i >= thumb_pos && i < thumb_pos + thumb_heigth
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
472 ? attr_thumb : attr_scroll);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
473 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
474
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
475 ++row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
476 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
477 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
478
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
479 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
480 * Set the index of the currently selected item. The menu will scroll when
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
481 * necessary. When "n" is out of range don't scroll.
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
482 * This may be repeated when the preview window is used:
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
483 * "repeat" == 0: open preview window normally
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
484 * "repeat" == 1: open preview window but don't set the size
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
485 * "repeat" == 2: don't open preview window
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
486 * Returns TRUE when the window was resized and the location of the popup menu
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
487 * must be recomputed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
488 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
489 static int
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
490 pum_set_selected(n, repeat)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
491 int n;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
492 int repeat;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
493 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
494 int resized = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
495 int context = pum_height / 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
496
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
497 pum_selected = n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
498
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
499 if (pum_selected >= 0 && pum_selected < pum_size)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
500 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
501 if (pum_first > pum_selected - 4)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
502 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
503 /* scroll down; when we did a jump it's probably a PageUp then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
504 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
505 if (pum_first > pum_selected - 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
506 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
507 pum_first -= pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
508 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
509 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
510 else if (pum_first > pum_selected)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
511 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
512 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
513 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
514 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
515 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
516 else if (pum_first < pum_selected - pum_height + 5)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
517 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
518 /* scroll up; when we did a jump it's probably a PageDown then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
519 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
520 if (pum_first < pum_selected - pum_height + 1 + 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
521 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
522 pum_first += pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
523 if (pum_first < pum_selected - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
524 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
525 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
526 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
527 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
528 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
529
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
530 /* Give a few lines of context when possible. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
531 if (context > 3)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
532 context = 3;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
533 if (pum_height > 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
534 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
535 if (pum_first > pum_selected - context)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
536 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
537 /* scroll down */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
538 pum_first = pum_selected - context;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
539 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
540 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
541 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
542 else if (pum_first < pum_selected + context - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
543 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
544 /* scroll up */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
545 pum_first = pum_selected + context - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
546 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
547 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
548
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
549 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
550 /*
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
551 * Show extra info in the preview window if there is something and
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
552 * 'completeopt' contains "preview".
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
553 * Skip this when tried twice already.
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
554 * Skip this also when there is not much room.
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
555 * NOTE: Be very careful not to sync undo!
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
556 */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
557 if (pum_array[pum_selected].pum_info != NULL
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
558 && Rows > 10
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
559 && repeat <= 1
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
560 && vim_strchr(p_cot, 'p') != NULL)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
561 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
562 win_T *curwin_save = curwin;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
563 int res = OK;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
564
2622
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
565 /* Open a preview window. 3 lines by default. Prefer
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
566 * 'previewheight' if set and smaller. */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
567 g_do_tagpreview = 3;
2622
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
568 if (p_pvh > 0 && p_pvh < g_do_tagpreview)
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
569 g_do_tagpreview = p_pvh;
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
570 resized = prepare_tagpreview(FALSE);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
571 g_do_tagpreview = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
572
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
573 if (curwin->w_p_pvw)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
574 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
575 if (curbuf->b_fname == NULL
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
576 && curbuf->b_p_bt[0] == 'n' && curbuf->b_p_bt[2] == 'f'
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
577 && curbuf->b_p_bh[0] == 'w')
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
578 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
579 /* Already a "wipeout" buffer, make it empty. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
580 while (!bufempty())
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
581 ml_delete((linenr_T)1, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
582 }
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
583 else
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
584 {
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
585 /* Don't want to sync undo in the current buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
586 ++no_u_sync;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1668
diff changeset
587 res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
588 --no_u_sync;
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
589 if (res == OK)
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
590 {
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
591 /* Edit a new, empty buffer. Set options for a "wipeout"
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
592 * buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
593 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
594 set_option_value((char_u *)"bt", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
595 (char_u *)"nofile", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
596 set_option_value((char_u *)"bh", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
597 (char_u *)"wipe", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
598 set_option_value((char_u *)"diff", 0L,
1302
7281a86ae640 updated for version 7.1-016
vimboss
parents: 1097
diff changeset
599 NULL, OPT_LOCAL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
600 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
601 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
602 if (res == OK)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
603 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
604 char_u *p, *e;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
605 linenr_T lnum = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
606
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
607 for (p = pum_array[pum_selected].pum_info; *p != NUL; )
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
608 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
609 e = vim_strchr(p, '\n');
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
610 if (e == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
611 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
612 ml_append(lnum++, p, 0, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
613 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
614 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
615 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
616 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
617 *e = NUL;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 825
diff changeset
618 ml_append(lnum++, p, (int)(e - p + 1), FALSE);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
619 *e = '\n';
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
620 p = e + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
621 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
622 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
623
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
624 /* Increase the height of the preview window to show the
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
625 * text, but no more than 'previewheight' lines. */
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
626 if (repeat == 0)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
627 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
628 if (lnum > p_pvh)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
629 lnum = p_pvh;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
630 if (curwin->w_height < lnum)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
631 {
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
632 win_setheight((int)lnum);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
633 resized = TRUE;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
634 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
635 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
636
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
637 curbuf->b_changed = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
638 curbuf->b_p_ma = FALSE;
2113
85ad19790706 updated for version 7.2.396
Bram Moolenaar <bram@zimbu.org>
parents: 2056
diff changeset
639 curwin->w_cursor.lnum = 1;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
640 curwin->w_cursor.col = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
641
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
642 if (curwin != curwin_save && win_valid(curwin_save))
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
643 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
644 /* Return cursor to where we were */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
645 validate_cursor();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
646 redraw_later(SOME_VALID);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
647
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
648 /* When the preview window was resized we need to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
649 * update the view on the buffer. Only go back to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
650 * the window when needed, otherwise it will always be
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
651 * redraw. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
652 if (resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
653 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
654 win_enter(curwin_save, TRUE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
655 update_topline();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
656 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
657
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
658 /* Update the screen before drawing the popup menu.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
659 * Enable updating the status lines. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
660 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
661 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
662 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
663
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
664 if (!resized && win_valid(curwin_save))
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
665 win_enter(curwin_save, TRUE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
666
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
667 /* May need to update the screen again when there are
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
668 * autocommands involved. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
669 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
670 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
671 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
672 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
673 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
674 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
675 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
676 #endif
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
677 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
678
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
679 if (!resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
680 pum_redraw();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
681
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
682 return resized;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
683 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
684
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
685 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
686 * Undisplay the popup menu (later).
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
687 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
688 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
689 pum_undisplay()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
690 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
691 pum_array = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
692 redraw_all_later(SOME_VALID);
940
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
693 #ifdef FEAT_WINDOWS
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
694 redraw_tabline = TRUE;
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
695 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
696 status_redraw_all();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
697 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
698
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
699 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
700 * Clear the popup menu. Currently only resets the offset to the first
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
701 * displayed item.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
702 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
703 void
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
704 pum_clear()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
705 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
706 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
707 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
708
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
709 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
710 * Return TRUE if the popup menu is displayed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
711 * Overruled when "pum_do_redraw" is set, used to redraw the status lines.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
712 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
713 int
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
714 pum_visible()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
715 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
716 return !pum_do_redraw && pum_array != NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
717 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
718
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
719 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
720 * Return the height of the popup menu, the number of entries visible.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
721 * Only valid when pum_visible() returns TRUE!
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
722 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
723 int
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
724 pum_get_height()
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
725 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
726 return pum_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
727 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
728
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
729 #endif