comparison runtime/doc/popup.txt @ 17413:40417757dffd v8.1.1705

patch 8.1.1705: using ~{} for a literal dict is not nice commit https://github.com/vim/vim/commit/4c6d90458baae843463f930fdc3fe4a7a2191d27 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 16 22:04:02 2019 +0200 patch 8.1.1705: using ~{} for a literal dict is not nice Problem: Using ~{} for a literal dict is not nice. Solution: Use #{} instead.
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Jul 2019 22:15:05 +0200
parents 2558f90045e5
children 6e756ad5ef1a
comparison
equal deleted inserted replaced
17412:6ab542e33829 17413:40417757dffd
176 DETAILS *popup-function-details* 176 DETAILS *popup-function-details*
177 177
178 popup_atcursor({what}, {options}) *popup_atcursor()* 178 popup_atcursor({what}, {options}) *popup_atcursor()*
179 Show the {what} above the cursor, and close it when the cursor 179 Show the {what} above the cursor, and close it when the cursor
180 moves. This works like: > 180 moves. This works like: >
181 call popup_create({what}, ~{ 181 call popup_create({what}, #{
182 \ pos: 'botleft', 182 \ pos: 'botleft',
183 \ line: 'cursor-1', 183 \ line: 'cursor-1',
184 \ col: 'cursor', 184 \ col: 'cursor',
185 \ moved: 'WORD', 185 \ moved: 'WORD',
186 \ }) 186 \ })
189 189
190 popup_beval({what}, {options}) *popup_beval()* 190 popup_beval({what}, {options}) *popup_beval()*
191 Show the {what} above the position from 'ballooneval' and 191 Show the {what} above the position from 'ballooneval' and
192 close it when the mouse moves. This works like: > 192 close it when the mouse moves. This works like: >
193 let pos = screenpos(v:beval_winnr, v:beval_lnum, v:beval_col) 193 let pos = screenpos(v:beval_winnr, v:beval_lnum, v:beval_col)
194 call popup_create({what}, ~{ 194 call popup_create({what}, #{
195 \ pos: 'botleft', 195 \ pos: 'botleft',
196 \ line: pos.row - 1, 196 \ line: pos.row - 1,
197 \ col: pos.col, 197 \ col: pos.col,
198 \ mousemoved: 'WORD', 198 \ mousemoved: 'WORD',
199 \ }) 199 \ })
238 < In case of failure zero is returned. 238 < In case of failure zero is returned.
239 239
240 240
241 popup_dialog({what}, {options}) *popup_dialog()* 241 popup_dialog({what}, {options}) *popup_dialog()*
242 Just like |popup_create()| but with these default options: > 242 Just like |popup_create()| but with these default options: >
243 call popup_create({what}, ~{ 243 call popup_create({what}, #{
244 \ pos: 'center', 244 \ pos: 'center',
245 \ zindex: 200, 245 \ zindex: 200,
246 \ drag: 1, 246 \ drag: 1,
247 \ border: [], 247 \ border: [],
248 \ padding: [], 248 \ padding: [],
249 \}) 249 \})
250 < Use {options} to change the properties. E.g. add a 'filter' 250 < Use {options} to change the properties. E.g. add a 'filter'
251 option with value 'popup_filter_yesno'. Example: > 251 option with value 'popup_filter_yesno'. Example: >
252 call popup_create('do you want to quit (Yes/no)?', ~{ 252 call popup_create('do you want to quit (Yes/no)?', #{
253 \ filter: 'popup_filter_yesno', 253 \ filter: 'popup_filter_yesno',
254 \ callback: 'QuitCallback', 254 \ callback: 'QuitCallback',
255 \ }) 255 \ })
256 256
257 < By default the dialog can be dragged, so that text below it 257 < By default the dialog can be dragged, so that text below it
354 popup_menu({what}, {options}) *popup_menu()* 354 popup_menu({what}, {options}) *popup_menu()*
355 Show the {what} near the cursor, handle selecting one of the 355 Show the {what} near the cursor, handle selecting one of the
356 items with cursorkeys, and close it an item is selected with 356 items with cursorkeys, and close it an item is selected with
357 Space or Enter. {what} should have multiple lines to make this 357 Space or Enter. {what} should have multiple lines to make this
358 useful. This works like: > 358 useful. This works like: >
359 call popup_create({what}, ~{ 359 call popup_create({what}, #{
360 \ pos: 'center', 360 \ pos: 'center',
361 \ zindex: 200, 361 \ zindex: 200,
362 \ drag: 1, 362 \ drag: 1,
363 \ wrap: 0, 363 \ wrap: 0,
364 \ border: [], 364 \ border: [],
389 389
390 390
391 popup_notification({what}, {options}) *popup_notification()* 391 popup_notification({what}, {options}) *popup_notification()*
392 Show the {what} for 3 seconds at the top of the Vim window. 392 Show the {what} for 3 seconds at the top of the Vim window.
393 This works like: > 393 This works like: >
394 call popup_create({what}, ~{ 394 call popup_create({what}, #{
395 \ line: 1, 395 \ line: 1,
396 \ col: 10, 396 \ col: 10,
397 \ minwidth: 20, 397 \ minwidth: 20,
398 \ time: 3000, 398 \ time: 3000,
399 \ tabpage: -1, 399 \ tabpage: -1,
730 if a:result 730 if a:result
731 " ... 'y' or 'Y' was pressed 731 " ... 'y' or 'Y' was pressed
732 endif 732 endif
733 endfunc 733 endfunc
734 734
735 call popup_dialog('Continue? y/n', ~{ 735 call popup_dialog('Continue? y/n', #{
736 \ filter: 'popup_filter_yesno', 736 \ filter: 'popup_filter_yesno',
737 \ callback: 'MyDialogHandler', 737 \ callback: 'MyDialogHandler',
738 \ }) 738 \ })
739 < 739 <
740 *popup_menu-shortcut-example* 740 *popup_menu-shortcut-example*
741 Extend popup_filter_menu() with shortcut keys: > 741 Extend popup_filter_menu() with shortcut keys: >
742 742
743 call popup_menu(['Save', 'Cancel', 'Discard'], ~{ 743 call popup_menu(['Save', 'Cancel', 'Discard'], #{
744 \ filter: 'MyMenuFilter', 744 \ filter: 'MyMenuFilter',
745 \ callback: 'MyMenuHandler', 745 \ callback: 'MyMenuHandler',
746 \ }) 746 \ })
747 747
748 func MyMenuFilter(id, key) 748 func MyMenuFilter(id, key)
779 " Still the same text, keep the existing popup 779 " Still the same text, keep the existing popup
780 return '' 780 return ''
781 endif 781 endif
782 call popup_close(s:winid) 782 call popup_close(s:winid)
783 endif 783 endif
784 let s:winid = popup_beval(v:beval_text, ~{mousemoved: 'word'}) 784 let s:winid = popup_beval(v:beval_text, #{mousemoved: 'word'})
785 let s:last_text = v:beval_text 785 let s:last_text = v:beval_text
786 return '' 786 return ''
787 endfunc 787 endfunc
788 < 788 <
789 If the text has to be obtained asynchronously return an empty string from the 789 If the text has to be obtained asynchronously return an empty string from the
810 call timer_start(100, 'ShowPopup') 810 call timer_start(100, 'ShowPopup')
811 return '' 811 return ''
812 endfunc 812 endfunc
813 813
814 func ShowPopup(id) 814 func ShowPopup(id)
815 let s:winid = popup_beval(s:balloonText, ~{mousemoved: 'word'}) 815 let s:winid = popup_beval(s:balloonText, #{mousemoved: 'word'})
816 endfunc 816 endfunc
817 < 817 <
818 818
819 vim:tw=78:ts=8:noet:ft=help:norl: 819 vim:tw=78:ts=8:noet:ft=help:norl: