add config.lineguide option

This commit is contained in:
takase1121 2021-07-10 22:47:03 +08:00
parent 135ad072bd
commit 3b3677ca4b
1 changed files with 11 additions and 9 deletions

View File

@ -6,16 +6,18 @@ local DocView = require "core.docview"
local draw_overlay = DocView.draw_overlay local draw_overlay = DocView.draw_overlay
function DocView:draw_overlay(...) function DocView:draw_overlay(...)
local ns = ("n"):rep(config.line_limit) if config.lineguide then
local ss = self:get_font():subpixel_scale() local ns = self:get_font():get_width_subpixel("n") * config.line_limit
local offset = self:get_font():get_width_subpixel(ns) / ss local ss = self:get_font():subpixel_scale()
local x = self:get_line_screen_position(1) + offset local offset = ns / ss
local y = self.position.y local x = self:get_line_screen_position(1) + offset
local w = math.ceil(SCALE * 1) local y = self.position.y
local h = self.size.y local w = math.ceil(SCALE * 1)
local h = self.size.y
local color = style.guide or style.selection local color = style.guide or style.selection
renderer.draw_rect(x, y, w, h, color) renderer.draw_rect(x, y, w, h, color)
end
draw_overlay(self, ...) draw_overlay(self, ...)
end end