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.
This change looks wrong to me, and I suspect that even if it were rewritten to have the same functionality, it would be less readable that what it currently is. Could you revert (or fix) this change, please?