1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-- mod-version:3
-- original implementation by AqilCont
local core = require "core"
local config = require "core.config"
local common = require "core.common"
local style = require "core.style"
local StatusView = require "core.statusview"
config.plugins.memoryusage = common.merge({
enabled = true,
-- The config specification used by the settings gui
config_spec = {
name = "Memory Usage",
{
label = "Enabled",
description = "Show or hide the lua memory usage from the status bar.",
path = "enabled",
type = "toggle",
default = true,
on_apply = function(enabled)
core.add_thread(function()
if enabled then
core.status_view:get_item("status:memory-usage"):show()
else
core.status_view:get_item("status:memory-usage"):hide()
end
end)
end
}
}
}, config.plugins.memoryusage)
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
|