Skip to content

Commit

Permalink
terminal:fix <c-v>
Browse files Browse the repository at this point in the history
Signed-off-by: tracyone <tracyone@live.cn>
  • Loading branch information
tracyone committed Jan 30, 2022
1 parent 9f6c0bf commit 664e5d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
7 changes: 0 additions & 7 deletions autoload/te/env.vim
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ function! te#env#check_requirement() abort
endif
endfunction

function! te#env#get_termwinkey() abort
if has('patch-8.0.1743')
return &termwinkey
else
return &termkey
endif
endfunction

function! te#env#SupportFloatingWindows() abort
if te#env#IsNvim() == 0
Expand Down
2 changes: 1 addition & 1 deletion autoload/te/feat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function! te#feat#gen_feature_vim(reset) abort
endif
let l:temp2=te#feat#get_vim_version()
if v:shell_error != 0
let g:vinux_version='vinux V1.5.0'.' @'.l:temp2[0].'.'.l:temp2[1]
let g:vinux_version='vinux V1.5.1'.' @'.l:temp2[0].'.'.l:temp2[1]
else
let l:temp = matchstr(l:vinux_version[-1],'.*\(-\d\+-\w\+\)\@=')
if l:temp !=# ''
Expand Down
21 changes: 19 additions & 2 deletions autoload/te/terminal.vim
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function! te#terminal#repl() abort
call feedkeys("\<C-\>\<C-n>G\<c-w>h")
else
:call te#terminal#shell_pop({'opener':0x8, 'cmd':l:cmd})
execute 'call feedkeys("\'.te#env#get_termwinkey().'h")'
execute 'call feedkeys("\'.te#terminal#get_termwinkey().'h")'
endif
endfunction

Expand Down Expand Up @@ -390,6 +390,22 @@ function! te#terminal#hide_popup() abort
call s:hide_win(l:win_id, s:last_close_bufnr)
endfunction

function! te#terminal#get_termwinkey() abort
let l:result=""
if win_gettype() == 'popup'
return "<c-w>"
endif
if has('patch-8.0.1743')
let l:result=&termwinkey
else
let l:result=&termkey
endif
if empty(l:result)
let l:result="<c-w>"
endif
return l:result
endfunction

function! s:hide_win(winid, buf)
call te#terminal#set_line(a:buf, line('$'))
try
Expand Down Expand Up @@ -560,6 +576,7 @@ function! te#terminal#shell_pop(option) abort
return
elseif te#env#SupportFloatingWindows()
let l:term_list = te#terminal#get_buf_list()
let l:term_key = &termwinkey
if !exists('l:buf')
let l:buf = term_start(l:shell, #{hidden: 1, exit_cb:function('<SID>JobExit'),
\ term_rows:l:height, term_cols:l:width, env:l:env_dict})
Expand Down Expand Up @@ -597,7 +614,7 @@ function! te#terminal#shell_pop(option) abort
\ 'drag': 1,
\ 'close': 'button',
\ })
"call setwinvar(l:win_id, '&wincolor', 'Pmenu')
call setwinvar(l:win_id, '&termwinkey', l:term_key)
else
execute ':buf '.l:buf
endif
Expand Down
10 changes: 5 additions & 5 deletions rc/mappings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ if te#env#IsNvim() != 0
elseif te#env#SupportTerminal()
"terminal-emulator setting
"execute 'tnoremap <Esc> <C-\><C-n>' "effect <a-> key?
call te#meta#map('tmap <silent> ','h',te#env#get_termwinkey().'h')
call te#meta#map('tmap <silent> ','j',te#env#get_termwinkey().'j')
call te#meta#map('tmap <silent> ','k',te#env#get_termwinkey().'k')
call te#meta#map('tmap <silent> ','l',te#env#get_termwinkey().'l')
silent! execute 'tnoremap <c-v> '.te#env#get_termwinkey().'"*'
call te#meta#map('tmap <silent> ','h',te#terminal#get_termwinkey().'h')
call te#meta#map('tmap <silent> ','j',te#terminal#get_termwinkey().'j')
call te#meta#map('tmap <silent> ','k',te#terminal#get_termwinkey().'k')
call te#meta#map('tmap <silent> ','l',te#terminal#get_termwinkey().'l')
silent! execute 'tnoremap <c-v> '.te#terminal#get_termwinkey().'"*'
call te#meta#map('tnoremap <silent> ','b','<C-left>')
call te#meta#map('tnoremap <silent> ','f','<C-right>')
endif
Expand Down

0 comments on commit 664e5d7

Please sign in to comment.