code: def next_page(self):
          
          if self.history.position < self.history.size and self.history.bottom:
              mid = min(len(self.history.bottom),
                        int(math.ceil(self.lines * self.history.ratio)))
  
              self.history.top.extend(self.buffer[y] for y in range(mid))
              self.history = self.history \
                  ._replace(position=self.history.position + mid)
  
              for y in range(self.lines - mid):
                  self.buffer[y] = self.buffer[y + mid]
              for y in range(self.lines - mid, self.lines):
                  self.buffer[y] = self.history.bottom.popleft()
  
              self.dirty = set(range(self.lines))
docs: Move the screen page down through the history buffer.