From 17441837e8e9e2f400794fde0f6473ba10ea288f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 28 Jan 2021 16:33:25 +0800 Subject: status --- script/service/service.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'script/service/service.lua') diff --git a/script/service/service.lua b/script/service/service.lua index 1fcfa340..67de4818 100644 --- a/script/service/service.lua +++ b/script/service/service.lua @@ -5,6 +5,7 @@ local timer = require 'timer' local proto = require 'proto' local vm = require 'vm' local util = require 'utility' +local files = require 'files' local m = {} m.type = 'service' @@ -137,14 +138,33 @@ function m.startTimer() while true do pub.step() if await.step() then + m.working = true goto CONTINUE end + m.working = false thread.sleep(0.001) ::CONTINUE:: timer.update() end end +function m.reportStatus() + timer.loop(0.1, function () + local info = {} + if m.working then + info.text = '$(loading~spin)Lua' + else + info.text = 'Lua' + end + info.tooltip = ('已缓存文件:%d/%d\n内存占用:%.fM'):format( + files.astCount, + files.fileCount, + collectgarbage('count') / 1000 + ) + proto.notify('$/status', info) + end)() +end + function m.testVersion() local stack = debug.setcstacklimit(200) debug.setcstacklimit(stack + 1) @@ -162,6 +182,7 @@ function m.start() pub.recruitBraves(4) proto.listen() m.report() + m.reportStatus() m.testVersion() require 'provider' -- cgit v1.2.3