aboutsummaryrefslogtreecommitdiff
path: root/plugins/smallclock.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-03-11 05:14:12 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-22 13:16:10 -0400
commitd14d060f1c52afa0f72f15cdafcc0772474cce79 (patch)
tree329047e4010098f97ab9c42c09cd3e4f2ae40b0f /plugins/smallclock.lua
parent198252c258b3313d941ce9d53c6ed73430bf811d (diff)
downloadlite-xl-plugins-d14d060f1c52afa0f72f15cdafcc0772474cce79.tar.gz
lite-xl-plugins-d14d060f1c52afa0f72f15cdafcc0772474cce79.zip
smallclock: use new StatusView api, removed coroutine
Diffstat (limited to 'plugins/smallclock.lua')
-rw-r--r--plugins/smallclock.lua34
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua
index da13236..201a65a 100644
--- a/plugins/smallclock.lua
+++ b/plugins/smallclock.lua
@@ -1,27 +1,27 @@
-- mod-version:3 --lite-xl 2.1
local core = require "core"
local style = require "core.style"
-local status_view = require "core.statusview"
+local StatusView = require "core.statusview"
local time = ""
-core.add_thread(function()
- while true do
+local last_time = os.time()
+local function update_time()
+ if os.time() > last_time then
local t = os.date("*t")
time = string.format("%02d:%02d", t.hour, t.min)
- coroutine.yield(1)
+ last_time = os.time()
end
-end)
-
-local get_items = status_view.get_items
-
-function status_view:get_items()
- local left, right = get_items(self)
- local t = {style.dim, self.separator2, style.accent, time}
-
- for _, item in ipairs(t) do
- table.insert(right, item)
- end
-
- return left, right
end
+
+core.status_view:add_item(
+ nil,
+ "status:small-clock",
+ StatusView.Item.RIGHT,
+ function()
+ update_time()
+ return {style.accent, time}
+ end,
+ nil,
+ -1
+).separator = core.status_view.separator2