highlight.py refactoring

These are mostly trivial/mechanical edits.

I'd like to go further and make a proper class out of this module's public methods.
There is already an ad-hoc class-like structure with all those attributes on `highlight_window` function.
It would be better to help future contributors by splitting that enormous function into simpler self-contained subroutines.