summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1422
blob: fd0a0045590c98e6c110bd4066600fd9a5b8fdab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1422
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1422
Problem:    Popup_getoptions() not implemented yet.
Solution:   Implement it. (closes #4452)
Files:	    runtime/doc/popup.txt, src/evalfunc.c, src/popupwin.c,
            src/proto/popupwin.pro, src/testdir/test_popupwin.vim


*** ../vim-8.1.1421/runtime/doc/popup.txt	2019-05-29 21:44:30.764788713 +0200
--- runtime/doc/popup.txt	2019-05-30 14:24:42.327163943 +0200
***************
*** 86,100 ****
  IMPLEMENTATION:
  - Code is in popupwin.c
  - when creating the window set options to Vim default? (verify with 'number')
- - Do not show tilde below last line.
  - Implement filter.
    Check that popup_close() works in the filter.
  - Handle screen resize in screenalloc().
  - Make redrawing more efficient and avoid flicker.
      Fix redrawing problem with completion.
      Fix redrawing problem when scrolling non-current window
      Fix redrawing the statusline on top of a popup
! - Properly figure out the size and position.
  - Can the buffer be re-used, to avoid using up lots of buffer numbers?
  - Implement all the unimplemented options and features.
  
--- 86,103 ----
  IMPLEMENTATION:
  - Code is in popupwin.c
  - when creating the window set options to Vim default? (verify with 'number')
  - Implement filter.
    Check that popup_close() works in the filter.
+ - Implement the "pos" option.
  - Handle screen resize in screenalloc().
  - Make redrawing more efficient and avoid flicker.
+     Store popup info in a mask, use the mask in screen_line()
      Fix redrawing problem with completion.
      Fix redrawing problem when scrolling non-current window
      Fix redrawing the statusline on top of a popup
! - Figure out the size and position better.
!     if wrapping splits a double-wide character
!     if wrapping has an indent
  - Can the buffer be re-used, to avoid using up lots of buffer numbers?
  - Implement all the unimplemented options and features.
  
***************
*** 228,243 ****
  
  
  popup_getoptions({id})					*popup_getoptions()*
! 	  	{not implemented yet}
! 		Return the {options} for popup {id}.
  
  popup_getposition({id})					*popup_getposition()*
  		Return the position and size of popup {id}.  Returns a Dict
  		with these entries:
! 			col	screen column of the popup, one-based
! 			line	screen line of the popup, one-based
! 			width	width of the popup in screen cells
! 			height	height of the popup in screen cells
  		Note that these are the actual screen positions.  They differ
  		from the values in `popup_getoptions()` for the sizing and
  		positioning mechanism applied.
--- 231,253 ----
  
  
  popup_getoptions({id})					*popup_getoptions()*
! 		Return the {options} for popup {id} in a Dict.
! 		A zero value means the option was not set.
! 
! 		The "highlight" entry is omitted, use the 'wincolor' option
! 		for that: >
! 			let hl = getwinvar(winid, '&wincolor')
! 
! <		If popup window {id} is not found an empty Dict is returned.
  
  popup_getposition({id})					*popup_getposition()*
  		Return the position and size of popup {id}.  Returns a Dict
  		with these entries:
! 		    col		screen column of the popup, one-based
! 		    line	screen line of the popup, one-based
! 		    width	width of the popup in screen cells
! 		    height	height of the popup in screen cells
! 		    visible 	one if the popup is displayed, zero if hidden
  		Note that these are the actual screen positions.  They differ
  		from the values in `popup_getoptions()` for the sizing and
  		positioning mechanism applied.
***************
*** 304,312 ****
  			{only number is implemented}
  	pos		"topleft", "topright", "botleft" or "botright":
  			defines what corner of the popup "line" and "col" are
! 			used for.  Default is "botleft".  Alternatively
! 			"center" can be used to position the popup in the
! 			center of the Vim window.
  			{not implemented yet}
  	flip		when TRUE (the default) and the position is relative
  			to the cursor, flip to below or above the cursor to
--- 314,322 ----
  			{only number is implemented}
  	pos		"topleft", "topright", "botleft" or "botright":
  			defines what corner of the popup "line" and "col" are
! 			used for.  When not set "topleft" is used.
! 			Alternatively "center" can be used to position the
! 			popup in the center of the Vim window.
  			{not implemented yet}
  	flip		when TRUE (the default) and the position is relative
  			to the cursor, flip to below or above the cursor to
*** ../vim-8.1.1421/src/evalfunc.c	2019-05-29 21:44:30.764788713 +0200
--- src/evalfunc.c	2019-05-30 14:12:04.363485719 +0200
***************
*** 811,816 ****
--- 811,817 ----
  #ifdef FEAT_TEXT_PROP
      {"popup_close",	1, 1, f_popup_close},
      {"popup_create",	2, 2, f_popup_create},
+     {"popup_getoptions", 1, 1, f_popup_getoptions},
      {"popup_getposition", 1, 1, f_popup_getposition},
      {"popup_hide",	1, 1, f_popup_hide},
      {"popup_move",	2, 2, f_popup_move},
*** ../vim-8.1.1421/src/popupwin.c	2019-05-30 00:11:48.704086357 +0200
--- src/popupwin.c	2019-05-30 14:23:50.803455533 +0200
***************
*** 530,535 ****
--- 530,567 ----
  	dict_add_number(dict, "col", wp->w_wincol + 1);
  	dict_add_number(dict, "width", wp->w_width);
  	dict_add_number(dict, "height", wp->w_height);
+ 	dict_add_number(dict, "visible",
+ 				       (wp->w_popup_flags & POPF_HIDDEN) == 0);
+     }
+ }
+ 
+ /*
+  * f_popup_getoptions({id})
+  */
+     void
+ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
+ {
+     dict_T	*dict;
+     int		id = (int)tv_get_number(argvars);
+     win_T	*wp = find_popup_win(id);
+ 
+     if (rettv_dict_alloc(rettv) == OK)
+     {
+ 	if (wp == NULL)
+ 	    return;
+ 
+ 	dict = rettv->vval.v_dict;
+ 	dict_add_number(dict, "line", wp->w_wantline);
+ 	dict_add_number(dict, "col", wp->w_wantcol);
+ 	dict_add_number(dict, "minwidth", wp->w_minwidth);
+ 	dict_add_number(dict, "minheight", wp->w_minheight);
+ 	dict_add_number(dict, "maxheight", wp->w_maxheight);
+ 	dict_add_number(dict, "maxwidth", wp->w_maxwidth);
+ 	dict_add_number(dict, "zindex", wp->w_zindex);
+ # if defined(FEAT_TIMERS)
+ 	dict_add_number(dict, "time", wp->w_popup_timer != NULL
+ 				 ?  (long)wp->w_popup_timer->tr_interval : 0L);
+ # endif
      }
  }
  #endif // FEAT_TEXT_PROP
