--- /dev/null
+"shuber, 2008-06-08
+
+if ! exists("g:pygdb")
+
+let g:pygdb = 1
+let s:ScriptLocation = expand("<sfile>")
+
+
+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 <silent> <F5> :GDBLaunch<CR>
+ nmap <silent> <F8> :GDBToggleBreakpoint<CR>
+ nmap <silent> <F9> :GDBBreakpointCond<CR>
+endfunction
+
+
+
+endif
+
+