Create runner pane in temp window

In order to avoid rapid flickering of runner window as it is created
and initialized, create and initialize it in a temporary background
window then bring it in.
This commit is contained in:
Chris Toomey 2012-11-29 19:21:46 -05:00
parent b8a531b9b8
commit 60bb1622d4
2 changed files with 41 additions and 5 deletions

View File

@ -33,6 +33,7 @@ CONTENTS *vtr-contents*
3.9 ................................ |VtrClearOnReattach| 3.9 ................................ |VtrClearOnReattach|
3.10 ............................... |VtrDetachedName| 3.10 ............................... |VtrDetachedName|
3.11 ............................... |VtrClearSequence| 3.11 ............................... |VtrClearSequence|
3.12 ............................... |VtrInitTimeout|
============================================================================== ==============================================================================
ABOUT (1) *VTR-About* ABOUT (1) *VTR-About*
@ -344,5 +345,21 @@ insert mode. See the help file, ':help i_Ctrl-v', for more detail.
Default: " " Default: " "
------------------------------------------------------------------------------
*VtrInitTimeout*
3.12 g:VtrInitTimeout~
Timeout in milliseconds to use when initializing the runner in temporary
window. This is intended to provide the runner sufficient time to run the
initializing commands and then be attached to the Vim window.
This timeout is only relevant if VTR is configured to cd to the git root, or
run an initial command. These can be set through their respective
configuration options, |g:VtrGitCdUpOnOpen| and |g:VtrInitialCommand|.
let g:VtrInitTimeout = 100
Default: 500
============================================================================== ==============================================================================
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:

View File

@ -12,16 +12,29 @@ endfunction
function! s:OpenRunnerPane() function! s:OpenRunnerPane()
let s:vim_pane = s:ActiveTmuxPaneNumber() let s:vim_pane = s:ActiveTmuxPaneNumber()
let cmd = join(["split-window -p", s:vtr_percentage, "-".s:vtr_orientation]) let remote_cmd = join(["new-window", "-d", "-n", g:VtrDetachedName])
call s:SendTmuxCommand(cmd) call s:SendTmuxCommand(remote_cmd)
let s:runner_pane = s:ActiveTmuxPaneNumber() let [s:detached_window, s:runner_pane] = [s:LastWindowNumber(), 0]
call s:FocusVimPane()
if g:VtrGitCdUpOnOpen if g:VtrGitCdUpOnOpen
call s:GitCdUp() call s:GitCdUp()
endif endif
if g:VtrInitialCommand != "" if g:VtrInitialCommand != ""
call s:SendKeys(g:VtrInitialCommand) call s:SendKeys(g:VtrInitialCommand)
endif endif
if g:VtrInitialCommand || g:VtrGitCdUpOnOpen
call s:TimeoutWithProgess()
endif
call s:ReattachPane()
endfunction
function! s:TimeoutWithProgess()
let timeout_portion = g:VtrInitTimeout / 3
echohl String | echon 'Preparing runner.'
for time in [1,2,3]
execute join(['sleep', timeout_portion.'m'])
echon '.'
endfor
echohl None
endfunction endfunction
function! s:DetachRunnerPane() function! s:DetachRunnerPane()
@ -147,7 +160,12 @@ function! s:SendTmuxCommand(command)
endfunction endfunction
function! s:TargetedTmuxCommand(command, target_pane) function! s:TargetedTmuxCommand(command, target_pane)
return a:command . " -t " . a:target_pane if exists("s:detached_window")
let target = ':'.s:detached_window.'.'.a:target_pane
else
let target = a:target_pane
endif
return join([a:command, " -t ", target])
endfunction endfunction
function! s:_SendKeys(keys) function! s:_SendKeys(keys)
@ -325,6 +343,7 @@ function! s:InitializeVariables()
call s:InitVariable("g:VtrClearOnReorient", 1) call s:InitVariable("g:VtrClearOnReorient", 1)
call s:InitVariable("g:VtrClearOnReattach", 1) call s:InitVariable("g:VtrClearOnReattach", 1)
call s:InitVariable("g:VtrDetachedName", "VTR_Pane") call s:InitVariable("g:VtrDetachedName", "VTR_Pane")
call s:InitVariable("g:VtrInitTimeout", 450)
call s:InitVariable("g:VtrClearSequence", " ") call s:InitVariable("g:VtrClearSequence", " ")
let s:vtr_percentage = g:VtrPercentage let s:vtr_percentage = g:VtrPercentage
let s:vtr_orientation = g:VtrOrientation let s:vtr_orientation = g:VtrOrientation