Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime text 2 : highlight/color a line by plugin

I'm trying to create a plugin where i need do colorize/highlight a full line (not text).

For example if i do something like:

 for region in self.view.sel():
        if region.empty():
            line = self.view.line(region)
            self.view.add_regions('put-some-bg-color', [line], 'keyword', 'bookmark', sublime.DRAW_OUTLINED)

this will only put a outline on text until the newline char (\n).

I would like to put a backgroud color one the whole line, like it's done by the "highlight_line" preference.

like image 467
pcmind Avatar asked Nov 14 '22 05:11

pcmind


1 Answers

It is possible. You should be able to draw a line like this:

region = view.text_point(line_number, 0)
line = self.view.line(region)
self.view.add_regions(...)

You can take a look at the plugin Diffy I created.

like image 102
zs2020 Avatar answered Dec 09 '22 07:12

zs2020