diff options
author | jgmdev <jgmdev@gmail.com> | 2022-03-11 05:17:41 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-05-22 13:16:10 -0400 |
commit | ea1ac714ac1b52a62bc4692b218cece18107b72a (patch) | |
tree | 56f1a5e7c7a4c19c6d0343b53591ff540f4d1209 | |
parent | 2d3b785cd8bf7398cd6c72cfa6d35c34a3e9e396 (diff) | |
download | lite-xl-plugins-ea1ac714ac1b52a62bc4692b218cece18107b72a.tar.gz lite-xl-plugins-ea1ac714ac1b52a62bc4692b218cece18107b72a.zip |
memoryusage: use new StatusView api, use two decimals
-rw-r--r-- | plugins/memoryusage.lua | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/plugins/memoryusage.lua b/plugins/memoryusage.lua index 1305d62..e06b883 100644 --- a/plugins/memoryusage.lua +++ b/plugins/memoryusage.lua @@ -1,19 +1,24 @@ -- mod-version:3 --lite-xl 2.1 -- original implementation by AqilCont +local core = require "core" local style = require "core.style" local StatusView = require "core.statusview" -local get_items = StatusView.get_items - -function StatusView:get_items() - local left, right = get_items(self) - local t = { - style.text, (math.floor(collectgarbage("count") / 10.24) / 100) .. " MB", - style.dim, self.separator2, - } - for i, item in ipairs(t) do - table.insert(right, i, item) - end - return left, right -end +core.status_view:add_item( + nil, + "status:memory-usage", + StatusView.Item.RIGHT, + function() + return { + style.text, + string.format( + "%.2f MB", + (math.floor(collectgarbage("count") / 10.24) / 100) + ) + } + end, + nil, + 1, + "lua memory usage" +).separator = core.status_view.separator2 |