Adding a source view
authorStefan Huber <shuber2@gmail.com>
Wed, 11 Jun 2008 16:22:18 +0000 (18:22 +0200)
committerStefan Huber <shuber2@gmail.com>
Wed, 11 Jun 2008 16:22:18 +0000 (18:22 +0200)
DbgTerminal.py
GdbTerminal.py
PositionFrame.py

index c854bbaab2a449e344fcdbc7c5615e14a207b558..afeca3de2d2cf1cccbddbbc3c0477d661782c056 100644 (file)
@@ -193,6 +193,9 @@ class DbgTerminal (vte.Terminal):
        def getExpression(self, expr):
                raise NotImplementedError()
 
+       def listCodeSnippet(self):
+               raise NotImplementedError()
+
        def waitForPrompt(self, his):           
                raise NotImplementedError()
 
index 579849dea5816e2494894c7b606087d4f167d78c..5e6ba6d75d821583107faaccb258991bdd56032a 100755 (executable)
@@ -137,6 +137,15 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
                split = string.split(answer, "=")
                return string.join(split[1:], "=").strip()
 
+       
+       def listCodeSnippet(self):
+               starthis = self.getHistoryLen()
+               self.feed_child("list\n")
+               endhis, response = self.waitForPrompt(starthis)
+
+               text = string.join(self.history[starthis:endhis], "\n")
+               return text
+
 
        def waitForPrompt(self, his):
                rx = "^\(gdb\)"
index ce82619bc1ed37e1906e6cdbdeec05116fe94e88..4403932e3fc7c950d4fe31d00d99cf2b23fe17a3 100644 (file)
@@ -69,12 +69,22 @@ class PositionFrame (StatusFrame.StatusFrame):
 
 
        def updateValues(self, status, param):
+               
+               #Create new text buffer for source view
+               buf = gtk.TextBuffer()
 
                if status == "break":           
                        self.file, self.lineno = param
                        self.positionLabel.set_label("%s:%d" % (self.file, self.lineno))
+
+                       #Get some code
+                       code = self.debugger.listCodeSnippet()
+                       buf.set_text(code)
+
+
                else:
                        self.file, self.lineno = None, None
+                       code = ""
 
                        if status == "exited":
                                self.positionLabel.set_label("Exited with code %d." % param)
@@ -85,6 +95,12 @@ class PositionFrame (StatusFrame.StatusFrame):
                        else:
                                self.positionLabel.set_label(status)
 
+       
+               #Set the buffer
+               self.srcview.set_buffer(buf)
+
+
+               
 
        def applyConfiguration(self, conf):
                pass