aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-11-23 16:05:42 -0500
committerGitHub <noreply@github.com>2021-11-23 16:05:42 -0500
commit244219302ea740584a0f92b7c7370cf9066b07ef (patch)
tree5203408d84574a1cf0719ed1ffdd29e234e7ebac /plugins
parentbc0a289a79294445de9b0001bdaada93d801dadd (diff)
parenta6e752d1eba6217d8a2f4cac3d170db39e37d713 (diff)
downloadlite-xl-plugins-244219302ea740584a0f92b7c7370cf9066b07ef.tar.gz
lite-xl-plugins-244219302ea740584a0f92b7c7370cf9066b07ef.zip
Merge pull request #81 from takase1121/smoothcaret
add smoothcaret.lua
Diffstat (limited to 'plugins')
-rw-r--r--plugins/smoothcaret.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/smoothcaret.lua b/plugins/smoothcaret.lua
new file mode 100644
index 0000000..26f7d98
--- /dev/null
+++ b/plugins/smoothcaret.lua
@@ -0,0 +1,26 @@
+-- mod-version:2 -- lite-xl 2.0
+local config = require "core.config"
+local style = require "core.style"
+local DocView = require "core.docview"
+
+config.plugins.smoothcaret = { rate = 0.65 }
+
+local docview_update = DocView.update
+function DocView:update()
+ docview_update(self)
+
+ if not self.caret then
+ self.caret = { current = { x = 0, y = 0 }, target = { x = 0, y = 0 } }
+ end
+ local c = self.caret
+ self:move_towards(c.current, "x", c.target.x, config.plugins.smoothcaret.rate)
+ self:move_towards(c.current, "y", c.target.y, config.plugins.smoothcaret.rate)
+end
+
+function DocView:draw_caret(x, y)
+ local c = self.caret
+ local lh = self:get_line_height()
+ c.target.x = x
+ c.target.y = y
+ renderer.draw_rect(c.current.x, c.current.y, style.caret_width, lh, style.caret)
+end