1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 03:00:06 +08:00

Add undo mode

This commit is contained in:
wsdjeg 2017-04-22 01:37:23 +08:00
parent 0557d5e904
commit e2e3ae789d
2 changed files with 18 additions and 4 deletions

View File

@ -469,7 +469,7 @@ function! SpaceVim#end() abort
endif endif
let g:leaderGuide_max_size = 15 let g:leaderGuide_max_size = 15
let g:leaderGuide_submode_mappings = let g:leaderGuide_submode_mappings =
\ { '<C-C>': 'win_close', '<PageDown>': 'page_down', '<PageUp>': 'page_up'} \ { '<C-C>': 'win_close', '<PageDown>': 'page_down', '<PageUp>': 'page_up', 'u' : 'undo'}
call SpaceVim#plugins#load() call SpaceVim#plugins#load()
endfunction endfunction

View File

@ -292,7 +292,7 @@ function! s:create_string(layout) " {{{
call insert(r, '') call insert(r, '')
let output = join(r, "\n ") let output = join(r, "\n ")
cnoremap <nowait> <buffer> <Space> <Space><CR> cnoremap <nowait> <buffer> <Space> <Space><CR>
cnoremap <nowait> <buffer> <silent> <c-c> <LGCMD>submode<CR> cnoremap <nowait> <buffer> <silent> <c-h> <LGCMD>paging_help<CR>
return output return output
endfunction " }}} endfunction " }}}
@ -328,7 +328,6 @@ function! s:handle_input(input) " {{{
if type(a:input) ==? type({}) if type(a:input) ==? type({})
let s:lmap = a:input let s:lmap = a:input
let s:guide_group = a:input let s:guide_group = a:input
let g:guide_group = a:input
call s:start_buffer() call s:start_buffer()
else else
let s:prefix_key_inp = '' let s:prefix_key_inp = ''
@ -347,7 +346,7 @@ function! s:wait_for_input() " {{{
if inp ==? '' if inp ==? ''
let s:prefix_key_inp = '' let s:prefix_key_inp = ''
call s:winclose() call s:winclose()
elseif match(inp, "^<LGCMD>submode") == 0 elseif match(inp, "^<LGCMD>paging_help") == 0
call s:submode_mappings() call s:submode_mappings()
else else
if inp == ' ' if inp == ' '
@ -407,6 +406,12 @@ function! s:updateStatusline() abort
\ SpaceVim#mapping#leader#getName(s:prefix_key) \ SpaceVim#mapping#leader#getName(s:prefix_key)
\ . get(s:, 'prefix_key_inp', '') . gname \ . get(s:, 'prefix_key_inp', '') . gname
\ . '%#LeaderGuiderSep2#%#LeaderGuiderFill#' \ . '%#LeaderGuiderSep2#%#LeaderGuiderFill#'
\ . s:guide_help_msg()
endfunction
function! s:guide_help_msg() abort
let msg = '[C-h\ paging/help]'
return msg
endfunction endfunction
function! s:winclose() " {{{ function! s:winclose() " {{{
@ -426,6 +431,12 @@ function! s:page_down() " {{{
redraw! redraw!
call s:wait_for_input() call s:wait_for_input()
endfunction " }}} endfunction " }}}
function! s:page_undo() " {{{
call feedkeys("\<c-c>", "n")
redraw!
let s:lmap = s:lmap_undo
call s:start_buffer()
endfunction " }}}
function! s:page_up() " {{{ function! s:page_up() " {{{
call feedkeys("\<c-c>", "n") call feedkeys("\<c-c>", "n")
call feedkeys("\<c-b>", "x") call feedkeys("\<c-b>", "x")
@ -438,6 +449,8 @@ function! s:handle_submode_mapping(cmd) " {{{
call s:page_down() call s:page_down()
elseif a:cmd ==? '<LGCMD>page_up' elseif a:cmd ==? '<LGCMD>page_up'
call s:page_up() call s:page_up()
elseif a:cmd ==? '<LGCMD>undo'
call s:page_undo()
elseif a:cmd ==? '<LGCMD>win_close' elseif a:cmd ==? '<LGCMD>win_close'
call s:winclose() call s:winclose()
endif endif
@ -504,6 +517,7 @@ function! SpaceVim#mapping#guide#start_by_prefix(vis, key) " {{{
let rundict = s:cached_dicts[a:key] let rundict = s:cached_dicts[a:key]
endif endif
let s:lmap = rundict let s:lmap = rundict
let s:lmap_undo = rundict
call s:start_buffer() call s:start_buffer()
endfunction " }}} endfunction " }}}