some code beautifying: __waitForPrompt
[pygdb.git] / pygdb.vim
index 1926f3e60b5406859a794c3719884c46dbc109db..fe0626ff04f12b9359f87dbcef63393babe3cb17 100644 (file)
--- a/pygdb.vim
+++ b/pygdb.vim
@@ -9,47 +9,41 @@ let s:ScriptLocation = expand("<sfile>")
 python << >>
 
 import gtk
+import os
 import string
 import sys
 import threading
-
 import vim
 
-#Do not use a ~ for home directory
-sys.path.append("/home/shuber/projekte/pygdb/")
+import Configuration
 
-import pygdb
-import GdbTerminal
-import MainControlWindow
-import StatusWindow
 
 
-#Breakpoint positions: List of dictionaries of form {"signnum" : , "file" : , "lineno":, "cond" : }
+#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)
+       clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
 
-               gdbterm, mainctrlwnd, statuswnd = pygdb.launchDebugger(clientcmd, False)
 
-               for bp in gdbBps:
-                       statuswnd.breakpointsFrame.addBreakpoint(bp["file"], bp["lineno"], bp["cond"])
+       if clientcmd.strip()=="":
+               print "No command given!"
+               return
 
-               gtk.main()
-               gdbterm = None  
+       #Add the breakpoints to the configuration
+       conf = Configuration.Configuration()
+       conf.load(".pygdb.conf")
+       for bp in gdbBps:
+               conf.addBreak(bp["file"], bp["lineno"], bp["cond"])
+       conf.store(".pygdb.conf")
+       
+       vim.command("!python %s/pygdb.py %s &\n" % (pygdbdir, clientcmd))
 
 
 def gdbToggleBreakpoint(lineno=None, file=None):
@@ -59,7 +53,7 @@ def gdbToggleBreakpoint(lineno=None, file=None):
        if lineno==None:
                lineno = vim.current.window.cursor[0]
        if file==None:
-               file = vim.current.window.buffer.name
+               file = getCurrentFile()
 
        #Determine index of breakpoint
        bpidx = gdbGetBreakpoint( file, lineno )
@@ -87,7 +81,7 @@ def gdbBreakpointCond(lineno=None, file=None, cond=None):
        if lineno==None:
                lineno = vim.current.window.cursor[0]
        if file==None:
-               file = vim.current.window.buffer.name
+               file = getCurrentFile()
 
        #Determine index of breakpoint
        bpidx = gdbGetBreakpoint( file, lineno )
@@ -112,6 +106,11 @@ def gdbBreakpointCond(lineno=None, file=None, cond=None):
                gdbBps += [b]
 
 
+def getCurrentFile():
+       return vim.current.window.buffer.name
+
+
+
 def gdbNewSignnum():
        global signnum
        signnum += 1
@@ -128,10 +127,8 @@ def gdbGetBreakpoint(file, lineno):
 >>
 
 
-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