+ def contents_changed(self, term):
+ assert( self.getHistoryLen()>0 )
+
+ c,r = term.get_cursor_position()
+ 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 += lines[1:]
+
+
+ #Check if activity status has been changed
+ for i in range(len, self.getHistoryLen()):
+ line = self.history[i]
+
+ res = self.testForInactivity(i)
+ if res != None:
+ while self.activityChanged != None:
+ print "wait for pending activity"
+ gtk.main_iteration()
+
+ self.setActive(False)
+ self.activityChanged = res
+
+ res = self.testForActivity(i)
+ if res != None:
+ while self.activityChanged != None:
+ print "wait for pending activity"
+ gtk.main_iteration()
+
+ self.setActive(True)
+ self.activityChanged = res
+
+
+
+
+ def waitForNewline(self):
+ l = self.getHistoryLen()
+ while not self.getHistoryLen() > l:
+ gtk.main_iteration()
+
+ def getHistoryLen(self):
+ return len(self.history)
+
+ def waitForRx(self, pat, start):
+
+ rx = re.compile(pat)
+ curr = start
+ while True:
+ assert( curr>=start )
+ for no in range(curr, self.getHistoryLen()):
+ line = self.history[no]
+ if rx.search(line):
+ return no, line
+
+ #Do not forget the last line
+ curr = max(start,self.getHistoryLen()-1)
+ lr, lc = self.lastr, self.lastc
+
+ while (self.lastr, self.lastc) == (lr,lc):
+ gtk.main_iteration()
+
+
+ def getCommand(self):
+ return self.getArgv()[0];
+
+ def getArgv(self):