Rewrite input history navigation

merge at your own risk

- 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