Skip to content

Commit

Permalink
Merge pull request spolu#26 from afriggeri/rotation
Browse files Browse the repository at this point in the history
Added pane rotation
  • Loading branch information
Stanislas Polu committed Aug 31, 2012
2 parents 43895f9 + 9a0ec2d commit d41bd96
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doc/dwm.txt
Expand Up @@ -83,6 +83,8 @@ mapped:
<c-m> |:DWM_Full|
<c-j> Move cursor clockwise to the next window
<c-k> Move cursor counter-clockwise to the previous window
<c-,> Rotate windows counter-clockwise
<c-.> Rotate windows clockwise
<c-h> Grow Master Pane Width
<c-l> Shrink Master Pane Width

Expand Down
30 changes: 24 additions & 6 deletions plugin/dwm.vim
Expand Up @@ -43,10 +43,15 @@ endif
" +--------+--------+

" Move the current master pane to the stack
function! DWM_Stack()
1wincmd h
" Move to the top of the stack
wincmd K
function! DWM_Stack(clockwise)
1wincmd w
if a:clockwise
" Move to the top of the stack
wincmd K
else
" Move to the bottom of the stack
wincmd J
endif
" At this point, the layout *should* be the following with the previous master
" at the top.
" +-----------------+
Expand All @@ -63,7 +68,7 @@ endfunction
" Add a new buffer
function! DWM_New()
" Move current master pane to the stack
call DWM_Stack()
call DWM_Stack(1)
" Create a vertical split
vert topleft new
call DWM_ResizeMasterPaneWidth()
Expand All @@ -73,7 +78,7 @@ endfunction
" added to the top of the stack)
function! DWM_Focus()
let l:curwin = winnr()
call DWM_Stack()
call DWM_Stack(1)
exec l:curwin . "wincmd w"
wincmd H
call DWM_ResizeMasterPaneWidth()
Expand Down Expand Up @@ -118,13 +123,26 @@ function! DWM_ShrinkMaster()
endif
endfunction

function! DWM_Rotate(clockwise)
call DWM_Stack(a:clockwise)
if a:clockwise
wincmd W
else
wincmd w
endif
wincmd H
call DWM_ResizeMasterPaneWidth()
endfunction

if !exists('g:dwm_map_keys')
let g:dwm_map_keys = 1
endif

if g:dwm_map_keys
map <C-J> <C-W>w
map <C-K> <C-W>W
map <C-,> :call DWM_Rotate(0)<CR>
map <C-.> :call DWM_Rotate(1)<CR>
map <C-N> :call DWM_New()<CR>
map <C-C> :call DWM_Close()<CR>
Expand Down

0 comments on commit d41bd96

Please sign in to comment.