aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSwissalpS <Luke@SwissalpS.ws>2020-06-26 02:52:03 +0200
committerSwissalpS <Luke@SwissalpS.ws>2020-06-26 02:52:03 +0200
commite811c111185d81b9dfb64c9146ef074ee03b8337 (patch)
treec15c9024cc12bc251bc7f06489d806f61cab2df8 /plugins
parent76144065f71d08ec5eb0ccc7309d847c871a3d11 (diff)
downloadlite-xl-plugins-e811c111185d81b9dfb64c9146ef074ee03b8337.tar.gz
lite-xl-plugins-e811c111185d81b9dfb64c9146ef074ee03b8337.zip
toggle whitespace visibility during runtime
Diffstat (limited to 'plugins')
-rw-r--r--plugins/drawwhitespace.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/drawwhitespace.lua b/plugins/drawwhitespace.lua
index 016d18c..d595d0a 100644
--- a/plugins/drawwhitespace.lua
+++ b/plugins/drawwhitespace.lua
@@ -1,15 +1,19 @@
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"
+local command = require "core.command"
-- originally written by luveti
config.whitespace_map = { [" "] = "·", ["\t"] = "»" }
+local visible = false
+
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
local text = self.doc.lines[idx]
local tx, ty = x, y + self:get_line_text_y_offset()
@@ -27,3 +31,8 @@ function DocView:draw_line_text(idx, x, y)
end
end
+command.add("core.docview", {
+ ["drawwhitespace:toggle"] = function() visible = not visible end,
+ ["drawwhitespace:no"] = function() visible = false end,
+ ["drawwhitespace:yes"] = function() visible = true end,
+})