aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-12-05 14:45:37 -0500
committerGitHub <noreply@github.com>2021-12-05 14:45:37 -0500
commit72a6478e15f22b284636fb97f219ced74a07764f (patch)
treefcd1f35dd04ef46907b4c1ad317f2f58091fc877
parent44f1494b013687c8c6430c3d4564dbd1c2fba64d (diff)
parentdc64ff09521cf98a9adc44be8c5a019d62e7aa17 (diff)
downloadlite-xl-plugins-72a6478e15f22b284636fb97f219ced74a07764f.tar.gz
lite-xl-plugins-72a6478e15f22b284636fb97f219ced74a07764f.zip
Merge pull request #83 from Guldoman/extend_selection_line
Add `extend_selection_line`
-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