Trim long buffers

Fixes #338
Rename 'lines' to 'lines_per_screen'
Merge pull request #339 from glowing-bear/trimlines

Trim long buffers