aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--plugins/extend_selection_line.lua19
2 files changed, 20 insertions, 0 deletions
diff --git a/README.md b/README.md
index dd7d7fd..115829c 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@ Plugin | Description
[`eval`](plugins/eval.lua?raw=1) | Replaces selected Lua code with its evaluated result
[`exec`](plugins/exec.lua?raw=1) | Runs selected text through shell command and replaces with result
[`ephemeraldocviews`](plugins/ephemeraldocviews.lua?raw=1) | Preview tabs. Opening a doc will replace the contents of the preview tab. Marks tabs as non-preview on any change.
+*[`extend_selection_line`](plugins/extend_selection_line.lua?raw=1)* | When a selection crosses multiple lines, it is drawn to the end of the screen *([screenshot](https://user-images.githubusercontent.com/2798487/140995616-89a20b55-5917-4df8-8a7c-d7c53732fa8b.png))*
[`fallbackfonts`](https://github.com/takase1121/lite-fallback-fonts)* | Adds support for fallback fonts *([gif](https://raw.githubusercontent.com/takase1121/lite-fallback-fonts/master/assets/Iw18fI57J0.gif))*
[`fontconfig`](plugins/fontconfig.lua?raw=1) | Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html).
*[`force_syntax`](plugins/force_syntax.lua?raw=1)* | Change the syntax used for a file.
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