Move gutter width calculation out of loop
This commit is contained in:
parent
4ad353eb4b
commit
135ad072bd
|
@ -112,7 +112,8 @@ end
|
||||||
|
|
||||||
|
|
||||||
function DocView:get_gutter_width()
|
function DocView:get_gutter_width()
|
||||||
return self:get_font():get_width(#self.doc.lines) + style.padding.x * 2
|
local padding = style.padding.x * 2
|
||||||
|
return self:get_font():get_width(#self.doc.lines) + padding, padding
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,7 +382,7 @@ function DocView:draw_line_body(idx, x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function DocView:draw_line_gutter(idx, x, y)
|
function DocView:draw_line_gutter(idx, x, y, width)
|
||||||
local color = style.line_number
|
local color = style.line_number
|
||||||
for _, line1, _, line2 in self.doc:get_selections(true) do
|
for _, line1, _, line2 in self.doc:get_selections(true) do
|
||||||
if idx >= line1 and idx <= line2 then
|
if idx >= line1 and idx <= line2 then
|
||||||
|
@ -391,7 +392,6 @@ function DocView:draw_line_gutter(idx, x, y)
|
||||||
end
|
end
|
||||||
local yoffset = self:get_line_text_y_offset()
|
local yoffset = self:get_line_text_y_offset()
|
||||||
x = x + style.padding.x
|
x = x + style.padding.x
|
||||||
local width = local width = self:get_font():get_width(#self.doc.lines)
|
|
||||||
common.draw_text(self:get_font(), color, idx, "right", x, y + yoffset, width, self:get_line_height())
|
common.draw_text(self:get_font(), color, idx, "right", x, y + yoffset, width, self:get_line_height())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -421,12 +421,12 @@ function DocView:draw()
|
||||||
local lh = self:get_line_height()
|
local lh = self:get_line_height()
|
||||||
|
|
||||||
local x, y = self:get_line_screen_position(minline)
|
local x, y = self:get_line_screen_position(minline)
|
||||||
|
local gw, gpad = self:get_gutter_width()
|
||||||
for i = minline, maxline do
|
for i = minline, maxline do
|
||||||
self:draw_line_gutter(i, self.position.x, y)
|
self:draw_line_gutter(i, self.position.x, y, gpad and gw - gpad or gw)
|
||||||
y = y + lh
|
y = y + lh
|
||||||
end
|
end
|
||||||
|
|
||||||
local gw = self:get_gutter_width()
|
|
||||||
local pos = self.position
|
local pos = self.position
|
||||||
x, y = self:get_line_screen_position(minline)
|
x, y = self:get_line_screen_position(minline)
|
||||||
core.push_clip_rect(pos.x + gw, pos.y, self.size.x, self.size.y)
|
core.push_clip_rect(pos.x + gw, pos.y, self.size.x, self.size.y)
|
||||||
|
|
Loading…
Reference in New Issue