X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=pygdb.vim;fp=pygdb.vim;h=b38a173115aca00226ac05589e4039b49f6ac3d9;hb=1094f7f4581a9c0074294004bbd8c934593a54d5;hp=0000000000000000000000000000000000000000;hpb=cfcc39662a53b6f7a77c7ec8f05478227c5f137f;p=pygdb.git diff --git a/pygdb.vim b/pygdb.vim new file mode 100644 index 0000000..b38a173 --- /dev/null +++ b/pygdb.vim @@ -0,0 +1,161 @@ +"shuber, 2008-06-08 + +if ! exists("g:pygdb") + +let g:pygdb = 1 +let s:ScriptLocation = expand("") + + +python << >> + +import gtk +import string +import sys +import threading + +import vim + +#Do not use a ~ for home directory +sys.path.append("/home/shuber/projekte/pygdb/") + +import GdbTerminal +import MainControlWindow +import StatusWindow + + +#Breakpoint positions: List of dictionaries of form {"signnum" : , "file" : , "lineno":, "cond" : } +gdbBps = [] +signnum = 0 +clientcmd = "" + +gdbterm = None +mainctrlwnd = None +statuswnd = None +gdbthread = None + + + +def gdbLaunch(): + global gdbterm, mainctrlwnd, statuswnd, gdbBps, clientcmd, gdbthread + + if gdbterm == None: + + clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd) + gdbterm = GdbTerminal.GdbTerminal(clientcmd) + mainctrlwnd = MainControlWindow.MainControlWindow(gdbterm, quitonclose=False) + statuswnd = StatusWindow.StatusWindow(mainctrlwnd, gdbterm, quitonclose=False) + gdbterm.initialize() + + + for bp in gdbBps: + statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"]) + + gtk.main() + gtk.main() + print "hello" + #mainctrlwnd.hide() + #statuswnd.hide() + + +def gdbToggleBreakpoint(lineno=None, file=None): + global gdbBps + + #Set lineno and file if not already set + if lineno==None: + lineno = vim.current.window.cursor[0] + if file==None: + file = vim.current.window.buffer.name + + #Determine index of breakpoint + bpidx = gdbGetBreakpoint( file, lineno ) + + #Remove the breakpoint + if bpidx != None: + vim.command("sign unplace %(signnum)d" % gdbBps[bpidx]) + del gdbBps[bpidx] + + #Create the breakpoint + else: + #Determine a sign number + signnum = gdbNewSignnum() + + #Create breakpoint and add sign + b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : None} + vim.command("sign place %(signnum)d line=%(lineno)d name=BreakPoint file=%(file)s" % b) + gdbBps += [b] + + +def gdbBreakpointCond(lineno=None, file=None, cond=None): + global gdbBps + + #Set lineno and file if not already set + if lineno==None: + lineno = vim.current.window.cursor[0] + if file==None: + file = vim.current.window.buffer.name + + #Determine index of breakpoint + bpidx = gdbGetBreakpoint( file, lineno ) + + #Remove the breakpoint + if bpidx != None: + if cond == None: + cond = vim.eval("input('Breakpoint condition: ', '%s')" % gdbBps[bpidx]["cond"]) + gdbBps[bpidx]["cond"] = cond + + else: + #Determine a sign number + signnum = gdbNewSignnum() + + #Get condition + if cond == None: + cond = vim.eval("input('Breakpoint condition: ', '')") + + #Create breakpoint and add sign + b = {"signnum" : signnum, "lineno" : lineno, "file" : file, "cond" : cond} + vim.command("sign place %(signnum)d line=%(lineno)d name=CondBreakPoint file=%(file)s" % b) + gdbBps += [b] + + +def gdbNewSignnum(): + global signnum + signnum += 1 + return signnum + + +def gdbGetBreakpoint(file, lineno): + for i in range(len(gdbBps)): + if [gdbBps[i]["file"], gdbBps[i]["lineno"]] == [file,lineno]: + return i + return None + + +>> + + +highlight ExecutionLine term=bold ctermbg=DarkGreen ctermfg=White +highlight BreakPoint term=inverse ctermbg=DarkCyan ctermfg=Black + +sign define ExecutionLine text==> texthl=ExecutionLine linehl=ExecutionLine +sign define BreakPoint text=! texthl=BreakPoint linehl=BreakPoint +sign define CondBreakPoint text=? texthl=BreakPoint linehl=BreakPoint + + + +command! GDBLaunch :python gdbLaunch() +command! GDBToggleBreakpoint :python gdbToggleBreakpoint() +command! GDBBreakpointCond :python gdbBreakpointCond() + + + +function! GDBMapDefaults() + nmap :GDBLaunch + nmap :GDBToggleBreakpoint + nmap :GDBBreakpointCond +endfunction + + + +endif + +