Automatically detect and exit copy mode when sending commands #70
This commit is contained in:
parent
140017a04d
commit
b9c630f882
@ -182,13 +182,20 @@ endfunction
|
|||||||
|
|
||||||
function! s:SendClearSequence()
|
function! s:SendClearSequence()
|
||||||
if !s:ValidRunnerPaneSet() | return | endif
|
if !s:ValidRunnerPaneSet() | return | endif
|
||||||
|
call s:SendTmuxCopyModeExit()
|
||||||
call s:_SendKeys(g:VtrClearSequence)
|
call s:_SendKeys(g:VtrClearSequence)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:SendQuitSequence()
|
||||||
|
if !s:ValidRunnerPaneSet() | return | endif
|
||||||
|
call s:_SendKeys("q")
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:GitCdUp()
|
function! s:GitCdUp()
|
||||||
let git_repo_check = "git rev-parse --git-dir > /dev/null 2>&1"
|
let git_repo_check = "git rev-parse --git-dir > /dev/null 2>&1"
|
||||||
let cdup_cmd = "cd './'$(git rev-parse --show-cdup)"
|
let cdup_cmd = "cd './'$(git rev-parse --show-cdup)"
|
||||||
let cmd = shellescape(join([git_repo_check, '&&', cdup_cmd]))
|
let cmd = shellescape(join([git_repo_check, '&&', cdup_cmd]))
|
||||||
|
call s:SendTmuxCopyModeExit()
|
||||||
call s:SendKeys(cmd)
|
call s:SendKeys(cmd)
|
||||||
call s:SendClearSequence()
|
call s:SendClearSequence()
|
||||||
endfunction
|
endfunction
|
||||||
@ -341,6 +348,15 @@ function! s:FlushCommand()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:SendTmuxCopyModeExit()
|
||||||
|
let l:session = s:TmuxInfo('session_name')
|
||||||
|
let l:win = s:TmuxInfo('window_index')
|
||||||
|
let target_cmd = join([l:session.':'.l:win.".".s:runner_pane])
|
||||||
|
if s:SendTmuxCommand("display-message -p -F '#{pane_in_mode}' -t " . l:target_cmd)
|
||||||
|
call s:SendQuitSequence()
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:SendCommandToRunner(ensure_pane, ...)
|
function! s:SendCommandToRunner(ensure_pane, ...)
|
||||||
if a:ensure_pane | call s:EnsureRunnerPane() | endif
|
if a:ensure_pane | call s:EnsureRunnerPane() | endif
|
||||||
if !s:ValidRunnerPaneSet() | return | endif
|
if !s:ValidRunnerPaneSet() | return | endif
|
||||||
@ -356,6 +372,7 @@ function! s:SendCommandToRunner(ensure_pane, ...)
|
|||||||
call s:EchoError("command string required")
|
call s:EchoError("command string required")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
call s:SendTmuxCopyModeExit()
|
||||||
if g:VtrClearBeforeSend
|
if g:VtrClearBeforeSend
|
||||||
call s:SendClearSequence()
|
call s:SendClearSequence()
|
||||||
endif
|
endif
|
||||||
@ -379,6 +396,7 @@ endfunction
|
|||||||
function! s:SendLinesToRunner(ensure_pane) range
|
function! s:SendLinesToRunner(ensure_pane) range
|
||||||
if a:ensure_pane | call s:EnsureRunnerPane() | endif
|
if a:ensure_pane | call s:EnsureRunnerPane() | endif
|
||||||
if !s:ValidRunnerPaneSet() | return | endif
|
if !s:ValidRunnerPaneSet() | return | endif
|
||||||
|
call s:SendTmuxCopyModeExit()
|
||||||
call s:SendTextToRunner(getline(a:firstline, a:lastline))
|
call s:SendTextToRunner(getline(a:firstline, a:lastline))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -407,6 +425,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:SendCtrlD()
|
function! s:SendCtrlD()
|
||||||
if !s:ValidRunnerPaneSet() | return | endif
|
if !s:ValidRunnerPaneSet() | return | endif
|
||||||
|
call s:SendTmuxCopyModeExit()
|
||||||
call s:SendKeys('')
|
call s:SendKeys('')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user