Rewrite input history navigation

- Use an offset from the bottom for storing the navigation state

- Rename the navigation functions to upHistory and downHistory for less
  confusion

- Centralize repeating buffer refresh code

GitHub: fixes #22