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