annotate src/popupmnu.c @ 13234:6e972d830e13 v8.0.1491

patch 8.0.1491: the minimum width of the popup menu is hard coded commit https://github.com/vim/vim/commit/a8f04aa275984183bab5bb583b128f38c64abb69 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 10 15:36:55 2018 +0100 patch 8.0.1491: the minimum width of the popup menu is hard coded Problem: The minimum width of the popup menu is hard coded. Solution: Add the 'pumwidth' option. (Christian Brabandt, James McCoy, closes #2314)
author Christian Brabandt <cb@256bit.org>
date Sat, 10 Feb 2018 15:45:06 +0100
parents 5045d3076db0
children 5b0faf628a55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 8220
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
800
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 */
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
26 static int pum_extra_width; /* width of extra stuff */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
27 static int pum_scrollbar; /* TRUE when scrollbar present */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
28
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
29 static int pum_row; /* top row of pum */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
30 static int pum_col; /* left column of pum */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
31
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
32 static int pum_do_redraw = FALSE; /* do redraw anyway */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
33
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7181
diff changeset
34 static int pum_set_selected(int n, int repeat);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
35
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
36 #define PUM_DEF_HEIGHT 10
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
37 #define PUM_DEF_WIDTH 15
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
38
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
39 static void
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
40 pum_compute_size(void)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
41 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
42 int i;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
43 int w;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
44
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
45 /* Compute the width of the widest match and the widest extra. */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
46 pum_base_width = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
47 pum_kind_width = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
48 pum_extra_width = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
49 for (i = 0; i < pum_size; ++i)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
50 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
51 w = vim_strsize(pum_array[i].pum_text);
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
52 if (pum_base_width < w)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
53 pum_base_width = w;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
54 if (pum_array[i].pum_kind != NULL)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
55 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
56 w = vim_strsize(pum_array[i].pum_kind) + 1;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
57 if (pum_kind_width < w)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
58 pum_kind_width = w;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
59 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
60 if (pum_array[i].pum_extra != NULL)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
61 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
62 w = vim_strsize(pum_array[i].pum_extra) + 1;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
63 if (pum_extra_width < w)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
64 pum_extra_width = w;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
65 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
66 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
67 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
68
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
69 /*
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
70 * Return the minimum width of the popup menu.
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
71 */
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
72 static int
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
73 pum_get_width(void)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
74 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
75 return p_pw == 0 ? PUM_DEF_WIDTH : p_pw;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
76 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
77
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
78 /*
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
79 * Show the popup menu with items "array[size]".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
80 * "array" must remain valid until pum_undisplay() is called!
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
81 * When possible the leftmost character is aligned with screen column "col".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
82 * The menu appears above the screen line "row" or at "row" + "height" - 1.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
83 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
84 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
85 pum_display(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
86 pumitem_T *array,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
87 int size,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
88 int selected) /* index of initially selected item, none if
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
89 out of range */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
90 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
91 int def_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
92 int max_width;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
93 int row;
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
94 int context_lines;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
95 int col;
10326
7d10572eaba4 commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents: 10302
diff changeset
96 int above_row;
7d10572eaba4 commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents: 10302
diff changeset
97 int below_row;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
98 int redo_count = 0;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
99 #if defined(FEAT_QUICKFIX)
10326
7d10572eaba4 commit https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
Christian Brabandt <cb@256bit.org>
parents: 10302
diff changeset
100 win_T *pvwin;
10332
4d98f501d1c5 commit https://github.com/vim/vim/commit/aab3383e70456f054fe9d0963fe3eb45994aa5e7
Christian Brabandt <cb@256bit.org>
parents: 10326
diff changeset
101 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
102
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
103 do
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
104 {
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
105 def_width = pum_get_width();
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
106 above_row = 0;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
107 below_row = cmdline_row;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
108
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
109 /* Pretend the pum is already there to avoid that must_redraw is set
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
110 * when 'cuc' is on. */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
111 pum_array = (pumitem_T *)1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
112 validate_cursor_col();
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
113 pum_array = NULL;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
114
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
115 row = curwin->w_wrow + W_WINROW(curwin);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
116
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
117 #if defined(FEAT_QUICKFIX)
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
118 FOR_ALL_WINDOWS(pvwin)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
119 if (pvwin->w_p_pvw)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
120 break;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
121 if (pvwin != NULL)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
122 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
123 if (W_WINROW(pvwin) < W_WINROW(curwin))
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
124 above_row = W_WINROW(pvwin) + pvwin->w_height;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
125 else if (W_WINROW(pvwin) > W_WINROW(curwin) + curwin->w_height)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
126 below_row = W_WINROW(pvwin);
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
127 }
8220
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
128 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
129
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
130 /*
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
131 * Figure out the size and position of the pum.
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
132 */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
133 if (size < PUM_DEF_HEIGHT)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
134 pum_height = size;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
135 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
136 pum_height = PUM_DEF_HEIGHT;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
137 if (p_ph > 0 && pum_height > p_ph)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
138 pum_height = p_ph;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
139
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
140 /* Put the pum below "row" if possible. If there are few lines decide
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
141 * on where there is more room. */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
142 if (row + 2 >= below_row - pum_height
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
143 && row - above_row > (below_row - above_row) / 2)
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
144 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
145 /* pum above "row" */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
146
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
147 /* Leave two lines of context if possible */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
148 if (curwin->w_wrow - curwin->w_cline_row >= 2)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
149 context_lines = 2;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
150 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
151 context_lines = curwin->w_wrow - curwin->w_cline_row;
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
152
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
153 if (row >= size + context_lines)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
154 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
155 pum_row = row - size - context_lines;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
156 pum_height = size;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
157 }
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
158 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
159 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
160 pum_row = 0;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
161 pum_height = row - context_lines;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
162 }
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
163 if (p_ph > 0 && pum_height > p_ph)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
164 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
165 pum_row += pum_height - p_ph;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
166 pum_height = p_ph;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
167 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
168 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
169 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
170 {
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
171 /* pum below "row" */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
172
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
173 /* Leave two lines of context if possible */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
174 if (curwin->w_cline_row
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
175 + curwin->w_cline_height - curwin->w_wrow >= 3)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
176 context_lines = 3;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
177 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
178 context_lines = curwin->w_cline_row
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
179 + curwin->w_cline_height - curwin->w_wrow;
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
180
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
181 pum_row = row + context_lines;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
182 if (size > below_row - pum_row)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
183 pum_height = below_row - pum_row;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
184 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
185 pum_height = size;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
186 if (p_ph > 0 && pum_height > p_ph)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
187 pum_height = p_ph;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
188 }
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1570
diff changeset
189
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
190 /* don't display when we only have room for one line */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
191 if (pum_height < 1 || (pum_height == 1 && size > 1))
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
192 return;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
193
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
194 #if defined(FEAT_QUICKFIX)
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
195 /* If there is a preview window at the above avoid drawing over it. */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
196 if (pvwin != NULL && pum_row < above_row && pum_height > above_row)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
197 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
198 pum_row += above_row;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
199 pum_height -= above_row;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
200 }
8220
ad9edad64d22 commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
201 #endif
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
202
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
203 pum_array = array;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
204 pum_size = size;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
205 pum_compute_size();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
206 max_width = pum_base_width;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
207
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
208 /* Calculate column */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
209 #ifdef FEAT_RIGHTLEFT
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
210 if (curwin->w_p_rl)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
211 col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
212 else
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
213 #endif
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
214 col = curwin->w_wincol + curwin->w_wcol;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
215
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
216 /* if there are more items than room we need a scrollbar */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
217 if (pum_height < size)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
218 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
219 pum_scrollbar = 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
220 ++max_width;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
221 }
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
222 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
223 pum_scrollbar = 0;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
224
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
225 if (def_width < max_width)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
226 def_width = max_width;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
227
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
228 if (((col < Columns - pum_get_width() || col < Columns - max_width)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
229 #ifdef FEAT_RIGHTLEFT
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
230 && !curwin->w_p_rl)
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
231 || (curwin->w_p_rl && (col > pum_get_width() || col > max_width)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
232 #endif
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
233 ))
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
234 {
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
235 /* align pum column with "col" */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
236 pum_col = col;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
237
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
238 /* start with the maximum space available */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
239 #ifdef FEAT_RIGHTLEFT
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
240 if (curwin->w_p_rl)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
241 pum_width = pum_col - pum_scrollbar + 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
242 else
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
243 #endif
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
244 pum_width = Columns - pum_col - pum_scrollbar;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
245
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
246 if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
247 && pum_width > pum_get_width())
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
248 {
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
249 /* the width is too much, make it narrower */
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
250 pum_width = max_width + pum_kind_width + pum_extra_width + 1;
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
251 if (pum_width < pum_get_width())
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
252 pum_width = pum_get_width();
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
253 }
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
254 else if (((col > pum_get_width() || col > max_width)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
255 #ifdef FEAT_RIGHTLEFT
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
256 && !curwin->w_p_rl)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
257 || (curwin->w_p_rl && (col < Columns - pum_get_width()
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
258 || col < Columns - max_width)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
259 #endif
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
260 ))
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
261 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
262 /* align right pum edge with "col" */
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
263 #ifdef FEAT_RIGHTLEFT
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
264 if (curwin->w_p_rl)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
265 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
266 pum_col = col + max_width + pum_scrollbar + 1;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
267 if (pum_col >= Columns)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
268 pum_col = Columns - 1;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
269 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
270 else
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
271 #endif
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
272 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
273 pum_col = col - max_width - pum_scrollbar;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
274 if (pum_col < 0)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
275 pum_col = 0;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
276 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
277
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
278 #ifdef FEAT_RIGHTLEFT
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
279 if (curwin->w_p_rl)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
280 pum_width = W_ENDCOL(curwin) - pum_col - pum_scrollbar + 1;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
281 else
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
282 #endif
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
283 pum_width = pum_col - pum_scrollbar;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
284
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
285 if (pum_width < pum_get_width())
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
286 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
287 pum_width = pum_get_width();
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
288 #ifdef FEAT_RIGHTLEFT
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
289 if (curwin->w_p_rl)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
290 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
291 if (pum_width > pum_col)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
292 pum_width = pum_col;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
293 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
294 else
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
295 #endif
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
296 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
297 if (pum_width >= Columns - pum_col)
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
298 pum_width = Columns - pum_col - 1;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
299 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
300 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
301 else if (pum_width > max_width + pum_kind_width
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
302 + pum_extra_width + 1
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
303 && pum_width > pum_get_width())
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
304 {
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
305 pum_width = max_width + pum_kind_width
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
306 + pum_extra_width + 1;
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
307 if (pum_width < pum_get_width())
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
308 pum_width = pum_get_width();
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
309 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
310 }
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
311
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
312 }
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
313 else if (Columns < def_width)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
314 {
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
315 /* not enough room, will use what we have */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
316 #ifdef FEAT_RIGHTLEFT
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
317 if (curwin->w_p_rl)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
318 pum_col = Columns - 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
319 else
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
320 #endif
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
321 pum_col = 0;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
322 pum_width = Columns - 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
323 }
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
324 else
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
325 {
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
326 if (max_width > pum_get_width())
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
327 max_width = pum_get_width(); /* truncate */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
328 #ifdef FEAT_RIGHTLEFT
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
329 if (curwin->w_p_rl)
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
330 pum_col = max_width - 1;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
331 else
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
332 #endif
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
333 pum_col = Columns - max_width;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
334 pum_width = max_width - pum_scrollbar;
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
335 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
336
12566
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
337 /* Set selected item and redraw. If the window size changed need to
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
338 * redo the positioning. Limit this to two times, when there is not
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
339 * much room the window size will keep changing. */
33a900199c25 patch 8.0.1161: popup menu drawing problem when resizing terminal
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
340 } while (pum_set_selected(selected, redo_count) && ++redo_count <= 2);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
341 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
342
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
343 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
344 * Redraw the popup menu, using "pum_first" and "pum_selected".
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
345 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
346 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
347 pum_redraw(void)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
348 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
349 int row = pum_row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
350 int col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
351 int attr_norm = highlight_attr[HLF_PNI];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
352 int attr_select = highlight_attr[HLF_PSI];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
353 int attr_scroll = highlight_attr[HLF_PSB];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
354 int attr_thumb = highlight_attr[HLF_PST];
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
355 int attr;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
356 int i;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
357 int idx;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
358 char_u *s;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
359 char_u *p = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
360 int totwidth, width, w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
361 int thumb_pos = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
362 int thumb_heigth = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
363 int round;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
364 int n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
365
5444
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
366 /* Never display more than we have */
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
367 if (pum_first > pum_size - pum_height)
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
368 pum_first = pum_size - pum_height;
d563839a9be0 updated for version 7.4.072
Bram Moolenaar <bram@vim.org>
parents: 2622
diff changeset
369
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
370 if (pum_scrollbar)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
371 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
372 thumb_heigth = pum_height * pum_height / pum_size;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
373 if (thumb_heigth == 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
374 thumb_heigth = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
375 thumb_pos = (pum_first * (pum_height - thumb_heigth)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
376 + (pum_size - pum_height) / 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
377 / (pum_size - pum_height);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
378 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
379
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
380 for (i = 0; i < pum_height; ++i)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
381 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
382 idx = i + pum_first;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
383 attr = (idx == pum_selected) ? attr_select : attr_norm;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
384
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
385 /* prepend a space if there is room */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
386 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
387 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
388 {
12515
972ea22c946f patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
389 if (pum_col < curwin->w_wincol + curwin->w_width - 1)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
390 screen_putchar(' ', row, pum_col + 1, attr);
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 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
393 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
394 if (pum_col > 0)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
395 screen_putchar(' ', row, pum_col - 1, attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
396
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
397 /* Display each entry, use two spaces for a Tab.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
398 * Do this 3 times: For the main text, kind and extra info */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
399 col = pum_col;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
400 totwidth = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
401 for (round = 1; round <= 3; ++round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
402 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
403 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
404 s = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
405 switch (round)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
406 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
407 case 1: p = pum_array[idx].pum_text; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
408 case 2: p = pum_array[idx].pum_kind; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
409 case 3: p = pum_array[idx].pum_extra; break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
410 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
411 if (p != NULL)
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
412 for ( ; ; MB_PTR_ADV(p))
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
413 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
414 if (s == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
415 s = p;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
416 w = ptr2cells(p);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
417 if (*p == NUL || *p == TAB || totwidth + w > pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
418 {
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
419 /* Display the text that fits or comes before a Tab.
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
420 * First convert it to printable characters. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
421 char_u *st;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
422 int saved = *p;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
423
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
424 *p = NUL;
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
425 st = transstr(s);
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
426 *p = saved;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
427 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
428 if (curwin->w_p_rl)
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
429 {
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
430 if (st != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
431 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
432 char_u *rt = reverse_text(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
433
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
434 if (rt != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
435 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
436 char_u *rt_start = rt;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
437 int size;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
438
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
439 size = vim_strsize(rt);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
440 if (size > pum_width)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
441 {
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
442 do
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
443 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
444 size -= has_mbyte
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
445 ? (*mb_ptr2cells)(rt) : 1;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
446 MB_PTR_ADV(rt);
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
447 } while (size > pum_width);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
448
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
449 if (size < pum_width)
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
450 {
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
451 /* Most left character requires
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
452 * 2-cells but only 1 cell is
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
453 * available on screen. Put a
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
454 * '<' on the left of the pum
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
455 * item */
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
456 *(--rt) = '<';
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
457 size++;
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
458 }
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
459 }
2056
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
460 screen_puts_len(rt, (int)STRLEN(rt),
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
461 row, col - size + 1, attr);
e9e3355861ba updated for version 7.2.342
Bram Moolenaar <bram@zimbu.org>
parents: 1743
diff changeset
462 vim_free(rt_start);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
463 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
464 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
465 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
466 col -= width;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
467 }
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 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
471 if (st != NULL)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
472 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
473 screen_puts_len(st, (int)STRLEN(st), row, col,
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
474 attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
475 vim_free(st);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
476 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
477 col += width;
1097
537cb92935b6 updated for version 7.0-223
vimboss
parents: 940
diff changeset
478 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
479
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
480 if (*p != TAB)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
481 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
482
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
483 /* Display two spaces for a Tab. */
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
484 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
485 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
486 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
487 screen_puts_len((char_u *)" ", 2, row, col - 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
488 attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
489 col -= 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
490 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
491 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
492 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
493 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
494 screen_puts_len((char_u *)" ", 2, row, col, attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
495 col += 2;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
496 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
497 totwidth += 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
498 s = NULL; /* start text at next char */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
499 width = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
500 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
501 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
502 width += w;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
503 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
504
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
505 if (round > 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
506 n = pum_kind_width + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
507 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
508 n = 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
509
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
510 /* Stop when there is nothing more to display. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
511 if (round == 3
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
512 || (round == 2 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
513 || (round == 1 && pum_array[idx].pum_kind == NULL
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
514 && pum_array[idx].pum_extra == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
515 || pum_base_width + n >= pum_width)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
516 break;
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
517 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
518 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
519 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
520 screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
521 col + 1, ' ', ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
522 col = pum_col - pum_base_width - n + 1;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
523 }
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
524 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
525 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
526 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
527 screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
528 ' ', ' ', attr);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
529 col = pum_col + pum_base_width + n;
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
530 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
531 totwidth = pum_base_width + n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
532 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
533
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
534 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
535 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
536 screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
537 ' ', attr);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
538 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
539 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
540 screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
541 attr);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
542 if (pum_scrollbar > 0)
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
543 {
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
544 #ifdef FEAT_RIGHTLEFT
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
545 if (curwin->w_p_rl)
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
546 screen_putchar(' ', row, pum_col - pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
547 i >= thumb_pos && i < thumb_pos + thumb_heigth
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
548 ? attr_thumb : attr_scroll);
1344
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
549 else
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
550 #endif
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
551 screen_putchar(' ', row, pum_col + pum_width,
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
552 i >= thumb_pos && i < thumb_pos + thumb_heigth
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
553 ? attr_thumb : attr_scroll);
843bfffb04c7 updated for version 7.1-058
vimboss
parents: 1302
diff changeset
554 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
555
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
556 ++row;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
557 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
558 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
559
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
560 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
561 * Set the index of the currently selected item. The menu will scroll when
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
562 * necessary. When "n" is out of range don't scroll.
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
563 * This may be repeated when the preview window is used:
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
564 * "repeat" == 0: open preview window normally
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
565 * "repeat" == 1: open preview window but don't set the size
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
566 * "repeat" == 2: don't open preview window
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
567 * Returns TRUE when the window was resized and the location of the popup menu
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
568 * must be recomputed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
569 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
570 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
571 pum_set_selected(int n, int repeat)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
572 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
573 int resized = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
574 int context = pum_height / 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
575
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
576 pum_selected = n;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
577
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
578 if (pum_selected >= 0 && pum_selected < pum_size)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
579 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
580 if (pum_first > pum_selected - 4)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
581 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
582 /* scroll down; when we did a jump it's probably a PageUp then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
583 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
584 if (pum_first > pum_selected - 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
585 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
586 pum_first -= pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
587 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
588 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
589 else if (pum_first > pum_selected)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
590 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
591 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
592 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
593 pum_first = pum_selected;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
594 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
595 else if (pum_first < pum_selected - pum_height + 5)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
596 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
597 /* scroll up; when we did a jump it's probably a PageDown then
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
598 * scroll a whole page */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
599 if (pum_first < pum_selected - pum_height + 1 + 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
600 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
601 pum_first += pum_height - 2;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
602 if (pum_first < pum_selected - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
603 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
604 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
605 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
606 pum_first = pum_selected - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
607 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
608
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
609 /* Give a few lines of context when possible. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
610 if (context > 3)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
611 context = 3;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
612 if (pum_height > 2)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
613 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
614 if (pum_first > pum_selected - context)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
615 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
616 /* scroll down */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
617 pum_first = pum_selected - context;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
618 if (pum_first < 0)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
619 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
620 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
621 else if (pum_first < pum_selected + context - pum_height + 1)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
622 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
623 /* scroll up */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
624 pum_first = pum_selected + context - pum_height + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
625 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
626 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
627
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
628 #if defined(FEAT_QUICKFIX)
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
629 /*
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
630 * Show extra info in the preview window if there is something and
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
631 * 'completeopt' contains "preview".
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
632 * Skip this when tried twice already.
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
633 * Skip this also when there is not much room.
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
634 * NOTE: Be very careful not to sync undo!
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
635 */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
636 if (pum_array[pum_selected].pum_info != NULL
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
637 && Rows > 10
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
638 && repeat <= 1
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
639 && vim_strchr(p_cot, 'p') != NULL)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
640 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
641 win_T *curwin_save = curwin;
12690
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
642 tabpage_T *curtab_save = curtab;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
643 int res = OK;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
644
2622
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
645 /* 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
646 * 'previewheight' if set and smaller. */
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
647 g_do_tagpreview = 3;
2622
b2cfe84c96cc updated for version 7.3.044
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
648 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
649 g_do_tagpreview = p_pvh;
6043
a97e5b9dbc26 updated for version 7.4.361
Bram Moolenaar <bram@vim.org>
parents: 5444
diff changeset
650 ++RedrawingDisabled;
7181
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
651 /* 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
652 * 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
653 ++no_u_sync;
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
654 resized = prepare_tagpreview(FALSE);
7181
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
655 --no_u_sync;
6043
a97e5b9dbc26 updated for version 7.4.361
Bram Moolenaar <bram@vim.org>
parents: 5444
diff changeset
656 --RedrawingDisabled;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
657 g_do_tagpreview = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
658
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
659 if (curwin->w_p_pvw)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
660 {
10302
210af8588e8a commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
661 if (!resized
210af8588e8a commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
662 && curbuf->b_nwindows == 1
210af8588e8a commit https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
663 && curbuf->b_fname == NULL
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
664 && curbuf->b_p_bt[0] == 'n' && curbuf->b_p_bt[2] == 'f'
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
665 && curbuf->b_p_bh[0] == 'w')
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
666 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
667 /* Already a "wipeout" buffer, make it empty. */
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10410
diff changeset
668 while (!BUFEMPTY())
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
669 ml_delete((linenr_T)1, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
670 }
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
671 else
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
672 {
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
673 /* Don't want to sync undo in the current buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
674 ++no_u_sync;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1668
diff changeset
675 res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
676 --no_u_sync;
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
677 if (res == OK)
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
678 {
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
679 /* Edit a new, empty buffer. Set options for a "wipeout"
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
680 * buffer. */
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
681 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
682 set_option_value((char_u *)"bt", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
683 (char_u *)"nofile", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
684 set_option_value((char_u *)"bh", 0L,
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
685 (char_u *)"wipe", OPT_LOCAL);
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
686 set_option_value((char_u *)"diff", 0L,
1302
7281a86ae640 updated for version 7.1-016
vimboss
parents: 1097
diff changeset
687 NULL, OPT_LOCAL);
825
6675076019ae updated for version 7.0d
vimboss
parents: 816
diff changeset
688 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
689 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
690 if (res == OK)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
691 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
692 char_u *p, *e;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
693 linenr_T lnum = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
694
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
695 for (p = pum_array[pum_selected].pum_info; *p != NUL; )
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
696 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
697 e = vim_strchr(p, '\n');
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
698 if (e == NULL)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
699 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
700 ml_append(lnum++, p, 0, FALSE);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
701 break;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
702 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
703 else
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
704 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
705 *e = NUL;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 825
diff changeset
706 ml_append(lnum++, p, (int)(e - p + 1), FALSE);
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
707 *e = '\n';
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
708 p = e + 1;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
709 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
710 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
711
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
712 /* Increase the height of the preview window to show the
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
713 * text, but no more than 'previewheight' lines. */
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
714 if (repeat == 0)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
715 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
716 if (lnum > p_pvh)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
717 lnum = p_pvh;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
718 if (curwin->w_height < lnum)
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
719 {
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
720 win_setheight((int)lnum);
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
721 resized = TRUE;
8e5830943bff updated for version 7.0e04
vimboss
parents: 835
diff changeset
722 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
723 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
724
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
725 curbuf->b_changed = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
726 curbuf->b_p_ma = FALSE;
2113
85ad19790706 updated for version 7.2.396
Bram Moolenaar <bram@zimbu.org>
parents: 2056
diff changeset
727 curwin->w_cursor.lnum = 1;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
728 curwin->w_cursor.col = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
729
12690
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
730 if ((curwin != curwin_save && win_valid(curwin_save))
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
731 || (curtab != curtab_save
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
732 && valid_tabpage(curtab_save)))
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
733 {
12690
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
734 if (curtab != curtab_save && valid_tabpage(curtab_save))
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
735 goto_tabpage_tp(curtab_save, FALSE, FALSE);
fad36581f788 patch 8.0.1223: crash when using autocomplete and tab pages
Christian Brabandt <cb@256bit.org>
parents: 12566
diff changeset
736
6089
2f02675bc4b0 updated for version 7.4.383
Bram Moolenaar <bram@vim.org>
parents: 6043
diff changeset
737 /* 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
738 * 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
739 * status line redrawing. */
2f02675bc4b0 updated for version 7.4.383
Bram Moolenaar <bram@vim.org>
parents: 6043
diff changeset
740 if (ins_compl_active() && !resized)
2f02675bc4b0 updated for version 7.4.383
Bram Moolenaar <bram@vim.org>
parents: 6043
diff changeset
741 curwin->w_redr_status = FALSE;
2f02675bc4b0 updated for version 7.4.383
Bram Moolenaar <bram@vim.org>
parents: 6043
diff changeset
742
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
743 /* Return cursor to where we were */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
744 validate_cursor();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
745 redraw_later(SOME_VALID);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
746
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
747 /* When the preview window was resized we need to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
748 * update the view on the buffer. Only go back to
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
749 * the window when needed, otherwise it will always be
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
750 * redraw. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
751 if (resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
752 {
7181
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
753 ++no_u_sync;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
754 win_enter(curwin_save, TRUE);
7181
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
755 --no_u_sync;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
756 update_topline();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
757 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
758
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
759 /* Update the screen before drawing the popup menu.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
760 * Enable updating the status lines. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
761 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
762 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
763 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
764
816
4a79d6d376f0 updated for version 7.0c02
vimboss
parents: 800
diff changeset
765 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
766 {
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
767 ++no_u_sync;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
768 win_enter(curwin_save, TRUE);
7181
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
769 --no_u_sync;
ce8b286e89ef commit https://github.com/vim/vim/commit/e7d1376b636e6c758196c3542bd2c1053f9edb75
Christian Brabandt <cb@256bit.org>
parents: 6089
diff changeset
770 }
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
771
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
772 /* May need to update the screen again when there are
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
773 * autocommands involved. */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
774 pum_do_redraw = TRUE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
775 update_screen(0);
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
776 pum_do_redraw = FALSE;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
777 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
778 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
779 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
780 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
781 #endif
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
782 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
783
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
784 if (!resized)
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
785 pum_redraw();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
786
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
787 return resized;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
788 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
789
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
790 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
791 * Undisplay the popup menu (later).
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
792 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
793 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
794 pum_undisplay(void)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
795 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
796 pum_array = NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
797 redraw_all_later(SOME_VALID);
940
306fc545fe2c updated for version 7.0-066
vimboss
parents: 838
diff changeset
798 redraw_tabline = TRUE;
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
799 status_redraw_all();
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
800 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
801
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
802 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
803 * Clear the popup menu. Currently only resets the offset to the first
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
804 * displayed item.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
805 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
806 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
807 pum_clear(void)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
808 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
809 pum_first = 0;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
810 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
811
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
812 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
813 * Return TRUE if the popup menu is displayed.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
814 * Overruled when "pum_do_redraw" is set, used to redraw the status lines.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
815 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
816 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
817 pum_visible(void)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
818 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
819 return !pum_do_redraw && pum_array != NULL;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
820 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
821
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
822 /*
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
823 * Return the height of the popup menu, the number of entries visible.
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
824 * Only valid when pum_visible() returns TRUE!
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
825 */
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
826 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
827 pum_get_height(void)
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
828 {
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
829 return pum_height;
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
830 }
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
831
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12865
diff changeset
832 # if defined(FEAT_BEVAL_TERM) || defined(PROTO)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
833 static pumitem_T *balloon_array = NULL;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
834 static int balloon_arraysize;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
835 static int balloon_mouse_row = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
836 static int balloon_mouse_col = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
837
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
838 #define BALLOON_MIN_WIDTH 50
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
839 #define BALLOON_MIN_HEIGHT 10
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
840
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
841 typedef struct {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
842 char_u *start;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
843 int bytelen;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
844 int cells;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
845 int indent;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
846 } balpart_T;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
847
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
848 /*
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
849 * Split a string into parts to display in the balloon.
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
850 * Aimed at output from gdb. Attempts to split at white space, preserve quoted
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
851 * strings and make a struct look good.
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
852 * Resulting array is stored in "array" and returns the size of the array.
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
853 */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
854 int
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
855 split_message(char_u *mesg, pumitem_T **array)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
856 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
857 garray_T ga;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
858 char_u *p;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
859 balpart_T *item;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
860 int quoted = FALSE;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
861 int height;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
862 int line;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
863 int item_idx;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
864 int indent = 0;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
865 int max_cells = 0;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
866 int max_height = Rows / 2 - 2;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
867 int long_item_count = 0;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
868 int split_long_items = FALSE;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
869
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
870 ga_init2(&ga, sizeof(balpart_T), 20);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
871 p = mesg;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
872
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
873 while (*p != NUL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
874 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
875 if (ga_grow(&ga, 1) == FAIL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
876 goto failed;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
877 item = ((balpart_T *)ga.ga_data) + ga.ga_len;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
878 item->start = p;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
879 item->indent = indent;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
880 item->cells = indent * 2;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
881 ++ga.ga_len;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
882 while (*p != NUL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
883 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
884 if (*p == '"')
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
885 quoted = !quoted;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
886 else if (*p == '\\' && p[1] != NUL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
887 ++p;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
888 else if (!quoted)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
889 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
890 if ((*p == ',' && p[1] == ' ') || *p == '{' || *p == '}')
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
891 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
892 /* Looks like a good point to break. */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
893 if (*p == '{')
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
894 ++indent;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
895 else if (*p == '}' && indent > 0)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
896 --indent;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
897 ++item->cells;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
898 p = skipwhite(p + 1);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
899 break;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
900 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
901 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
902 item->cells += ptr2cells(p);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
903 p += MB_PTR2LEN(p);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
904 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
905 item->bytelen = p - item->start;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
906 if (item->cells > max_cells)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
907 max_cells = item->cells;
12940
5045d3076db0 patch 8.0.1346: crash when passing 50 char string to balloon_split()
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
908 long_item_count += (item->cells - 1) / BALLOON_MIN_WIDTH;
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
909 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
910
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
911 height = 2 + ga.ga_len;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
912
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
913 /* If there are long items and the height is below the limit: split lines */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
914 if (long_item_count > 0 && height + long_item_count <= max_height)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
915 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
916 split_long_items = TRUE;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
917 height += long_item_count;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
918 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
919
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
920 /* Limit to half the window height, it has to fit above or below the mouse
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
921 * position. */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
922 if (height > max_height)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
923 height = max_height;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
924 *array = (pumitem_T *)alloc_clear((unsigned)sizeof(pumitem_T) * height);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
925 if (*array == NULL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
926 goto failed;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
927
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
928 /* Add an empty line above and below, looks better. */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
929 (*array)->pum_text = vim_strsave((char_u *)"");
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
930 (*array + height - 1)->pum_text = vim_strsave((char_u *)"");
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
931
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
932 for (line = 1, item_idx = 0; line < height - 1; ++item_idx)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
933 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
934 int skip;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
935 int thislen;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
936 int copylen;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
937 int ind;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
938 int cells;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
939
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
940 item = ((balpart_T *)ga.ga_data) + item_idx;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
941 for (skip = 0; skip < item->bytelen; skip += thislen)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
942 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
943 if (split_long_items && item->cells >= BALLOON_MIN_WIDTH)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
944 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
945 cells = item->indent * 2;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
946 for (p = item->start + skip; p < item->start + item->bytelen;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
947 p += MB_PTR2LEN(p))
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
948 if ((cells += ptr2cells(p)) > BALLOON_MIN_WIDTH)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
949 break;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
950 thislen = p - (item->start + skip);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
951 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
952 else
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
953 thislen = item->bytelen;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
954
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
955 /* put indent at the start */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
956 p = alloc(thislen + item->indent * 2 + 1);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
957 for (ind = 0; ind < item->indent * 2; ++ind)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
958 p[ind] = ' ';
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
959
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
960 /* exclude spaces at the end of the string */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
961 for (copylen = thislen; copylen > 0; --copylen)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
962 if (item->start[skip + copylen - 1] != ' ')
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
963 break;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
964
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
965 vim_strncpy(p + ind, item->start + skip, copylen);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
966 (*array)[line].pum_text = p;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
967 item->indent = 0; /* wrapped line has no indent */
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
968 ++line;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
969 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
970 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
971 ga_clear(&ga);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
972 return height;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
973
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
974 failed:
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
975 ga_clear(&ga);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
976 return 0;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
977 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
978
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
979 void
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
980 ui_remove_balloon(void)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
981 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
982 if (balloon_array != NULL)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
983 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
984 pum_undisplay();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
985 while (balloon_arraysize > 0)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
986 vim_free(balloon_array[--balloon_arraysize].pum_text);
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
987 vim_free(balloon_array);
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
988 balloon_array = NULL;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
989 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
990 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
991
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
992 /*
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
993 * Terminal version of a balloon, uses the popup menu code.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
994 */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
995 void
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
996 ui_post_balloon(char_u *mesg, list_T *list)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
997 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
998 ui_remove_balloon();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
999
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1000 if (mesg == NULL && list == NULL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1001 return;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1002 if (list != NULL)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1003 {
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1004 listitem_T *li;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1005 int idx;
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1006
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1007 balloon_arraysize = list->lv_len;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1008 balloon_array = (pumitem_T *)alloc_clear(
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1009 (unsigned)sizeof(pumitem_T) * list->lv_len);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1010 if (balloon_array == NULL)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1011 return;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1012 for (idx = 0, li = list->lv_first; li != NULL; li = li->li_next, ++idx)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1013 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1014 char_u *text = get_tv_string_chk(&li->li_tv);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1015
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1016 balloon_array[idx].pum_text = vim_strsave(
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1017 text == NULL ? (char_u *)"" : text);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1018 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1019 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1020 else
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1021 balloon_arraysize = split_message(mesg, &balloon_array);
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1022
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1023 if (balloon_arraysize > 0)
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1024 {
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1025 pum_array = balloon_array;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1026 pum_size = balloon_arraysize;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1027 pum_compute_size();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1028 pum_scrollbar = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1029 pum_height = balloon_arraysize;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1030
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1031 if (Rows - mouse_row > pum_size)
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1032 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1033 /* Enough space below the mouse row. */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1034 pum_row = mouse_row + 1;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1035 if (pum_height > Rows - pum_row)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1036 pum_height = Rows - pum_row;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1037 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1038 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1039 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1040 /* Show above the mouse row, reduce height if it does not fit. */
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1041 pum_row = mouse_row - pum_size;
12865
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1042 if (pum_row < 0)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1043 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1044 pum_height += pum_row;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1045 pum_row = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1046 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1047 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1048 if (Columns - mouse_col >= pum_base_width
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1049 || Columns - mouse_col > BALLOON_MIN_WIDTH)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1050 /* Enough space to show at mouse column. */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1051 pum_col = mouse_col;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1052 else
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1053 /* Not enough space, right align with window. */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1054 pum_col = Columns - (pum_base_width > BALLOON_MIN_WIDTH
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1055 ? BALLOON_MIN_WIDTH : pum_base_width);
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1056
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1057 pum_width = Columns - pum_col;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1058 if (pum_width > pum_base_width + 1)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1059 pum_width = pum_base_width + 1;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1060
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1061 pum_selected = -1;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1062 pum_first = 0;
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1063 pum_redraw();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1064 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1065 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1066
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1067 /*
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1068 * Called when the mouse moved, may remove any displayed balloon.
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1069 */
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1070 void
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1071 ui_may_remove_balloon(void)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1072 {
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1073 if (mouse_row != balloon_mouse_row || mouse_col != balloon_mouse_col)
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1074 ui_remove_balloon();
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1075 }
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12690
diff changeset
1076 # endif
13234
6e972d830e13 patch 8.0.1491: the minimum width of the popup menu is hard coded
Christian Brabandt <cb@256bit.org>
parents: 12940
diff changeset
1077
800
d8f905020502 updated for version 7.0b
vimboss
parents:
diff changeset
1078 #endif