aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGuldoman <giulio.lettieri@gmail.com>2021-11-09 21:26:14 +0100
committerGuldoman <giulio.lettieri@gmail.com>2021-11-09 21:26:14 +0100
commitfdc04ae0c45c48a900eedc8aa08d0021232b3c0a (patch)
treefe3e39bd597e708cdd2159741120d361467bbb80 /plugins
parent911d14ed38a5f96ec2175d4adbc1f8290fd61a32 (diff)
downloadlite-xl-plugins-fdc04ae0c45c48a900eedc8aa08d0021232b3c0a.tar.gz
lite-xl-plugins-fdc04ae0c45c48a900eedc8aa08d0021232b3c0a.zip
Add `extend_selection_line`
Diffstat (limited to 'plugins')
-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..a780fe0
--- /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, ...)
+ 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
+ draw_line_body(self, idx, x, y, ...)
+end