2021-04-11 08:20:41 +00:00
|
|
|
local FunctionComponent = require('lualine.component'):new()
|
|
|
|
|
2021-08-08 16:03:58 +00:00
|
|
|
FunctionComponent.update_status = function(self, is_focused)
|
2021-04-13 17:09:01 +00:00
|
|
|
-- 1st element in options table is the function provided by config
|
2021-09-03 12:19:00 +00:00
|
|
|
local ok, retval
|
|
|
|
ok, retval = pcall(self.options[1], self, is_focused)
|
2021-09-03 18:28:20 +00:00
|
|
|
if not ok then
|
|
|
|
return ''
|
|
|
|
end
|
2021-09-03 12:19:00 +00:00
|
|
|
if type(retval) ~= 'string' then
|
|
|
|
ok, retval = pcall(tostring, retval)
|
2021-09-03 18:28:20 +00:00
|
|
|
if not ok then
|
|
|
|
return ''
|
|
|
|
end
|
2021-09-03 12:19:00 +00:00
|
|
|
end
|
|
|
|
return retval
|
2021-04-11 08:20:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return FunctionComponent
|