*** ../vim-8.1.1421/src/proto/popupwin.pro	2019-05-30 00:11:48.704086357 +0200
--- src/proto/popupwin.pro	2019-05-30 14:11:15.287769511 +0200
***************
*** 10,14 ****
--- 10,15 ----
  void close_all_popups(void);
  void ex_popupclear(exarg_T *eap);
  void f_popup_move(typval_T *argvars, typval_T *rettv);
+ void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
  void f_popup_getposition(typval_T *argvars, typval_T *rettv);
  /* vim: set ft=c : */
*** ../vim-8.1.1421/src/testdir/test_popupwin.vim	2019-05-30 00:11:48.704086357 +0200
--- src/testdir/test_popupwin.vim	2019-05-30 14:28:02.174052682 +0200
***************
*** 108,123 ****
--- 108,126 ----
    redraw
    let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
    call assert_equal('world', line)
+   call assert_equal(1, popup_getposition(winid).visible)
  
    call popup_hide(winid)
    redraw
    let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
    call assert_equal('hello', line)
+   call assert_equal(0, popup_getposition(winid).visible)
  
    call popup_show(winid)
    redraw
    let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
    call assert_equal('world', line)
+   call assert_equal(1, popup_getposition(winid).visible)
  
  
    call popup_close(winid)
***************
*** 178,183 ****
--- 181,187 ----
    call assert_equal(3, res.col)
    call assert_equal(10, res.width)
    call assert_equal(11, res.height)
+   call assert_equal(1, res.visible)
  
    call popup_close(winid)
  endfunc
***************
*** 215,219 ****
--- 219,266 ----
      call assert_equal(test[2], position.height)
  
      call popup_close(winid)
+     call assert_equal({}, popup_getposition(winid))
    endfor
  endfunc
+ 
+ func Test_popup_getoptions()
+   let winid = popup_create('hello', {
+     \ 'line': 2,
+     \ 'col': 3,
+     \ 'minwidth': 10,
+     \ 'minheight': 11,
+     \ 'maxwidth': 20,
+     \ 'maxheight': 21,
+     \ 'zindex': 100,
+     \ 'time': 5000,
+     \})
+   redraw
+   let res = popup_getoptions(winid)
+   call assert_equal(2, res.line)
+   call assert_equal(3, res.col)
+   call assert_equal(10, res.minwidth)
+   call assert_equal(11, res.minheight)
+   call assert_equal(20, res.maxwidth)
+   call assert_equal(21, res.maxheight)
+   call assert_equal(100, res.zindex)
+   if has('timers')
+     call assert_equal(5000, res.time)
+   endif
+   call popup_close(winid)
+ 
+   let winid = popup_create('hello', {})
+   redraw
+   let res = popup_getoptions(winid)
+   call assert_equal(0, res.line)
+   call assert_equal(0, res.col)
+   call assert_equal(0, res.minwidth)
+   call assert_equal(0, res.minheight)
+   call assert_equal(0, res.maxwidth)
+   call assert_equal(0, res.maxheight)
+   call assert_equal(50, res.zindex)
+   if has('timers')
+     call assert_equal(0, res.time)
+   endif
+   call popup_close(winid)
+   call assert_equal({}, popup_getoptions(winid))
+ endfunc
*** ../vim-8.1.1421/src/version.c	2019-05-30 00:11:48.704086357 +0200
--- src/version.c	2019-05-30 14:28:17.621969065 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1422,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
50. The last girl you picked up was only a jpeg.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///