diff --git a/autoload/vebugger.vim b/autoload/vebugger.vim index 1cd80c1..5831629 100644 --- a/autoload/vebugger.vim +++ b/autoload/vebugger.vim @@ -295,16 +295,47 @@ function! vebugger#killDebugger() endif endfunction +"Perform an action on the actvie debugger, and register that action function! vebugger#userAction(action, ...) if exists('s:debugger') if has_key(s:debugger, a:action) + let s:debugger.lastUserAction = { + \'action': a:action, + \'args': a:000} + + try + doautocmd User Vebugger_PreUserAction + catch + endtry + call call(s:debugger[a:action], a:000, s:debugger) + + try + doautocmd User Vebugger_PostUserAction + catch + endtry else throw 'Current debugger does not support action '.a:action endif endif endfunction +augroup vebugger_hooks + autocmd! + "Make a blank action hook to prevent 'No matching autocommands" warning + autocmd User Vebugger_* echo +augroup END + +"Repeat the last action performed on the active debugger +function! vebugger#repeatLastUserAction() + if exists('s:debugger') + if has_key(s:debugger, 'lastUserAction') + let l:lastUserAction = s:debugger.lastUserAction + call call(s:debugger[l:lastUserAction.action], l:lastUserAction.args, s:debugger) + endif + endif +endfunction + "Write a line to the currently active debugger function! vebugger#writeLine(line) if exists('s:debugger') diff --git a/plugin/vebugger.vim b/plugin/vebugger.vim index b78bcb5..1ef8746 100644 --- a/plugin/vebugger.vim +++ b/plugin/vebugger.vim @@ -1,5 +1,7 @@ +command! -nargs=0 VBGrepeat call vebugger#repeatLastUserAction() + command! -nargs=1 VBGrawWrite call vebugger#userAction('writeLine', ) command! -nargs=0 VBGkill call vebugger#killDebugger()