diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/selectionhighlight.lua | 13 |
1 files changed, 12 insertions, 1 deletions
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 |