Clean up termbox frontend code

This fixes https://github.com/limetext/lime/issues/376 By default on a new line, no line number is printed and the editor is out of place. This is due to a missing piece of code that prints the line number after a newline is detected. I've also cleaned up some code throughout the file because it was bothering me.
[Manual loop unroll](https://github.com/limetext/lime/pull/436#discussion_r20406375), which again is quite misguided IMO.