X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=DbgTerminal.py;h=6fec9f3e789f40cff60e62de2561d271ca81164e;hb=648f1bdb4bb69daf905ce13c57eccd327b0bf151;hp=11eaf5c35ee2cdf4a7f2629716b69fe5f2394e85;hpb=973cf63f2347aa83edb9654d3566eaf66526d6b9;p=pygdb.git diff --git a/DbgTerminal.py b/DbgTerminal.py index 11eaf5c..6fec9f3 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -26,7 +26,7 @@ class DbgTerminal (vte.Terminal): #Set members self.childpid = None - self.history = [] + self.history = [""] self.isactive = True #Start debugger @@ -58,6 +58,8 @@ class DbgTerminal (vte.Terminal): def contents_changed(self, term): + assert( self.getHistoryLen()>0 ) + c,r = term.get_cursor_position() text = self.get_text_range(self.getHistoryLen()-1,0,r,-1,lambda *w:True) @@ -65,17 +67,17 @@ class DbgTerminal (vte.Terminal): assert(text[-1] == "\n") text = text[:-1] - #Remove the incomplete line - if self.getHistoryLen()>0 and self.history[-1]!='\n': - del self.history[-1] - #Get the lines and remove empty lines 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) + def waitForNewline(self): l = self.getHistoryLen() @@ -86,16 +88,16 @@ class DbgTerminal (vte.Terminal): return len(self.history) def waitForRx(self, rx, start): - curr = start - while True: - for no in range(max(curr-1,start), self.getHistoryLen()): + assert( curr>=start ) + for no in range(curr, self.getHistoryLen()): line = self.history[no] if rx.search(line): return no, line - curr = max(start,self.getHistoryLen()) + #Do not forget the last line + curr = max(start,self.getHistoryLen()-1) gtk.main_iteration() @@ -148,7 +150,6 @@ def quitHandler(*w): gtk.main_quit() except: pass - sys.exit(0)