diff options
author | rxi <rxi@users.noreply.github.com> | 2020-05-20 12:08:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-20 12:08:38 +0100 |
commit | 6d233a0a0dfaf513b63c2bf4cd5d513698f3752d (patch) | |
tree | 8921e2008967112776f08a1734bac9087cc15630 | |
parent | 98915835b0f67daa4f8694710c6d254fd9974781 (diff) | |
parent | fe3a8b17380e6ab007b645a3899109b799e5e731 (diff) | |
download | lite-xl-plugins-6d233a0a0dfaf513b63c2bf4cd5d513698f3752d.tar.gz lite-xl-plugins-6d233a0a0dfaf513b63c2bf4cd5d513698f3752d.zip |
Merge pull request #36 from liqube/master
Support #fff format in colorpreview plugin
-rw-r--r-- | plugins/colorpreview.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/colorpreview.lua b/plugins/colorpreview.lua index 2743f91..71f5c6d 100644 --- a/plugins/colorpreview.lua +++ b/plugins/colorpreview.lua @@ -7,7 +7,7 @@ local black = { common.color "#000000" } local tmp = {} -local function draw_color_previews(self, idx, x, y, ptn, base) +local function draw_color_previews(self, idx, x, y, ptn, base, nibbles) local text = self.doc.lines[idx] local s, e = 0, 0 @@ -19,6 +19,13 @@ local function draw_color_previews(self, idx, x, y, ptn, base) local r, g, b = str:match(ptn) r, g, b = tonumber(r, base), tonumber(g, base), tonumber(b, base) + -- #123 becomes #112233 + if nibbles then + r = r * 16 + g = g * 16 + b = b * 16 + end + local x1 = x + self:get_col_x_offset(idx, s) local x2 = x + self:get_col_x_offset(idx, e + 1) local oy = self:get_line_text_y_offset() @@ -41,6 +48,6 @@ local draw_line_text = DocView.draw_line_text function DocView:draw_line_text(idx, x, y) draw_line_text(self, idx, x, y) draw_color_previews(self, idx, x, y, "#(%x%x)(%x%x)(%x%x)%f[%X]", 16) + draw_color_previews(self, idx, x, y, "#(%x)(%x)(%x)%f[%X]", 16, true) -- support #fff css format draw_color_previews(self, idx, x, y, "rgba?%((%d+)%D+(%d+)%D+(%d+).-%)", 10) end - |