don't set styleranges that exceed the document's length
handle SGR codes 38 and 48 (setting color not yet implemented)