Update KillRunner to also kill detached window

This commit is contained in:
Chris Toomey 2012-11-24 11:55:27 -05:00
parent e496ccc593
commit c5df405e43

View File

@ -5,7 +5,6 @@
" TODO: reattach pane rather than create if s:detached_window is set " TODO: reattach pane rather than create if s:detached_window is set
" TODO: normalize naming, 'runner' not 'pane' " TODO: normalize naming, 'runner' not 'pane'
" TODO: update the clear sequence to use '^U^L' " TODO: update the clear sequence to use '^U^L'
" TODO: update KillRunnerPane to kill detached as well as local
" TODO: investigate occasional '[lost Server]' error from tmux " TODO: investigate occasional '[lost Server]' error from tmux
function! s:InitVariable(var, value) function! s:InitVariable(var, value)
@ -70,15 +69,37 @@ function! s:RequireDetachedPane()
return 1 return 1
endfunction endfunction
function! s:KillRunnerPane() function! s:RequireLocalPaneOrDetached()
if !s:RequireRunnerPane() if !exists('s:detached_window') && !exists('s:runner_pane')
return echohl ErrorMsg | echom "VTR: No pane, local or detached." | echohl None
return 0
endif endif
return 1
endfunction
function! s:KillLocalRunner()
let targeted_cmd = s:TargetedTmuxCommand("kill-pane", s:runner_pane) let targeted_cmd = s:TargetedTmuxCommand("kill-pane", s:runner_pane)
call s:SendTmuxCommand(targeted_cmd) call s:SendTmuxCommand(targeted_cmd)
unlet s:runner_pane unlet s:runner_pane
endfunction endfunction
function! s:KillDetachedWindow()
let cmd = join(["kill-window", '-t', s:detached_window])
call s:SendTmuxCommand(cmd)
unlet s:detached_window
endfunction
function! s:KillRunnerPane()
if !s:RequireLocalPaneOrDetached()
return
endif
if exists("s:runner_pane")
call s:KillLocalRunner()
else
call s:KillDetachedWindow()
endif
endfunction
function! s:ActiveTmuxPaneNumber() function! s:ActiveTmuxPaneNumber()
for pane_title in s:TmuxPanes() for pane_title in s:TmuxPanes()
if pane_title =~ '\(active\)' if pane_title =~ '\(active\)'
@ -188,15 +209,16 @@ function! s:LastWindowNumber()
return split(s:SendTmuxCommand("list-windows"), '\n')[-1][0] return split(s:SendTmuxCommand("list-windows"), '\n')[-1][0]
endfunction endfunction
function! s:ToggleOrientationVariable()
let g:VtrOrientation = (g:VtrOrientation == "v" ? "h" : "v")
endfunction
function! s:BreakRunnerPaneToTempWindow() function! s:BreakRunnerPaneToTempWindow()
let targeted_cmd = s:TargetedTmuxCommand("break-pane", s:runner_pane) let targeted_cmd = s:TargetedTmuxCommand("break-pane", s:runner_pane)
let full_command = join([targeted_cmd, "-d"]) let full_command = join([targeted_cmd, "-d"])
call s:SendTmuxCommand(full_command) call s:SendTmuxCommand(full_command)
let s:detached_window = s:LastWindowNumber() let s:detached_window = s:LastWindowNumber()
endfunction unlet s:runner_pane
function! s:ToggleOrientationVariable()
let g:VtrOrientation = (g:VtrOrientation == "v" ? "h" : "v")
endfunction endfunction
function! s:_ReattachPane() function! s:_ReattachPane()
@ -204,6 +226,7 @@ function! s:_ReattachPane()
\ "-p", g:VtrPercentage, "-".g:VtrOrientation]) \ "-p", g:VtrPercentage, "-".g:VtrOrientation])
call s:SendTmuxCommand(join_cmd) call s:SendTmuxCommand(join_cmd)
unlet s:detached_window unlet s:detached_window
let s:runner_pane = s:ActiveTmuxPaneNumber()
endfunction endfunction
function! s:ReattachPane() function! s:ReattachPane()