X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=DbgTerminal.py;fp=DbgTerminal.py;h=f69d8036fc8e5c3785903acb21f081a823ce268d;hb=e8f5eba24b3fd5cdd839bcfc170a2e3aa16dd05d;hp=ebe4e1a2f147ed16bb8c37474724d02f4811dded;hpb=162c3ac77fb35684824a2a8f975800dd9780bf10;p=pygdb.git diff --git a/DbgTerminal.py b/DbgTerminal.py index ebe4e1a..f69d803 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -9,6 +9,7 @@ import gtk import os import pango import pty +import re import string import sys import time @@ -51,7 +52,7 @@ class DbgTerminal (vte.Terminal): def initialize(self): self.childpid = self.fork_command( self.getCommand(), self.getArgv()) - self.waitForActivation(0) + self.waitForPrompt(0) self.setPty(self.client_ptyslave) def stopDbg(self): @@ -91,18 +92,19 @@ class DbgTerminal (vte.Terminal): assert( self.getHistoryLen()>0 ) c,r = term.get_cursor_position() - text = self.get_text_range(self.lastr,self.lastc,r,c-1,lambda *w:True) + text = self.get_text_range(self.lastr,0,r,c,lambda *w:True) self.lastc, self.lastr = c,r #Remove annoying \n at the end assert(text[-1] == "\n") text = text[:-1] + #Get the lines and remove empty lines lines = string.split(text, "\n") #Remove the incomplete line len = max(0,self.getHistoryLen()) - self.history[-1] += lines[0] + self.history[-1] = lines[0] self.history += lines[1:] @@ -139,7 +141,9 @@ class DbgTerminal (vte.Terminal): def getHistoryLen(self): return len(self.history) - def waitForRx(self, rx, start): + def waitForRx(self, pat, start): + + rx = re.compile(pat) curr = start while True: assert( curr>=start ) @@ -150,7 +154,10 @@ class DbgTerminal (vte.Terminal): #Do not forget the last line curr = max(start,self.getHistoryLen()-1) - gtk.main_iteration() + lr, lc = self.lastr, self.lastc + + while (self.lastr, self.lastc) == (lr,lc): + gtk.main_iteration() def getCommand(self): @@ -186,7 +193,7 @@ class DbgTerminal (vte.Terminal): def getExpression(self, expr): raise NotImplementedError() - def waitForActivation(self, his): + def waitForPrompt(self, his): raise NotImplementedError() def testForActivity(self, his):