Don't always invalidate the whole gutter

Instead, invalidate the whole lines gutter renderer only when needed.

WARNING: during file loading I think the gutter is redrawn a lot.
Instead of taking the total line count of the buffer, compare the number
of the last visible line.

This should prevent degenerate cases where the gutter window is being
continuously invalidated during certain operations, for example search.

This is needed to have decent search performances on Mac OS X (but this
is not the root cause why the search was really slow on OS X, it is
probably because text drawing is much slower than on Linux).