code: def save_position(self):
          
          # save text cursor position:
          self.old_text_pos = self.index(tkinter.INSERT)
          # save scroll position:
          self.old_first, self.old_last = self.yview()
docs: save cursor and scroll position