diff options
author | rxi <rxi@users.noreply.github.com> | 2020-04-29 08:57:36 +0100 |
---|---|---|
committer | rxi <rxi@users.noreply.github.com> | 2020-04-29 08:57:36 +0100 |
commit | 0ae27c601aa3dbf72fda3048061bed8ba89f1607 (patch) | |
tree | 5d3faa2453364839c3e24a657ebdb991aa987735 /plugins | |
parent | 83b5b6d5dac4c6250de1ce0c68018d26bffd634d (diff) | |
download | lite-xl-plugins-0ae27c601aa3dbf72fda3048061bed8ba89f1607.tar.gz lite-xl-plugins-0ae27c601aa3dbf72fda3048061bed8ba89f1607.zip |
Added `drawwhitespace` plugin
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/drawwhitespace.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/drawwhitespace.lua b/plugins/drawwhitespace.lua new file mode 100644 index 0000000..b121833 --- /dev/null +++ b/plugins/drawwhitespace.lua @@ -0,0 +1,29 @@ +local config = require "core.config" +local style = require "core.style" +local DocView = require "core.docview" + +-- originally written by luveti + +config.whitespace_map = { [" "] = "·", ["\t"] = "»" } + +local draw_line_text = DocView.draw_line_text + +function DocView:draw_line_text(idx, x, y) + draw_line_text(self, idx, x, y) + + local cl = self:get_cached_line(idx) + local tx, ty = x, y + self:get_line_text_y_offset() + local font = self:get_font() + local color = style.whitespace or style.syntax.comment + local map = config.whitespace_map + + for i = 1, #cl.text do + local chr = cl.text:sub(i, i) + local rep = map[chr] + if rep then + renderer.draw_text(font, rep, tx, ty, color) + end + tx = tx + font:get_width(chr) + end +end + |