aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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