+ text = self.get_text_range(max(self.getHistoryLen()-1,0),0,r,-1,lambda *w:True)
+
+ #Remove annoying \n at the end
+ 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")
+
+ #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)