Rename a few functions.
This commit is contained in:
parent
6ae682e462
commit
a2bc33b076
105
plugin/gundo.vim
105
plugin/gundo.vim
@ -106,21 +106,7 @@ function! s:GundoMapPreview()"{{{
|
|||||||
cabbrev <script> <silent> <buffer> quit call <sid>GundoClose()
|
cabbrev <script> <silent> <buffer> quit call <sid>GundoClose()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoMarkPreviewBuffer()"{{{
|
function! s:GundoSettingsGraph()"{{{
|
||||||
setlocal buftype=nofile
|
|
||||||
setlocal bufhidden=hide
|
|
||||||
setlocal noswapfile
|
|
||||||
setlocal nobuflisted
|
|
||||||
setlocal nomodifiable
|
|
||||||
setlocal filetype=diff
|
|
||||||
setlocal nonumber
|
|
||||||
setlocal norelativenumber
|
|
||||||
setlocal nowrap
|
|
||||||
setlocal foldlevel=20
|
|
||||||
" TODO: Set foldmethod?
|
|
||||||
endfunction"}}}
|
|
||||||
|
|
||||||
function! s:GundoMarkBuffer()"{{{
|
|
||||||
setlocal buftype=nofile
|
setlocal buftype=nofile
|
||||||
setlocal bufhidden=hide
|
setlocal bufhidden=hide
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
@ -131,10 +117,25 @@ function! s:GundoMarkBuffer()"{{{
|
|||||||
setlocal nonumber
|
setlocal nonumber
|
||||||
setlocal norelativenumber
|
setlocal norelativenumber
|
||||||
setlocal nowrap
|
setlocal nowrap
|
||||||
call s:GundoSyntax()
|
call s:GundoSyntaxGraph()
|
||||||
|
call s:GundoMapGraph()
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoSyntax()"{{{
|
function! s:GundoSettingsPreview()"{{{
|
||||||
|
setlocal buftype=nofile
|
||||||
|
setlocal bufhidden=hide
|
||||||
|
setlocal noswapfile
|
||||||
|
setlocal nobuflisted
|
||||||
|
setlocal nomodifiable
|
||||||
|
setlocal filetype=diff
|
||||||
|
setlocal nonumber
|
||||||
|
setlocal norelativenumber
|
||||||
|
setlocal nowrap
|
||||||
|
setlocal foldlevel=20
|
||||||
|
call s:GundoMapPreview()
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! s:GundoSyntaxGraph()"{{{
|
||||||
let b:current_syntax = 'gundo'
|
let b:current_syntax = 'gundo'
|
||||||
|
|
||||||
syn match GundoCurrentLocation '@'
|
syn match GundoCurrentLocation '@'
|
||||||
@ -162,14 +163,13 @@ function! s:GundoResizeBuffers(backto)"{{{
|
|||||||
exe a:backto . "wincmd w"
|
exe a:backto . "wincmd w"
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoOpenBuffer()"{{{
|
function! s:GundoOpenGraph()"{{{
|
||||||
let existing_gundo_buffer = bufnr("__Gundo__")
|
let existing_gundo_buffer = bufnr("__Gundo__")
|
||||||
|
|
||||||
if existing_gundo_buffer == -1
|
if existing_gundo_buffer == -1
|
||||||
exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w"
|
exe bufwinnr(bufnr('__Gundo_Preview__')) . "wincmd w"
|
||||||
exe "new __Gundo__"
|
exe "new __Gundo__"
|
||||||
call s:GundoResizeBuffers(winnr())
|
call s:GundoResizeBuffers(winnr())
|
||||||
call s:GundoMapGraph()
|
|
||||||
else
|
else
|
||||||
let existing_gundo_window = bufwinnr(existing_gundo_buffer)
|
let existing_gundo_window = bufwinnr(existing_gundo_buffer)
|
||||||
|
|
||||||
@ -185,6 +185,26 @@ function! s:GundoOpenBuffer()"{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! s:GundoOpenPreview()"{{{
|
||||||
|
let existing_preview_buffer = bufnr("__Gundo_Preview__")
|
||||||
|
|
||||||
|
if existing_preview_buffer == -1
|
||||||
|
exe "vnew __Gundo_Preview__"
|
||||||
|
wincmd H
|
||||||
|
else
|
||||||
|
let existing_preview_window = bufwinnr(existing_preview_buffer)
|
||||||
|
|
||||||
|
if existing_preview_window != -1
|
||||||
|
if winnr() != existing_preview_window
|
||||||
|
exe existing_preview_window . "wincmd w"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
exe "vsplit +buffer" . existing_preview_buffer
|
||||||
|
wincmd H
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoClose()"{{{
|
function! s:GundoClose()"{{{
|
||||||
if bufwinnr(bufnr('__Gundo__')) != -1
|
if bufwinnr(bufnr('__Gundo__')) != -1
|
||||||
exe bufwinnr(bufnr('__Gundo__')) . "wincmd w"
|
exe bufwinnr(bufnr('__Gundo__')) . "wincmd w"
|
||||||
@ -228,27 +248,6 @@ function! s:GundoToggle()"{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoOpenPreview()"{{{
|
|
||||||
let existing_preview_buffer = bufnr("__Gundo_Preview__")
|
|
||||||
|
|
||||||
if existing_preview_buffer == -1
|
|
||||||
exe "vnew __Gundo_Preview__"
|
|
||||||
wincmd H
|
|
||||||
call s:GundoMapPreview()
|
|
||||||
else
|
|
||||||
let existing_preview_window = bufwinnr(existing_preview_buffer)
|
|
||||||
|
|
||||||
if existing_preview_window != -1
|
|
||||||
if winnr() != existing_preview_window
|
|
||||||
exe existing_preview_window . "wincmd w"
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
exe "vsplit +buffer" . existing_preview_buffer
|
|
||||||
wincmd H
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction"}}}
|
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Mercurial's graphlog code
|
"{{{ Mercurial's graphlog code
|
||||||
@ -656,11 +655,11 @@ def changenr(nodes):
|
|||||||
ENDPYTHON
|
ENDPYTHON
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Graph rendering
|
"{{{ Rendering
|
||||||
|
|
||||||
function! s:GundoRender()"{{{
|
function! s:GundoRenderGraph()"{{{
|
||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
def GundoRender():
|
def GundoRenderGraph():
|
||||||
nodes, nmap = make_nodes()
|
nodes, nmap = make_nodes()
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
@ -682,7 +681,7 @@ def GundoRender():
|
|||||||
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
|
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
|
||||||
header = (INLINE_HELP % target).splitlines()
|
header = (INLINE_HELP % target).splitlines()
|
||||||
|
|
||||||
vim.command('GundoOpenBuffer')
|
vim.command('GundoOpenGraph')
|
||||||
vim.command('setlocal modifiable')
|
vim.command('setlocal modifiable')
|
||||||
vim.current.buffer[:] = (header + result)
|
vim.current.buffer[:] = (header + result)
|
||||||
vim.command('setlocal nomodifiable')
|
vim.command('setlocal nomodifiable')
|
||||||
@ -698,14 +697,10 @@ def GundoRender():
|
|||||||
i += 1
|
i += 1
|
||||||
vim.command('%d' % (i+len(header)-1))
|
vim.command('%d' % (i+len(header)-1))
|
||||||
|
|
||||||
GundoRender()
|
GundoRenderGraph()
|
||||||
ENDPYTHON
|
ENDPYTHON
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
"{{{ Preview rendering
|
|
||||||
|
|
||||||
function! s:GundoRenderPreview(target)"{{{
|
function! s:GundoRenderPreview(target)"{{{
|
||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
import difflib
|
import difflib
|
||||||
@ -800,7 +795,7 @@ function! s:GundoRevert()"{{{
|
|||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
_undo_to(vim.eval('target_num'))
|
_undo_to(vim.eval('target_num'))
|
||||||
ENDPYTHON
|
ENDPYTHON
|
||||||
GundoRender
|
GundoRenderGraph
|
||||||
exe back . "wincmd w"
|
exe back . "wincmd w"
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
@ -846,7 +841,7 @@ def GundoPlayTo():
|
|||||||
|
|
||||||
for node in branch:
|
for node in branch:
|
||||||
_undo_to(node.n)
|
_undo_to(node.n)
|
||||||
vim.command('GundoRender')
|
vim.command('GundoRenderGraph')
|
||||||
normal('zz')
|
normal('zz')
|
||||||
vim.command('%dwincmd w' % int(vim.eval('back')))
|
vim.command('%dwincmd w' % int(vim.eval('back')))
|
||||||
vim.command('redraw')
|
vim.command('redraw')
|
||||||
@ -859,9 +854,9 @@ endfunction"}}}
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Misc
|
"{{{ Misc
|
||||||
command! -nargs=0 GundoOpenBuffer call s:GundoOpenBuffer()
|
command! -nargs=0 GundoOpenGraph call s:GundoOpenGraph()
|
||||||
command! -nargs=0 GundoToggle call s:GundoToggle()
|
command! -nargs=0 GundoToggle call s:GundoToggle()
|
||||||
command! -nargs=0 GundoRender call s:GundoRender()
|
command! -nargs=0 GundoRenderGraph call s:GundoRenderGraph()
|
||||||
autocmd BufNewFile __Gundo__ call s:GundoMarkBuffer()
|
autocmd BufNewFile __Gundo__ call s:GundoSettingsGraph()
|
||||||
autocmd BufNewFile __Gundo_Preview__ call s:GundoMarkPreviewBuffer()
|
autocmd BufNewFile __Gundo_Preview__ call s:GundoSettingsPreview()
|
||||||
"}}}
|
"}}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user