From ea1ac714ac1b52a62bc4692b218cece18107b72a Mon Sep 17 00:00:00 2001 From: jgmdev Date: Fri, 11 Mar 2022 05:17:41 -0400 Subject: memoryusage: use new StatusView api, use two decimals --- plugins/memoryusage.lua | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'plugins/memoryusage.lua') 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 -- cgit v1.2.3