Merge pull request #753 from Jipok/highlight_selection

Add for config.highlight_current_line new variant: no_selection
This commit is contained in:
Adam 2021-12-29 14:43:17 -05:00 committed by GitHub
commit 1552f18a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -13,6 +13,7 @@ config.undo_merge_timeout = 0.3
config.max_undos = 10000
config.max_tabs = 8
config.always_show_tabs = true
-- Possible values: false, true, "no_selection"
config.highlight_current_line = true
config.line_height = 1.2
config.indent_size = 2

View File

@ -331,13 +331,22 @@ end
function DocView:draw_line_body(idx, x, y)
-- draw highlight if any selection ends on this line
local draw_highlight = false
for lidx, line1, col1, line2, col2 in self.doc:get_selections(false) do
if line1 == idx then
draw_highlight = true
break
local hcl = config.highlight_current_line
if hcl ~= false then
for lidx, line1, col1, line2, col2 in self.doc:get_selections(false) do
if line1 == idx then
if hcl == "no_selection" then
if (line1 ~= line2) or (col1 ~= col2) then
draw_highlight = false
break
end
end
draw_highlight = true
break
end
end
end
if draw_highlight and config.highlight_current_line and core.active_view == self then
if draw_highlight and core.active_view == self then
self:draw_line_highlight(x + self.scroll.x, y)
end