diff options
author | jgmdev <jgmdev@gmail.com> | 2022-05-24 19:29:50 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-05-24 19:29:50 -0400 |
commit | 35e947d1933613bb0b5a1488bf0fa4587f98ef7d (patch) | |
tree | 07d2515f44db03b1e865f6aef6adfd12b118890b /plugins/smoothcaret.lua | |
parent | c1f3671e2a8defbc67d1e77c72d5866f2825cdb5 (diff) | |
download | lite-xl-plugins-35e947d1933613bb0b5a1488bf0fa4587f98ef7d.tar.gz lite-xl-plugins-35e947d1933613bb0b5a1488bf0fa4587f98ef7d.zip |
added config_spec and other plugin compatibility fixes.
Diffstat (limited to 'plugins/smoothcaret.lua')
-rw-r--r-- | plugins/smoothcaret.lua | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/plugins/smoothcaret.lua b/plugins/smoothcaret.lua index 75ee769..3a30d5b 100644 --- a/plugins/smoothcaret.lua +++ b/plugins/smoothcaret.lua @@ -5,12 +5,38 @@ local style = require "core.style" local common = require "core.common" local DocView = require "core.docview" -config.plugins.smoothcaret = common.merge({ rate = 0.65 }, config.plugins.smoothcaret) +config.plugins.smoothcaret = common.merge({ + enabled = true, + rate = 0.65, + -- The config specification used by the settings gui + config_spec = { + name = "Smooth Caret", + { + label = "Enabled", + description = "Disable or enable the smooth caret animation.", + path = "enabled", + type = "toggle", + default = true + }, + { + label = "Rate", + description = "Speed of the animation.", + path = "rate", + type = "number", + default = 0.65, + min = 0.2, + max = 1.0, + step = 0.05 + }, + } +}, config.plugins.smoothcaret) local docview_update = DocView.update function DocView:update() docview_update(self) + if not config.plugins.smoothcaret.enabled then return end + local minline, maxline = self:get_visible_line_range() -- We need to keep track of all the carets @@ -73,7 +99,13 @@ function DocView:update() self.caret_idx = 1 end +local docview_draw_caret = DocView.draw_caret function DocView:draw_caret(x, y) + if not config.plugins.smoothcaret.enabled then + docview_draw_caret(self, x, y) + return + end + local c = self.visible_carets[self.caret_idx] or { current = { x = x, y = y } } local lh = self:get_line_height() |