aboutsummaryrefslogtreecommitdiff
path: root/plugins/extend_selection_line.lua
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-12-05 14:46:16 -0500
committerGitHub <noreply@github.com>2021-12-05 14:46:16 -0500
commitb4d44e207122130013dcbddd60635ab89ad8b692 (patch)
treea539c45c85588f74f824fe45e6f214c4acb5bbef /plugins/extend_selection_line.lua
parent1e063c95f0bd51934cff752af653964c6aa80c0c (diff)
parent72a6478e15f22b284636fb97f219ced74a07764f (diff)
downloadlite-xl-plugins-b4d44e207122130013dcbddd60635ab89ad8b692.tar.gz
lite-xl-plugins-b4d44e207122130013dcbddd60635ab89ad8b692.zip
Merge branch 'master' into immersive-title
Diffstat (limited to 'plugins/extend_selection_line.lua')
-rw-r--r--plugins/extend_selection_line.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/extend_selection_line.lua b/plugins/extend_selection_line.lua
new file mode 100644
index 0000000..e986597
--- /dev/null
+++ b/plugins/extend_selection_line.lua
@@ -0,0 +1,19 @@
+-- mod-version:2 -- lite-xl 2.0
+local DocView = require "core.docview"
+local style = require "core.style"
+
+local draw_line_body = DocView.draw_line_body
+function DocView:draw_line_body(idx, x, y, ...)
+ draw_line_body(self, idx, x, y, ...)
+ local lh = self:get_line_height()
+ for _, line1, _, line2, _ in self.doc:get_selections(true) do
+ if idx >= line1 and idx < line2 and line1 ~= line2 then
+ -- draw selection from the end of the line to the end of the available space
+ local x1 = x + self:get_col_x_offset(idx, #self.doc.lines[idx])
+ local x2 = x + self.scroll.x + self.size.x
+ if x2 > x1 then
+ renderer.draw_rect(x1, y, x2 - x1, lh, style.selection)
+ end
+ end
+ end
+end