Added StatusView:get_items()

This commit is contained in:
rxi 2020-05-03 18:47:55 +01:00
parent 844dced7cd
commit d5ffee51ff

View file

@ -79,12 +79,13 @@ function StatusView:draw_items(items, right_align, yoffset)
end end
local function draw_for_doc_view(self, x, y) function StatusView:get_items()
if getmetatable(core.active_view) == DocView then
local dv = core.active_view local dv = core.active_view
local line, col = dv.doc:get_selection() local line, col = dv.doc:get_selection()
local dirty = dv.doc:is_dirty() local dirty = dv.doc:is_dirty()
self:draw_items { return {
dirty and style.accent or style.text, style.icon_font, "f", dirty and style.accent or style.text, style.icon_font, "f",
style.dim, style.font, separator2, style.text, style.dim, style.font, separator2, style.text,
dv.doc.filename and style.text or style.dim, dv.doc:get_name(), dv.doc.filename and style.text or style.dim, dv.doc:get_name(),
@ -96,15 +97,21 @@ local function draw_for_doc_view(self, x, y)
style.text, style.text,
separator, separator,
string.format("%d%%", line / #dv.doc.lines * 100), string.format("%d%%", line / #dv.doc.lines * 100),
} }, {
self:draw_items({
style.icon_font, "g", style.icon_font, "g",
style.font, style.dim, separator2, style.text, style.font, style.dim, separator2, style.text,
#dv.doc.lines, " lines", #dv.doc.lines, " lines",
separator, separator,
dv.doc.crlf and "CRLF" or "LF" dv.doc.crlf and "CRLF" or "LF"
}, true) }
end
return {}, {
style.icon_font, "g",
style.font, style.dim, separator2,
#core.docs, style.text, " / ",
#core.project_files, " files"
}
end end
@ -115,16 +122,9 @@ function StatusView:draw()
self:draw_items(self.message, false, self.size.y) self:draw_items(self.message, false, self.size.y)
end end
if getmetatable(core.active_view) == DocView then local left, right = self:get_items()
draw_for_doc_view(self) self:draw_items(left)
else self:draw_items(right, true)
self:draw_items({
style.icon_font, "g",
style.font, style.dim, separator2,
#core.docs, style.text, " / ",
#core.project_files, " files"
}, true)
end
end end