Add initial ResizeRunner command

This commit is contained in:
Chris Toomey 2012-11-23 19:30:56 -05:00
parent a601e99ffe
commit 369fba87b5
2 changed files with 38 additions and 10 deletions

View File

@ -14,6 +14,7 @@ This plugin exposes a command to open a small command runner window
## Inspiration ## Inspiration
- Tslime.vim This plugin is heavily inspired by the functionality in the Vimux plugin. This
- Vimux plugin aims to implement a similar feature set while not requiring Vim with
- Turbux ruby requirement. In addition a few new commands not found in Vimux have been
added to provide additional control over the tmux runner pane.

View File

@ -62,6 +62,33 @@ function! s:FocusTmuxPane(pane_number)
call s:SendTmuxCommand(targeted_cmd) call s:SendTmuxCommand(targeted_cmd)
endfunction endfunction
function! s:RunnerPaneDimensions()
let panes = s:TmuxPanes()
for pane in panes
if pane =~ '^'.s:runner_pane
let pane_info = matchlist(pane, s:runner_pane.': [\(\d\+\)x\(\d\+\)\]')
return {'width': pane_info[1], 'height': pane_info[2]}
endif
endfor
endfunction
function! s:ResizeRunnerPane()
let new_percent = s:HighlightedPrompt("Runner screen percentage: ")
let pane_dimensions = s:RunnerPaneDimensions()
let inputs = [pane_dimensions['height'], '*', new_percent, '/', g:VtrPercentage]
let new_lines = eval(join(inputs)) " Not sure why I need to use eval...?
let lines_delta = abs(pane_dimensions['height'] - new_lines)
let move_down = (eval(join([new_percent, '<', g:VtrPercentage])))
let direction = move_down ? '-D' : '-U'
let targeted_cmd = s:TargetedTmuxCommand("resize-pane", s:runner_pane)
let full_command = join([targeted_cmd, direction, lines_delta])
let g:VtrPercentage = new_percent
call s:SendTmuxCommand(full_command)
endfunction
command! VTRResizePane :call s:ResizeRunnerPane()
nmap ,rr :VTRResizePane<cr>
function! s:FocusRunnerPane() function! s:FocusRunnerPane()
call s:FocusTmuxPane(s:runner_pane) call s:FocusTmuxPane(s:runner_pane)
endfunction endfunction
@ -114,23 +141,23 @@ function! s:ToggleOrientationVariable()
let g:VtrOrientation = (g:VtrOrientation == "v" ? "h" : "v") let g:VtrOrientation = (g:VtrOrientation == "v" ? "h" : "v")
endfunction endfunction
function! s:RotateRunner() function! s:ReorientRunner()
let temp_window = s:BreakRunnerPaneToTempWindow() let temp_window = s:BreakRunnerPaneToTempWindow()
call s:ToggleOrientationVariable() call s:ToggleOrientationVariable()
let join_cmd = join(["join-pane", "-s", ":".temp_window.".0", let join_cmd = join(["join-pane", "-s", ":".temp_window.".0",
\ "-p", g:VtrPercentage, "-".g:VtrOrientation]) \ "-p", g:VtrPercentage, "-".g:VtrOrientation])
echom join_cmd
call s:SendTmuxCommand(join_cmd) call s:SendTmuxCommand(join_cmd)
call s:SendClearSequence()
call s:FocusVimPane() call s:FocusVimPane()
endfunction endfunction
function! s:HighlightedPrompt() function! s:HighlightedPrompt(prompt)
echohl String | let input = shellescape(input(g:VtrPrompt)) | echohl None echohl String | let input = shellescape(input(a:prompt)) | echohl None
return input return input
endfunction endfunction
function! s:SendCommandToRunner() function! s:SendCommandToRunner()
let user_command = s:HighlightedPrompt() let user_command = s:HighlightedPrompt(g:VtrPrompt)
if g:VtrClearBeforeSend if g:VtrClearBeforeSend
call s:SendClearSequence() call s:SendClearSequence()
endif endif
@ -141,8 +168,8 @@ command! VTROpenRunner :call s:OpenRunnerPane()
command! VTRKillRunner :call s:KillRunnerPane() command! VTRKillRunner :call s:KillRunnerPane()
command! VTRFocusRunnerPane :call s:FocusRunnerPane() command! VTRFocusRunnerPane :call s:FocusRunnerPane()
command! VTRSendCommandToRunner :call s:SendCommandToRunner() command! VTRSendCommandToRunner :call s:SendCommandToRunner()
command! VTRRotateRunner :call s:RotateRunner() command! VTRReorientRunner :call s:ReorientRunner()
nmap ,rr :VTRRotateRunner<cr> nmap ,ror :VTRReorientRunner<cr>
nmap ,sc :VTRSendCommandToRunner<cr> nmap ,sc :VTRSendCommandToRunner<cr>
nmap ,or :VTROpenRunner<cr> nmap ,or :VTROpenRunner<cr>
nmap ,kr :VTRKillRunner<cr> nmap ,kr :VTRKillRunner<cr>