I want to offset a single region up or down by a mutiple of line_height (called region
and offset
, respectively, in the code below).
The only way I’ve managed to do so is to go from region > point > layout, offset the layout, and then go back again. It works just fine but it’s not very elegant. Here’s what it looks like:
region_a = list(view.text_to_layout(region.a))
region_b = list(view.text_to_layout(region.b))
region_a[1] = region_a[1] + offset
region_b[1] = region_b[1] + offset
region = sublime.Region(view.layout_to_text(region_a), view.layout_to_text(region_b))
I’m looking for gentle (or not so gentle) suggestions for improvement in either my python or use of the API .
Thanks,
Alex