Mouse click keeps caret inline instead of after it

Added a CaretListener which checks if the mouse moved the caret. If so,
make sure to reposition the caret when the caret is supposed to be "on"
a character instead of behind the last character.

Fixes #211.