Add hook for pre&post user actions
This commit is contained in:
parent
4567ad166b
commit
e3c069b5b6
@ -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')
|
||||
|
@ -1,5 +1,7 @@
|
||||
|
||||
|
||||
command! -nargs=0 VBGrepeat call vebugger#repeatLastUserAction()
|
||||
|
||||
command! -nargs=1 VBGrawWrite call vebugger#userAction('writeLine', <q-args>)
|
||||
command! -nargs=0 VBGkill call vebugger#killDebugger()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user