Keep LineBlock's cached_numlines up to date.

Previously, LineBlock's appendLine and dropLines methods would
invalidate its cache of the number of full lines that were in the block,
causing an expensive iteration through the entire block the next time
that information was necessary. This is unnecessary - instead, we can
update the cached_numlines value by examining the line that was just
added or dropped.

This improves the performance of `cat /usr/share/dict/words' on my
machine by about a quarter.
Add tests for ensuring cached_numlines sanity

If TEST_LINEBUFFER_SANITY is defined, each time we would update the
cached_numlines value outside of the complete refresh case, we would
also calculate the normal refreshed value and log to the console if the
updated value differs from the correct, refreshed value.
Merge remote-tracking branch 'upstream/master'
Invalidate cache if new width != old width

Also, improve the debug log so that it doesn't complain about an invalid
cache not being equal to the correct value, and pull the debug logger
into a function.
dropLines updates the line buffer cache correctly.

It doesn't make sense to call NumberOfFullLines on a range of
characters that spans a raw line. We already have the precise number of
wrapped lines to drop, orig_n, so use it to update the cache instead.
Merge pull request #134 from jordanlewis/master

Scrollback buffer performance improvment: Keep LineBlock's cached_numlines up to date