code: def before_event(self, event):
          
          if event not in ["prev_page", "next_page"]:
              while self.history.position < self.history.size:
                  self.next_page()
docs: Ensure a screen is at the bottom of the history buffer.
  
          :param str event: event name, for example ``"linefeed"``.