aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco <francesco.bbt@gmail.com>2021-03-14 16:37:39 +0100
committerGitHub <noreply@github.com>2021-03-14 16:37:39 +0100
commit54b03a2e7f9baa342e1182b0e695233fc1c24c41 (patch)
treeebd3162edc8eec704e2a1aa5a22127367b081c2d
parentf239216c2f0dbc087d4c7701732399258ed2011a (diff)
parent2685b05692e6fc40490c3118a992de1b18ee3856 (diff)
downloadlite-xl-plugins-54b03a2e7f9baa342e1182b0e695233fc1c24c41.tar.gz
lite-xl-plugins-54b03a2e7f9baa342e1182b0e695233fc1c24c41.zip
Merge pull request #2 from franko/lqdev-plugin-patches
Plugin patches
-rw-r--r--README.md6
-rw-r--r--plugins/indentguide.lua10
-rw-r--r--plugins/lineguide.lua4
3 files changed, 14 insertions, 6 deletions
diff --git a/README.md b/README.md
index 2a966b6..0099aa7 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,12 @@
-Plugins for the [lite text editor](https://github.com/rxi/lite) adapted for [lite-xl](https://github.com/franko/lite-xl)
+Plugins for [Lite XL](https://github.com/franko/lite-xl)
*Note: if you make a pull request, the table should be updated and kept in
alphabetical order. If your plugin is large (or you'd otherwise prefer it to
have its own repo), the table can simply be updated to add a link to the repo;
otherwise the plugin file itself can be submitted. If a plugin's link resolves
-to something other than a raw file it should be marked with an asterisk.*
+to something other than a raw file it should be marked with an asterisk.
+If a plugin has modifications specific to Lite XL or is otherwise incompatible
+with the official version of lite, format the name in italic.*
---
diff --git a/plugins/indentguide.lua b/plugins/indentguide.lua
index daf7d8b..db57f9e 100644
--- a/plugins/indentguide.lua
+++ b/plugins/indentguide.lua
@@ -34,12 +34,16 @@ local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(idx, x, y)
local spaces = get_line_indent_guide_spaces(self.doc, idx)
- local sw = self:get_font():get_width(" ")
local w = math.ceil(1 * SCALE)
local h = self:get_line_height()
- for i = 0, spaces - 1, config.indent_size do
+ local sspaces = ""
+ local font = self:get_font()
+ local ss = font:subpixel_scale()
+ for _ = 0, spaces - 1, config.indent_size do
local color = style.guide or style.selection
- renderer.draw_rect(x + sw * i, y, w, h, color)
+ local sw = font:get_width_subpixel(sspaces) / ss
+ renderer.draw_rect(x + sw, y, w, h, color)
+ sspaces = sspaces .. (' '):rep(config.indent_size)
end
draw_line_text(self, idx, x, y)
end
diff --git a/plugins/lineguide.lua b/plugins/lineguide.lua
index fc24567..7669c52 100644
--- a/plugins/lineguide.lua
+++ b/plugins/lineguide.lua
@@ -7,7 +7,9 @@ local draw = DocView.draw
function DocView:draw(...)
draw(self, ...)
- local offset = self:get_font():get_width("n") * config.line_limit
+ local ns = ("n"):rep(config.line_limit)
+ local ss = self:get_font():subpixel_scale()
+ local offset = self:get_font():get_width_subpixel(ns) / ss
local x = self:get_line_screen_position(1) + offset
local y = self.position.y
local w = math.ceil(SCALE * 1)