lineguide: added config spec
This commit is contained in:
parent
d48fa9ef74
commit
31d2024283
|
@ -14,6 +14,56 @@ config.plugins.lineguide = common.merge({
|
||||||
-- 100,
|
-- 100,
|
||||||
-- 120,
|
-- 120,
|
||||||
config.line_limit
|
config.line_limit
|
||||||
|
},
|
||||||
|
-- The config specification used by gui generators
|
||||||
|
config_spec = {
|
||||||
|
name = "Line Guide",
|
||||||
|
{
|
||||||
|
label = "Enabled",
|
||||||
|
description = "Disable or enable drawing of the line guide.",
|
||||||
|
path = "enabled",
|
||||||
|
type = "toggle",
|
||||||
|
default = true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Width",
|
||||||
|
description = "Width in pixels of the line guide.",
|
||||||
|
path = "width",
|
||||||
|
type = "number",
|
||||||
|
default = 2,
|
||||||
|
min = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Ruler Positions",
|
||||||
|
description = "The different column numbers for the line guides to draw.",
|
||||||
|
path = "rulers",
|
||||||
|
type = "list_strings",
|
||||||
|
default = { tostring(config.line_limit) or "80" },
|
||||||
|
get_value = function(rulers)
|
||||||
|
if type(rulers) == "table" then
|
||||||
|
local new_rulers = {}
|
||||||
|
for _, ruler in ipairs(rulers) do
|
||||||
|
table.insert(new_rulers, tostring(ruler))
|
||||||
|
end
|
||||||
|
return new_rulers
|
||||||
|
else
|
||||||
|
return { tostring(config.line_limit) }
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
set_value = function(rulers)
|
||||||
|
local new_rulers = {}
|
||||||
|
for _, ruler in ipairs(rulers) do
|
||||||
|
local number = tonumber(ruler)
|
||||||
|
if number then
|
||||||
|
table.insert(new_rulers, number)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #new_rulers == 0 then
|
||||||
|
table.insert(new_rulers, config.line_limit)
|
||||||
|
end
|
||||||
|
return new_rulers
|
||||||
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, config.plugins.lineguide)
|
}, config.plugins.lineguide)
|
||||||
|
|
||||||
|
@ -31,7 +81,13 @@ local draw_overlay = DocView.draw_overlay
|
||||||
function DocView:draw_overlay(...)
|
function DocView:draw_overlay(...)
|
||||||
draw_overlay(self, ...)
|
draw_overlay(self, ...)
|
||||||
|
|
||||||
if config.plugins.lineguide.enabled and not self:is(CommandView) then
|
if
|
||||||
|
type(config.plugins.lineguide) == "table"
|
||||||
|
and
|
||||||
|
config.plugins.lineguide.enabled
|
||||||
|
and
|
||||||
|
not self:is(CommandView)
|
||||||
|
then
|
||||||
local line_x = self:get_line_screen_position(1)
|
local line_x = self:get_line_screen_position(1)
|
||||||
local character_width = self:get_font():get_width("n")
|
local character_width = self:get_font():get_width("n")
|
||||||
local ruler_width = config.plugins.lineguide.width
|
local ruler_width = config.plugins.lineguide.width
|
||||||
|
|
Loading…
Reference in New Issue