aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-05-24 20:12:57 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-24 20:12:57 -0400
commitef4088437c664637fcd4a73d342beeacdebec180 (patch)
tree638d04d2c3c650cee55c1c3b25e86845f1a80646
parent7bbe262002404958a3f116d34f70c31e942134fa (diff)
downloadlite-xl-plugins-ef4088437c664637fcd4a73d342beeacdebec180.tar.gz
lite-xl-plugins-ef4088437c664637fcd4a73d342beeacdebec180.zip
colorpreview: allow live disabling
-rw-r--r--plugins/colorpreview.lua31
1 files changed, 28 insertions, 3 deletions
diff --git a/plugins/colorpreview.lua b/plugins/colorpreview.lua
index f1e88d5..57e96c3 100644
--- a/plugins/colorpreview.lua
+++ b/plugins/colorpreview.lua
@@ -1,8 +1,24 @@
-- mod-version:3 --lite-xl 2.1
+local config = require "core.config"
local common = require "core.common"
local DocView = require "core.docview"
+config.plugins.colorpreview = common.merge({
+ enabled = false,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Color Preview",
+ {
+ label = "Enable",
+ description = "Enable or disable the color preview feature.",
+ path = "enabled",
+ type = "toggle",
+ default = false
+ }
+ }
+}, config.plugins.colorpreview)
+
local white = { common.color "#ffffff" }
local black = { common.color "#000000" }
local tmp = {}
@@ -56,8 +72,17 @@ local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(line, x, y)
local lh = draw_line_text(self, line, x, y)
- draw_color_previews(self, line, x, y, "#(%x%x)(%x%x)(%x%x)(%x?%x?)%f[%W]", 16)
- draw_color_previews(self, line, x, y, "#(%x)(%x)(%x)%f[%W]", 16, true) -- support #fff css format
- draw_color_previews(self, line, x, y, "rgba?%((%d+)%D+(%d+)%D+(%d+)[%s,]-([%.%d]-)%s-%)", nil)
+ if config.plugins.colorpreview.enabled then
+ draw_color_previews(self, line, x, y,
+ "#(%x%x)(%x%x)(%x%x)(%x?%x?)%f[%W]",
+ 16
+ )
+ -- support #fff css format
+ draw_color_previews(self, line, x, y, "#(%x)(%x)(%x)%f[%W]", 16, true)
+ draw_color_previews(self, line, x, y,
+ "rgba?%((%d+)%D+(%d+)%D+(%d+)[%s,]-([%.%d]-)%s-%)",
+ nil
+ )
+ end
return lh
end