Move block selection code to helper function.
Simplify visual-linewise UI fixes.

We clip the displayed selection so the caret sits at the end of the
previous line instead of displaying it in column 0 like Eclipse does.

Rewrite this code so the visual UI fixes can profit from some of the
helper variables.

Work for #561.
Use block cursor to signal EOL selection.

Before, the selection would always jump to the next line to signal the
the newline character(s) were selected because that is how Eclipse would
do it. Vim on the other hand just selects an extra (whitespace)
character to signal it, so we now shorten the selection and show the
caret on the previous line.

Fixes #561.
Fix offsets and caret for last character selection

If the caret is past the last char instead of 'on' that char, moving the
selection back means you have to press <Left> twice. Simply forbid
moving the caret past that last character when extending the selection.

The cursor can be past the last character if the last line is empty
(in that case it's a newline) and the selection is started from there.
Vim doesn't allow creating an empty selection for that last line though,
so change the selection to be "on" the previous newline. Also make sure
to fix the caret type if this happens.

Related to #540.