annotate src/popupmnu.c @ 8788:c29f6fad5319

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