rewriting DbgTerminal.contents_changed. Much better now
authorStefan Huber <shuber2@gmail.com>
Tue, 10 Jun 2008 21:03:35 +0000 (23:03 +0200)
committerStefan Huber <shuber2@gmail.com>
Tue, 10 Jun 2008 21:03:35 +0000 (23:03 +0200)
DbgTerminal.py

index 6fec9f3e789f40cff60e62de2561d271ca81164e..6b09426a0698313742ed85402b441cdf4b715c67 100644 (file)
@@ -28,6 +28,7 @@ class DbgTerminal (vte.Terminal):
                self.childpid = None
                self.history = [""]
                self.isactive = True
+               self.lastc, self.lastr = 0,0
 
                #Start debugger
                self.clientCmd = clientCmd
@@ -61,7 +62,8 @@ class DbgTerminal (vte.Terminal):
                assert( self.getHistoryLen()>0 )
 
                c,r = term.get_cursor_position()
-               text = self.get_text_range(self.getHistoryLen()-1,0,r,-1,lambda *w:True)
+               text = self.get_text_range(self.lastr,self.lastc,r,c-1,lambda *w:True)
+               self.lastc, self.lastr = c,r
 
                #Remove annoying \n at the end
                assert(text[-1] == "\n")
@@ -71,12 +73,8 @@ class DbgTerminal (vte.Terminal):
                lines = string.split(text, "\n")
 
                #Remove the incomplete line
-               del self.history[-1]
-               #Add lines to history. The last line contains no "\n" at the end!
-               self.history += [l+"\n" for l in lines[:-1]]
-               self.history += [lines[-1]]
-
-               assert(r == self.getHistoryLen()-1)
+               self.history[-1] += lines[0]
+               self.history += lines[1:]
 
 
        def waitForNewline(self):