aboutsummaryrefslogtreecommitdiff
path: root/plugins/drawwhitespace.lua
diff options
context:
space:
mode:
authorSwissalpS <Luke@SwissalpS.ws>2020-06-27 12:41:57 +0200
committerSwissalpS <Luke@SwissalpS.ws>2020-06-27 12:41:57 +0200
commit50592bcd3a5e241160ebb67fe8b9c6a711fcc8a1 (patch)
treefa9fc382657a336ce82dc07cc815d3ed130ae509 /plugins/drawwhitespace.lua
parent3d9c5d596f1aa5c555e3e31a5c4c467382832811 (diff)
downloadlite-xl-plugins-50592bcd3a5e241160ebb67fe8b9c6a711fcc8a1.tar.gz
lite-xl-plugins-50592bcd3a5e241160ebb67fe8b9c6a711fcc8a1.zip
put flag in config
this way users can override the default setting in project file and/or user space.
Diffstat (limited to 'plugins/drawwhitespace.lua')
-rw-r--r--plugins/drawwhitespace.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/drawwhitespace.lua b/plugins/drawwhitespace.lua
index 656a15d..8441d68 100644
--- a/plugins/drawwhitespace.lua
+++ b/plugins/drawwhitespace.lua
@@ -6,14 +6,15 @@ local command = require "core.command"
-- originally written by luveti
config.whitespace_map = { [" "] = "·", ["\t"] = "»" }
-
-local visible = true
+config.draw_whitespace = true
local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(idx, x, y)
draw_line_text(self, idx, x, y)
- if not visible then return end
+
+ --if not visible then return end
+ if not config.draw_whitespace then return end
local text = self.doc.lines[idx]
local tx, ty = x, y + self:get_line_text_y_offset()
@@ -32,7 +33,7 @@ function DocView:draw_line_text(idx, x, y)
end
command.add("core.docview", {
- ["drawwhitespace:toggle"] = function() visible = not visible end,
- ["drawwhitespace:disable"] = function() visible = false end,
- ["drawwhitespace:enable"] = function() visible = true end,
+ ["drawwhitespace:toggle"] = function() config.draw_whitespace = not config.draw_whitespace end,
+ ["drawwhitespace:no"] = function() config.draw_whitespace = false end,
+ ["drawwhitespace:yes"] = function() config.draw_whitespace = true end,
})