Implement chat history recall with up/down keys

This commit implements a feature commonly found in IRC clients,
wherein the user can press the up key to recall previously sent
messages (and can press the down key to cycle back the other
direction in the history).

This commit is similar to pull request #11, except that this
implementation works properly.