mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-03 04:28:36 +00:00
parent
e6d33f77da
commit
d631c76e8d
@ -648,6 +648,7 @@ function! s:split(dict)
|
|||||||
\ 'left': ['vertical topleft', 'vertical resize', &columns],
|
\ 'left': ['vertical topleft', 'vertical resize', &columns],
|
||||||
\ 'right': ['vertical botright', 'vertical resize', &columns] }
|
\ 'right': ['vertical botright', 'vertical resize', &columns] }
|
||||||
let ppos = s:getpos()
|
let ppos = s:getpos()
|
||||||
|
let is_popup = 0
|
||||||
try
|
try
|
||||||
if s:present(a:dict, 'window')
|
if s:present(a:dict, 'window')
|
||||||
if type(a:dict.window) == type({})
|
if type(a:dict.window) == type({})
|
||||||
@ -655,6 +656,7 @@ function! s:split(dict)
|
|||||||
throw 'Vim 8.2.191 or later is required for pop-up window'
|
throw 'Vim 8.2.191 or later is required for pop-up window'
|
||||||
end
|
end
|
||||||
call s:popup(a:dict.window)
|
call s:popup(a:dict.window)
|
||||||
|
let is_popup = 1
|
||||||
else
|
else
|
||||||
execute 'keepalt' a:dict.window
|
execute 'keepalt' a:dict.window
|
||||||
endif
|
endif
|
||||||
@ -672,11 +674,11 @@ function! s:split(dict)
|
|||||||
endif
|
endif
|
||||||
execute cmd sz.'new'
|
execute cmd sz.'new'
|
||||||
execute resz sz
|
execute resz sz
|
||||||
return [ppos, {}]
|
return [ppos, {}, is_popup]
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
return [ppos, { '&l:wfw': &l:wfw, '&l:wfh': &l:wfh }]
|
return [ppos, { '&l:wfw': &l:wfw, '&l:wfh': &l:wfh }, is_popup]
|
||||||
finally
|
finally
|
||||||
setlocal winfixwidth winfixheight
|
setlocal winfixwidth winfixheight
|
||||||
endtry
|
endtry
|
||||||
@ -685,7 +687,7 @@ endfunction
|
|||||||
function! s:execute_term(dict, command, temps) abort
|
function! s:execute_term(dict, command, temps) abort
|
||||||
let winrest = winrestcmd()
|
let winrest = winrestcmd()
|
||||||
let pbuf = bufnr('')
|
let pbuf = bufnr('')
|
||||||
let [ppos, winopts] = s:split(a:dict)
|
let [ppos, winopts, is_popup] = s:split(a:dict)
|
||||||
call s:use_sh()
|
call s:use_sh()
|
||||||
let b:fzf = a:dict
|
let b:fzf = a:dict
|
||||||
let fzf = { 'buf': bufnr(''), 'pbuf': pbuf, 'ppos': ppos, 'dict': a:dict, 'temps': a:temps,
|
let fzf = { 'buf': bufnr(''), 'pbuf': pbuf, 'ppos': ppos, 'dict': a:dict, 'temps': a:temps,
|
||||||
@ -752,8 +754,17 @@ function! s:execute_term(dict, command, temps) abort
|
|||||||
if !len(&bufhidden)
|
if !len(&bufhidden)
|
||||||
setlocal bufhidden=hide
|
setlocal bufhidden=hide
|
||||||
endif
|
endif
|
||||||
let fzf.buf = term_start([&shell, &shellcmdflag, command], {'curwin': 1, 'exit_cb': function(fzf.on_exit)})
|
let term_opts = {'exit_cb': function(fzf.on_exit)}
|
||||||
if !has('patch-8.0.1261') && !has('nvim') && !s:is_win
|
if is_popup
|
||||||
|
let term_opts.hidden = 1
|
||||||
|
else
|
||||||
|
let term_opts.curwin = 1
|
||||||
|
endif
|
||||||
|
let fzf.buf = term_start([&shell, &shellcmdflag, command], term_opts)
|
||||||
|
if is_popup && exists('#TerminalWinOpen')
|
||||||
|
doautocmd <nomodeline> TerminalWinOpen
|
||||||
|
endif
|
||||||
|
if !has('patch-8.0.1261') && !s:is_win
|
||||||
call term_wait(fzf.buf, 20)
|
call term_wait(fzf.buf, 20)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -824,23 +835,22 @@ if has('nvim')
|
|||||||
else
|
else
|
||||||
function! s:create_popup(hl, opts) abort
|
function! s:create_popup(hl, opts) abort
|
||||||
let is_frame = has_key(a:opts, 'border')
|
let is_frame = has_key(a:opts, 'border')
|
||||||
let buf = is_frame ? '' : term_start(&shell, #{hidden: 1, term_finish: 'close'})
|
let s:popup_create = {buf -> popup_create(buf, #{
|
||||||
let id = popup_create(buf, #{
|
|
||||||
\ line: a:opts.row,
|
\ line: a:opts.row,
|
||||||
\ col: a:opts.col,
|
\ col: a:opts.col,
|
||||||
\ minwidth: a:opts.width,
|
\ minwidth: a:opts.width,
|
||||||
\ minheight: a:opts.height,
|
\ minheight: a:opts.height,
|
||||||
\ zindex: 50 - is_frame,
|
\ zindex: 50 - is_frame,
|
||||||
\ })
|
\ })}
|
||||||
|
|
||||||
if is_frame
|
if is_frame
|
||||||
|
let id = s:popup_create('')
|
||||||
call setwinvar(id, '&wincolor', a:hl)
|
call setwinvar(id, '&wincolor', a:hl)
|
||||||
call setbufline(winbufnr(id), 1, a:opts.border)
|
call setbufline(winbufnr(id), 1, a:opts.border)
|
||||||
execute 'autocmd BufWipeout * ++once call popup_close('..id..')'
|
execute 'autocmd BufWipeout * ++once call popup_close('..id..')'
|
||||||
else
|
|
||||||
execute 'autocmd BufWipeout * ++once call term_sendkeys('..buf..', "exit\<CR>")'
|
|
||||||
endif
|
|
||||||
return winbufnr(id)
|
return winbufnr(id)
|
||||||
|
else
|
||||||
|
autocmd TerminalOpen * ++once call s:popup_create(str2nr(expand('<abuf>')))
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user