diff --git a/autoload/vebugger/gdb.vim b/autoload/vebugger/gdb.vim index c61c442..f674bbb 100644 --- a/autoload/vebugger/gdb.vim +++ b/autoload/vebugger/gdb.vim @@ -37,6 +37,7 @@ function! vebugger#gdb#start(binaryFile,args) call l:debugger.setWriteHandler('std','breakpoints',function('s:writeBreakpoints')) call l:debugger.setWriteHandler('std','closeDebugger',function('s:closeDebugger')) call l:debugger.setWriteHandler('std','evaluateExpressions',function('s:requestEvaluateExpression')) + call l:debugger.setWriteHandler('std','executeStatements',function('s:executeStatements')) call l:debugger.generateWriteActionsFromTemplate() @@ -125,6 +126,20 @@ function! s:requestEvaluateExpression(writeAction,debugger) endfor endfunction +function! s:executeStatements(writeAction,debugger) + for l:evalAction in a:writeAction + if has_key(l:evalAction,'statement') + let l:statement=l:evalAction.statement + let l:statement=substitute(l:statement,'\v;\s*$','','') "remove trailing `;` + if l:statement=~'\v^[^(]+\=.+' + call a:debugger.writeLine('set '.l:statement) + else + call a:debugger.writeLine('call '.l:statement) + endif + endif + endfor +endfunction + function! s:readEvaluatedExpressions(pipeName,line,readResult,debugger) dict if 'out'==a:pipeName if has_key(self,'nextExpressionToBePrinted') diff --git a/autoload/vebugger/std.vim b/autoload/vebugger/std.vim index 2c24250..a180c12 100644 --- a/autoload/vebugger/std.vim +++ b/autoload/vebugger/std.vim @@ -24,6 +24,7 @@ function! vebugger#std#setStandardWriteactionsTemplate(debugger) \'flow':'', \'breakpoints':[], \'evaluateExpressions':[], + \'executeStatements':[], \'removeAfterDisplayed':[], \'closeDebugger':''} endfunction @@ -119,6 +120,13 @@ function! s:standardFunctions.eval(expression) dict call self.performWriteActions() endfunction +"Executes a statement in the debugged program +function! s:standardFunctions.execute(statement) dict + call self.addWriteAction('std','executeStatements',{ + \'statement':(a:statement)}) + call self.performWriteActions() +endfunction + let s:standardThinkHandlers={} function! s:standardThinkHandlers.addProgramOutputToShell(readResult,debugger) dict let l:programOutput=a:readResult.std.programOutput @@ -272,3 +280,10 @@ function! vebugger#std#eval(expression) call l:debugger.std_eval(a:expression) endif endfunction + +function! vebugger#std#execute(statement) + let l:debugger=vebugger#getActiveDebugger() + if !empty(l:debugger) && !empty(l:debugger.std_eval) + call l:debugger.std_execute(a:statement) + endif +endfunction diff --git a/plugin/vebugger.vim b/plugin/vebugger.vim index 0fa3a1c..adc5df2 100644 --- a/plugin/vebugger.vim +++ b/plugin/vebugger.vim @@ -15,8 +15,10 @@ command! -nargs=0 VBGclearBreakpints call vebugger#std#clearBreakpoints() command! -nargs=1 VBGeval call vebugger#std#eval() command! -nargs=0 VBGevalWordUnderCursor call vebugger#std#eval(expand('')) +command! -nargs=1 VBGexecute call vebugger#std#execute() command! -range -nargs=0 VBGevalSelectedText call vebugger#std#eval(vebugger#util#get_visual_selection()) +command! -range -nargs=0 VBGexecuteSelectedText call vebugger#std#execute(vebugger#util#get_visual_selection()) command! -range -nargs=0 VBGrawWriteSelectedText call vebugger#writeLine(vebugger#util#get_visual_selection()) command! -nargs=1 -complete=file VBGstartGDB call vebugger#gdb#start(,{}) @@ -36,12 +38,15 @@ if exists('g:vebugger_leader') \'B':'VBGclearBreakpints', \'e':'VBGevalWordUnderCursor', \'E':'exe "VBGeval ".input("VBG-Eval> ")', + \'x':'exe "VBGexecute ".getline(".")', + \'X':'exe "VBGexecute ".input("VBG-Exec> ")', \'w':'exe "VBGrawWrite ".getline(".")', \'W':'exe "VBGrawWrite ".input("VBG> ")'}) exe 'nnoremap '.g:vebugger_leader.s:mapping[0].' :'.s:mapping[1].'' endfor for s:mapping in items({ \'e':'VBGevalSelectedText', + \'x':'VBGexecuteSelectedText', \'w':'VBGrawWriteSelectedText'}) exe 'vnoremap '.g:vebugger_leader.s:mapping[0].' :'.s:mapping[1].'' endfor