<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def before_event(self, event):
 """Ensure a screen is at the bottom of the history buffer. :param str event: event name, for example ``"linefeed"``. """

        if event not in ["prev_page", "next_page"]:
            while self.history.position < self.history.size:
                self.next_page()