Skip to content

Commit 34bf4e1

Browse files
add show() hide() methods
1 parent 0aade33 commit 34bf4e1

File tree

1 file changed

+31
-11
lines changed
  • autoload/vital/__vital__/Experimental/UI

1 file changed

+31
-11
lines changed

autoload/vital/__vital__/Experimental/UI/Popup.vim

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,41 @@ function! s:create(opt) abort
4444
endif
4545
let s:_popups[id] = data
4646
call s:_notify(id, {}, 'create')
47+
call s:_notify(id, {}, 'show')
4748
return id
4849
endfunction
4950

5051
function! s:close(id) abort
51-
if has_key(s:_popups, a:id)
52-
let data = s:_popups[a:id]
53-
if s:_has_nvim
54-
call nvim_win_close(data['winid'], 1)
55-
let data['winid'] = 0
56-
else
57-
call popup_close(data['winid'])
58-
endif
59-
call s:_notify(a:id, {}, 'close')
60-
call remove(s:_popups, a:id)
52+
let data = s:_popups[a:id]
53+
if s:_has_nvim
54+
call nvim_win_close(data['winid'], 1)
55+
let data['winid'] = 0
56+
else
57+
call popup_close(data['winid'])
58+
endif
59+
call s:_notify(a:id, {}, 'close')
60+
call remove(s:_popups, a:id)
61+
endfunction
62+
63+
function! s:hide(id) abort
64+
let data = s:_popups[a:id]
65+
if s:_has_nvim
66+
call nvim_win_close(data['winid'], 1)
67+
let data['winid'] = 0
68+
else
69+
call popup_hide(data['winid'])
70+
endif
71+
call s:_notify(a:id, {}, 'hide')
72+
endfunction
73+
74+
function! s:show(id) abort
75+
let data = s:_popups[a:id]
76+
if s:_has_nvim
77+
let data['winid'] = s:_nvim_open_win(a:id, data)
78+
else
79+
call popup_show(data['winid'])
6180
endif
81+
call s:_notify(a:id, {}, 'show')
6282
endfunction
6383

6484
function! s:_nvim_open_win(id, data) abort
@@ -71,7 +91,7 @@ function! s:_nvim_open_win(id, data) abort
7191
\ 'row': a:data['sy'],
7292
\ 'focusable': 0,
7393
\ }
74-
return nvim_open_win(a:data['bufnr'], 1, opt)
94+
return nvim_open_win(a:data['bufnr'], 0, opt)
7595
endfunction
7696

7797
function! s:_set(data, opt) abort

0 commit comments

Comments
 (0)