import os
import pango
import pty
+import re
import string
import sys
import time
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):
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:]
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 )
#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):
def getExpression(self, expr):
raise NotImplementedError()
- def waitForActivation(self, his):
+ def waitForPrompt(self, his):
raise NotImplementedError()
def testForActivity(self, his):