From e811c111185d81b9dfb64c9146ef074ee03b8337 Mon Sep 17 00:00:00 2001 From: SwissalpS Date: Fri, 26 Jun 2020 02:52:03 +0200 Subject: toggle whitespace visibility during runtime --- plugins/drawwhitespace.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugins/drawwhitespace.lua') 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, +}) -- cgit v1.2.3