comparison runtime/doc/popup.txt @ 17320:33dccaafb214 v8.1.1659

patch 8.1.1659: popup window "mousemoved" values not correct commit https://github.com/vim/vim/commit/b05caa782dbab51db8de60940eff7992f8cfd882 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 10 21:55:54 2019 +0200 patch 8.1.1659: popup window "mousemoved" values not correct Problem: Popup window "mousemoved" values not correct. Solution: Convert text column to mouse column.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jul 2019 22:00:04 +0200
parents 8a095d343c59
children d82b0cfb1e82
comparison
equal deleted inserted replaced
17319:f0ecd01d17ab 17320:33dccaafb214
190 Show the {what} above the position from 'ballooneval' and 190 Show the {what} above the position from 'ballooneval' and
191 close it when the mouse moves. This works like: > 191 close it when the mouse moves. This works like: >
192 let pos = screenpos(v:beval_winnr, v:beval_lnum, v:beval_col) 192 let pos = screenpos(v:beval_winnr, v:beval_lnum, v:beval_col)
193 call popup_create({what}, { 193 call popup_create({what}, {
194 \ 'pos': 'botleft', 194 \ 'pos': 'botleft',
195 \ 'line': pos.lnum - 1, 195 \ 'line': pos.row - 1,
196 \ 'col': pos.col, 196 \ 'col': pos.col,
197 \ 'mousemoved': 'WORD', 197 \ 'mousemoved': 'WORD',
198 \ }) 198 \ })
199 < Use {options} to change the properties. 199 < Use {options} to change the properties.
200 See |popup_beval_example| for an example use. 200 See |popup_beval_example| for an example use.
760 Example for using a popup window for 'ballooneval': > 760 Example for using a popup window for 'ballooneval': >
761 761
762 set ballooneval balloonevalterm 762 set ballooneval balloonevalterm
763 set balloonexpr=BalloonExpr() 763 set balloonexpr=BalloonExpr()
764 let s:winid = 0 764 let s:winid = 0
765 let s:last_text = ''
765 766
766 func BalloonExpr() 767 func BalloonExpr()
767 if s:winid 768 if s:winid && popup_getpos(s:winid) != {}
769 " previous popup window still shows
770 if v:beval_text == s:last_text
771 " Still the same text, keep the existing popup
772 return ''
773 endif
768 call popup_close(s:winid) 774 call popup_close(s:winid)
769 let s:winid = 0
770 endif 775 endif
771 let s:winid = popup_beval([bufname(v:beval_bufnr), v:beval_text], {}) 776 let s:winid = popup_beval(v:beval_text, {'mousemoved': 'word'})
777 let s:last_text = v:beval_text
772 return '' 778 return ''
773 endfunc 779 endfunc
774 < 780 <
775 If the text has to be obtained asynchronously return an empty string from the 781 If the text has to be obtained asynchronously return an empty string from the
776 expression function and call popup_beval() once the text is available. In 782 expression function and call popup_beval() once the text is available. In
777 this example similated with a timer callback: > 783 this example simulated with a timer callback: >
778 784
779 set ballooneval balloonevalterm 785 set ballooneval balloonevalterm
780 set balloonexpr=BalloonExpr() 786 set balloonexpr=BalloonExpr()
781 let s:winid = 0 787 let s:winid = 0
788 let s:balloonText = ''
782 789
783 func BalloonExpr() 790 func BalloonExpr()
784 if s:winid 791 if s:winid && popup_getpos(s:winid) != {}
792 " previous popup window still shows
793 if v:beval_text == s:balloonText
794 " Still the same text, keep the existing popup
795 return ''
796 endif
785 call popup_close(s:winid) 797 call popup_close(s:winid)
786 let s:winid = 0 798 let s:winid = 0
787 endif 799 endif
788 " simulate an asynchronous loopup for the text to display 800 " simulate an asynchronous loopup for the text to display
789 let s:balloonFile = bufname(v:beval_bufnr) 801 let s:balloonText = v:beval_text
790 let s:balloonWord = v:beval_text
791 call timer_start(100, 'ShowPopup') 802 call timer_start(100, 'ShowPopup')
792 return '' 803 return ''
793 endfunc 804 endfunc
794 805
795 func ShowPopup(id) 806 func ShowPopup(id)
796 let s:winid = popup_beval([s:balloonFile, s:balloonWord], {}) 807 let s:winid = popup_beval(s:balloonText, {'mousemoved': 'word'})
797 endfunc 808 endfunc
798 < 809 <
799 810
800 vim:tw=78:ts=8:noet:ft=help:norl: 811 vim:tw=78:ts=8:noet:ft=help:norl: