summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1303
blob: 1e02df5d90561d8eb3aad574c3e60ec3df57f2d4 (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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1303
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.1303
Problem:    Not possible to hide a balloon.
Solution:   Hide the balloon when balloon_show() is called with an empty
            string or list.  Add balloon_gettext().
Files:	    src/evalfunc.c, src/popupmnu.c, src/gui_beval.c, src/gui_w32.c,
            src/beval.h, src/testdir/test_balloon.vim, runtime/doc/eval.txt


*** ../vim-8.1.1302/src/evalfunc.c	2019-05-07 22:06:48.675310695 +0200
--- src/evalfunc.c	2019-05-09 13:37:08.630549700 +0200
***************
*** 63,68 ****
--- 63,69 ----
  static void f_atan2(typval_T *argvars, typval_T *rettv);
  #endif
  #ifdef FEAT_BEVAL
+ static void f_balloon_gettext(typval_T *argvars, typval_T *rettv);
  static void f_balloon_show(typval_T *argvars, typval_T *rettv);
  # if defined(FEAT_BEVAL_TERM)
  static void f_balloon_split(typval_T *argvars, typval_T *rettv);
***************
*** 552,557 ****
--- 553,559 ----
      {"atan2",		2, 2, f_atan2},
  #endif
  #ifdef FEAT_BEVAL
+     {"balloon_gettext",	0, 0, f_balloon_gettext},
      {"balloon_show",	1, 1, f_balloon_show},
  # if defined(FEAT_BEVAL_TERM)
      {"balloon_split",	1, 1, f_balloon_split},
***************
*** 1764,1769 ****
--- 1766,1784 ----
   */
  #ifdef FEAT_BEVAL
      static void
+ f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+     rettv->v_type = VAR_STRING;
+     if (balloonEval != NULL)
+     {
+ 	if (balloonEval->msg == NULL)
+ 	    rettv->vval.v_string = NULL;
+ 	else
+ 	    rettv->vval.v_string = vim_strsave(balloonEval->msg);
+     }
+ }
+ 
+     static void
  f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
  {
      if (balloonEval != NULL)
***************
*** 1773,1781 ****
  		&& !gui.in_use
  # endif
  	   )
! 	    post_balloon(balloonEval, NULL, argvars[0].vval.v_list);
  	else
! 	    post_balloon(balloonEval, tv_get_string_chk(&argvars[0]), NULL);
      }
  }
  
--- 1788,1808 ----
  		&& !gui.in_use
  # endif
  	   )
! 	{
! 	    list_T *l = argvars[0].vval.v_list;
! 
! 	    // empty list removes the balloon
! 	    post_balloon(balloonEval, NULL,
! 				       l == NULL || l->lv_len == 0 ? NULL : l);
! 	}
  	else
! 	{
! 	    char_u *mesg = tv_get_string_chk(&argvars[0]);
! 
! 	    if (mesg != NULL)
! 		// empty string removes the balloon
! 		post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
! 	}
      }
  }
  
*** ../vim-8.1.1302/src/popupmnu.c	2019-04-27 22:06:33.348200718 +0200
--- src/popupmnu.c	2019-05-09 13:00:32.746821137 +0200
***************
*** 1154,1160 ****
--- 1154,1163 ----
      ui_remove_balloon();
  
      if (mesg == NULL && list == NULL)
+     {
+ 	pum_undisplay();
  	return;
+     }
      if (list != NULL)
      {
  	listitem_T  *li;
*** ../vim-8.1.1302/src/gui_beval.c	2019-02-17 17:44:36.207875527 +0100
--- src/gui_beval.c	2019-05-09 13:22:36.063032440 +0200
***************
*** 117,123 ****
  	beval->appContext = XtWidgetToApplicationContext((Widget)target);
  #endif
  	beval->showState = ShS_NEUTRAL;
! 	beval->msg = mesg;
  	beval->msgCB = mesgCB;
  	beval->clientData = clientData;
  
--- 117,124 ----
  	beval->appContext = XtWidgetToApplicationContext((Widget)target);
  #endif
  	beval->showState = ShS_NEUTRAL;
! 	vim_free(beval->msg);
! 	beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
  	beval->msgCB = mesgCB;
  	beval->clientData = clientData;
  
***************
*** 208,215 ****
      void
  gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
  {
!     beval->msg = mesg;
!     if (mesg != NULL)
  	drawBalloon(beval);
      else
  	undrawBalloon(beval);
--- 209,217 ----
      void
  gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
  {
!     vim_free(beval->msg);
!     beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
!     if (beval->msg != NULL)
  	drawBalloon(beval);
      else
  	undrawBalloon(beval);
***************
*** 225,230 ****
--- 227,233 ----
      void
  gui_mch_unpost_balloon(BalloonEval *beval)
  {
+     VIM_CLEAR(beval->msg);
      undrawBalloon(beval);
  }
  #endif
***************
*** 975,980 ****
--- 978,984 ----
  	gtk_widget_show(beval->balloonShell);
  
  	beval->showState = ShS_SHOWING;
+ 	gui_mch_update();
      }
  }
  
*** ../vim-8.1.1302/src/gui_w32.c	2019-05-08 22:28:41.677765838 +0200
--- src/gui_w32.c	2019-05-09 13:25:57.537884363 +0200
***************
*** 8506,8511 ****
--- 8506,8520 ----
  {
      POINT   pt;
  
+     vim_free(beval->msg);
+     beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
+     if (beval->msg == NULL)
+     {
+ 	delete_tooltip(beval);
+ 	beval->showState = ShS_NEUTRAL;
+ 	return;
+     }
+ 
      // TRACE0("gui_mch_post_balloon {{{");
      if (beval->showState == ShS_SHOWING)
  	return;
*** ../vim-8.1.1302/src/beval.h	2019-02-17 17:44:36.199875566 +0100
--- src/beval.h	2019-05-09 13:23:08.630846624 +0200
***************
*** 75,81 ****
  #ifdef FEAT_VARTABS
      int			*vts;		// vartabstop setting for this buffer
  #endif
!     char_u		*msg;
  #ifdef FEAT_GUI_MSWIN
      void		*tofree;
  #endif
--- 75,81 ----
  #ifdef FEAT_VARTABS
      int			*vts;		// vartabstop setting for this buffer
  #endif
!     char_u		*msg;		// allocated: current text
  #ifdef FEAT_GUI_MSWIN
      void		*tofree;
  #endif
*** ../vim-8.1.1302/src/testdir/test_balloon.vim	2019-05-08 22:54:26.023509040 +0200
--- src/testdir/test_balloon.vim	2019-05-09 13:44:47.320155388 +0200
***************
*** 1,8 ****
  " Tests for 'balloonevalterm'.
  
! if !has('balloon_eval_term') || has('gui_running')
!   finish
! endif
  
  source screendump.vim
  if !CanRunVimInTerminal()
--- 1,7 ----
  " Tests for 'balloonevalterm'.
  
! " Tests that only work in the terminal.
! if has('balloon_eval_term') && !has('gui_running')
  
  source screendump.vim
  if !CanRunVimInTerminal()
***************
*** 53,55 ****
--- 52,75 ----
    call StopVimInTerminal(buf)
    call delete('XTest_beval_visual')
  endfunc
+ 
+ endif
+ 
+ " Tests that only work in the GUI
+ if has('gui_running')
+ 
+ func Test_balloon_show_gui()
+   let msg = 'this this this this'
+   call balloon_show(msg)
+   call assert_equal(msg, balloon_gettext())
+   sleep 10m
+   call balloon_show('')
+ 
+   let msg = 'that that'
+   call balloon_show(msg)
+   call assert_equal(msg, balloon_gettext())
+   sleep 10m
+   call balloon_show('')
+ endfunc
+ 
+ endif
*** ../vim-8.1.1302/runtime/doc/eval.txt	2019-05-07 22:06:48.675310695 +0200
--- runtime/doc/eval.txt	2019-05-09 13:38:34.266112489 +0200
***************
*** 2226,2231 ****
--- 2226,2232 ----
  asin({expr})			Float	arc sine of {expr}
  atan({expr})			Float	arc tangent of {expr}
  atan2({expr1}, {expr2})		Float	arc tangent of {expr1} / {expr2}
+ balloon_gettext()		String	current text in the balloon
  balloon_show({expr})		none	show {expr} inside the balloon
  balloon_split({msg})		List	split {msg} as used for a balloon
  browse({save}, {title}, {initdir}, {default})
***************
*** 3007,3021 ****
  <			2.356194
  		{only available when compiled with the |+float| feature}
  
  balloon_show({expr})					*balloon_show()*
  		Show {expr} inside the balloon.  For the GUI {expr} is used as
  		a string.  For a terminal {expr} can be a list, which contains
  		the lines of the balloon.  If {expr} is not a list it will be
  		split with |balloon_split()|.
  
  		Example: >
  			func GetBalloonContent()
! 			   " initiate getting the content
  			   return ''
  			endfunc
  			set balloonexpr=GetBalloonContent()
--- 3008,3027 ----
  <			2.356194
  		{only available when compiled with the |+float| feature}
  
+ balloon_gettext()					*balloon_gettext()*
+ 		Return the current text in the balloon.  Only for the string,
+ 		not used for the List.
+ 
  balloon_show({expr})					*balloon_show()*
  		Show {expr} inside the balloon.  For the GUI {expr} is used as
  		a string.  For a terminal {expr} can be a list, which contains
  		the lines of the balloon.  If {expr} is not a list it will be
  		split with |balloon_split()|.
+ 		If {expr} is an empty string any existing balloon is removed.
  
  		Example: >
  			func GetBalloonContent()
! 			   " ... initiate getting the content
  			   return ''
  			endfunc
  			set balloonexpr=GetBalloonContent()
***************
*** 4229,4234 ****
--- 4235,4242 ----
  		and "\..." notation |expr-quote|. For example,
  		feedkeys("\<CR>") simulates pressing of the <Enter> key. But
  		feedkeys('\<CR>') pushes 5 characters.
+ 		A special code that might be useful is <Ignore>, it exits the
+ 		wait for a character without doing anything.  *<Ignore>*
  
  		{mode} is a String, which can contain these character flags:
  		'm'	Remap keys. This is default.  If {mode} is absent,
*** ../vim-8.1.1302/src/version.c	2019-05-08 22:54:26.023509040 +0200
--- src/version.c	2019-05-09 13:47:18.087347922 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1303,
  /**/

-- 
   [The rest of the ARMY stand around looking at a loss.]
INSPECTOR END OF FILM: (picks up megaphone) All right!  Clear off!  Go on!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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    ///