Allow repeated runs of the previous command

This commit is contained in:
Chris Toomey 2012-11-23 22:24:09 -05:00
parent ddb36560a0
commit 4bd17efd06

View File

@ -1,6 +1,10 @@
" TODO: guards on methods that expect pane, window to exist " TODO: guards on methods that expect pane, window to exist
" TODO: full command and option docs " TODO: full command and option docs
" TODO: maximize command " TODO: maximize command
" TODO: unlet s:pane on anything the detaches, kills, etc
" TODO: create pane if not already available when running sendcommand
" TODO: reattach pane rather than create if s:detach_window is set
" TODO: normalize naming, 'runner' not 'pane'
function! s:InitVariable(var, value) function! s:InitVariable(var, value)
if !exists(a:var) if !exists(a:var)
@ -36,7 +40,6 @@ function! s:OpenRunnerPane()
endif endif
if g:VtrInitialCommand != "" if g:VtrInitialCommand != ""
call s:SendKeys(g:VtrInitialCommand) call s:SendKeys(g:VtrInitialCommand)
call s:SendClearSequence()
endif endif
endfunction endfunction
@ -195,12 +198,20 @@ function! s:HighlightedPrompt(prompt)
return input return input
endfunction endfunction
function! s:FlushCommand()
if exists("s:user_command")
unlet s:user_command
endif
endfunction
function! s:SendCommandToRunner() function! s:SendCommandToRunner()
let user_command = s:HighlightedPrompt(g:VtrPrompt) if !exists("s:user_command")
let s:user_command = s:HighlightedPrompt(g:VtrPrompt)
endif
if g:VtrClearBeforeSend if g:VtrClearBeforeSend
call s:SendClearSequence() call s:SendClearSequence()
endif endif
call s:SendKeys(user_command) call s:SendKeys(s:user_command)
endfunction endfunction
function! s:DefineCommands() function! s:DefineCommands()
@ -213,6 +224,7 @@ function! s:DefineCommands()
command! VTRDetachPane :call s:DetachRunnerPane() command! VTRDetachPane :call s:DetachRunnerPane()
command! VTRReattachPane :call s:ReattachPane() command! VTRReattachPane :call s:ReattachPane()
command! VTRClearRunner :call s:SendClearSequence() command! VTRClearRunner :call s:SendClearSequence()
command! VTRFlushCommand :call s:FlushCommand()
endfunction endfunction
function! s:DefineKeymaps() function! s:DefineKeymaps()
@ -226,6 +238,7 @@ function! s:DefineKeymaps()
nmap ,dr :VTRDetachPane<cr> nmap ,dr :VTRDetachPane<cr>
nmap ,ar :VTRReattachPane<cr> nmap ,ar :VTRReattachPane<cr>
nmap ,cr :VTRClearRunner<cr> nmap ,cr :VTRClearRunner<cr>
nmap ,fc :VTRFlushCommand<cr>
endif endif
endfunction endfunction