Little code refactor

This commit is contained in:
Insality 2020-01-30 02:00:01 +03:00
parent b5686af391
commit 32bbddb706
4 changed files with 12 additions and 3 deletions

View File

@ -5,6 +5,7 @@ local const = require("druid.const")
local M = {}
--- Return number with zero number prefix
-- @function formats.add_prefix_zeros
-- @tparam number num Number for conversion
@ -13,7 +14,7 @@ local M = {}
function M.add_prefix_zeros(num, count)
local result = tostring(num)
for i = string.len(result), count - 1 do
result = const.ZERO..result
result = const.ZERO .. result
end
return result
end

View File

@ -16,8 +16,8 @@ function instance.get_style(self)
end
function instance.set_style(self, component_style)
self._meta.style = component_style
function instance.set_style(self, druid_style)
self._meta.style = druid_style
end

View File

@ -1,10 +1,16 @@
local const = require("druid.const")
local druid_input = require("druid.helper.druid_input")
local settings = require("druid.system.settings")
local M = {}
local function input_init(self)
-- TODO: To custom settings
if not settings.auto_focus_gain then
return
end
if not self.input_inited then
self.input_inited = true
druid_input.focus()
@ -16,6 +22,7 @@ end
local function create(self, module)
---@class component
local instance = setmetatable({}, { __index = module })
-- Component context, self from component creation
instance:setup_component(self._context, self._style)

View File

@ -5,6 +5,7 @@ local M = {}
M.is_debug = false
M.default_style = nil
M.auto_focus_gain = true
function M.get_text(name)