Skip to content

Commit 72a6478

Browse files
authored
Merge pull request rxi#83 from Guldoman/extend_selection_line
Add `extend_selection_line`
2 parents 44f1494 + dc64ff0 commit 72a6478

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Plugin | Description
3434
[`eval`](plugins/eval.lua?raw=1) | Replaces selected Lua code with its evaluated result
3535
[`exec`](plugins/exec.lua?raw=1) | Runs selected text through shell command and replaces with result
3636
[`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.
37+
*[`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))*
3738
[`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))*
3839
[`fontconfig`](plugins/fontconfig.lua?raw=1) | Allows users to load fonts with [fontconfig](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html).
3940
*[`force_syntax`](plugins/force_syntax.lua?raw=1)* | Change the syntax used for a file.

plugins/extend_selection_line.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- mod-version:2 -- lite-xl 2.0
2+
local DocView = require "core.docview"
3+
local style = require "core.style"
4+
5+
local draw_line_body = DocView.draw_line_body
6+
function DocView:draw_line_body(idx, x, y, ...)
7+
draw_line_body(self, idx, x, y, ...)
8+
local lh = self:get_line_height()
9+
for _, line1, _, line2, _ in self.doc:get_selections(true) do
10+
if idx >= line1 and idx < line2 and line1 ~= line2 then
11+
-- draw selection from the end of the line to the end of the available space
12+
local x1 = x + self:get_col_x_offset(idx, #self.doc.lines[idx])
13+
local x2 = x + self.scroll.x + self.size.x
14+
if x2 > x1 then
15+
renderer.draw_rect(x1, y, x2 - x1, lh, style.selection)
16+
end
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)