From: Stefan Huber Date: Wed, 11 Jun 2008 16:22:18 +0000 (+0200) Subject: Adding a source view X-Git-Tag: v0.99.0~5 X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=commitdiff_plain;h=3c94180482e4ccd256f087ff182278f083a94276 Adding a source view --- diff --git a/DbgTerminal.py b/DbgTerminal.py index c854bba..afeca3d 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -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() diff --git a/GdbTerminal.py b/GdbTerminal.py index 579849d..5e6ba6d 100755 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -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\)" diff --git a/PositionFrame.py b/PositionFrame.py index ce82619..4403932 100644 --- a/PositionFrame.py +++ b/PositionFrame.py @@ -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