aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-04-30 13:33:09 +0100
committerrxi <rxi@users.noreply.github.com>2020-04-30 13:36:03 +0100
commit6dd61f0c9cc3ee6c4da25f564db36b3458a90532 (patch)
treec414300e3fe9869e5b21ae85635f11302a76ec84
parent00008754892d8ece014fda5abce905eae64ae331 (diff)
downloadlite-xl-plugins-6dd61f0c9cc3ee6c4da25f564db36b3458a90532.tar.gz
lite-xl-plugins-6dd61f0c9cc3ee6c4da25f564db36b3458a90532.zip
Changed selectionhighlight plugin to draw box instead of filled rectangle
-rw-r--r--README.md2
-rw-r--r--plugins/selectionhighlight.lua13
2 files changed, 13 insertions, 2 deletions
diff --git a/README.md b/README.md
index e2ab68e..b7368e5 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ Plugin | Description
[`language_wren`](plugins/language_wren.lua?raw=1) | Syntax for the [Wren](http://wren.io/) programming language
[`linter`](https://github.com/drmargarido/linters)* | Linters for multiple languages
[`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt`
-[`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection
+[`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | [Highlights](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png) regions of code that match the current selection
[`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically
[`spellcheck`](plugins/spellcheck.lua?raw=1) | [Underlines](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png) misspelt words
[`theme16`](https://github.com/monolifed/theme16)* | Theme manager with base16 themes
diff --git a/plugins/selectionhighlight.lua b/plugins/selectionhighlight.lua
index 31a5042..5404ce7 100644
--- a/plugins/selectionhighlight.lua
+++ b/plugins/selectionhighlight.lua
@@ -3,6 +3,16 @@ local DocView = require "core.docview"
-- originally written by luveti
+local function draw_box(x, y, w, h, color)
+ local r = renderer.draw_rect
+ local s = math.ceil(SCALE)
+ r(x, y, w, s, color)
+ r(x, y + h - s, w, s, color)
+ r(x, y + s, s, h - s * 2, color)
+ r(x + w - s, y + s, s, h - s * 2, color)
+end
+
+
local draw_line_body = DocView.draw_line_body
function DocView:draw_line_body(idx, x, y)
@@ -17,7 +27,8 @@ function DocView:draw_line_body(idx, x, y)
if start_col == nil then break end
local x1 = x + self:get_col_x_offset(idx, start_col)
local x2 = x + self:get_col_x_offset(idx, end_col + 1)
- renderer.draw_rect(x1, y, x2 - x1, lh, style.selection)
+ local color = style.selectionhighlight or style.syntax.comment
+ draw_box(x1, y, x2 - x1, lh, color)
last_col = end_col + 1
end
end