__author__ = "shuber"
+import gobject
import gtk
import os
import pango
self.history = [""]
self.isactive = True
self.lastc, self.lastr = 0,0
+ self.gotActiveCallback = []
+ self.gotInactiveCallback = []
+ self.activityChanged = None
#Start debugger
self.clientCmd = clientCmd
#Set up terminal window and initialize debugger
self.connect("cursor-moved", self.contents_changed)
self.connect("child-exited", quitHandler)
+ gobject.timeout_add(50, self.checkActivityChanged)
#font description
fontdesc = pango.FontDescription("monospace 9")
os.kill(self.childpid, 15);
self.childpid = None
+ def checkActivityChanged(self):
+
+ try:
+
+ #There was activity
+ if self.activityChanged != None:
+
+ res = self.activityChanged
+ self.activityChanged = None
+
+ status, param = res
+ if self.isActive():
+ for cb in self.gotActiveCallback:
+ cb(status, param)
+ else:
+ for cb in self.gotInactiveCallback:
+ cb(status, param)
+ except:
+ pass
+
+ return True
+
def contents_changed(self, term):
#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 = self.getHistoryLen()
+ len = max(0,self.getHistoryLen()-1)
self.history[-1] += lines[0]
self.history += lines[1:]
- for l in self.history[len:]:
- pass
+
+ #Check if activity status has been changed
+ for i in range(len, self.getHistoryLen()):
+ line = self.history[i]
+
+ res = self.testForActivity(i)
+ if res != None and not self.isActive():
+ self.setActive(True)
+ self.activityChanged = res
+
+ res = self.testForInactivity(i)
+ if res != None and self.isActive():
+ self.setActive(False)
+ self.activityChanged = res
+
def waitForNewline(self):
def waitForActivation(self, his):
raise NotImplementedError()
+ def testForActivity(self, his):
+ raise NotImplementedError()
+
+ def testForInactivity(self, his):
+ raise NotImplementedError()
+
def setActive(self, isactive):
self.isactive = isactive