From 4dc6062043cd13964a30c4c697d4ba9acb053c51 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Wed, 27 Feb 2019 08:10:09 -0500 Subject: [PATCH] cleanup --- sys/apis/ui.lua | 1 - sys/apis/ui/components/Text.lua | 7 ++++++- sys/apps/Tasks.lua | 19 ++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 361484d..712b600 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -263,7 +263,6 @@ function Manager:click(target, code, button, x, y) if clickEvent.element.focus then target:setFocus(clickEvent.element) end -_G._p = clickEvent self:inputEvent(clickEvent.element, clickEvent) target:sync() diff --git a/sys/apis/ui/components/Text.lua b/sys/apis/ui/components/Text.lua index 96310ec..186bd58 100644 --- a/sys/apis/ui/components/Text.lua +++ b/sys/apis/ui/components/Text.lua @@ -16,5 +16,10 @@ function UI.Text:setParent() end function UI.Text:draw() - self:write(1, 1, Util.widthify(self.value or '', self.width), self.backgroundColor) + if self.align and self.align == 'center' then + self:clear() + self:centeredWrite(1, self.value or '') + else + self:write(1, 1, Util.widthify(self.value or '', self.width)) + end end diff --git a/sys/apps/Tasks.lua b/sys/apps/Tasks.lua index 5bcd043..9b35be2 100644 --- a/sys/apps/Tasks.lua +++ b/sys/apps/Tasks.lua @@ -1,8 +1,5 @@ -_G.requireInjector(_ENV) - local Event = require('event') local UI = require('ui') -local Util = require('util') local kernel = _G.kernel local multishell = _ENV.multishell @@ -51,15 +48,15 @@ function page:eventHandler(event) end function page.grid:getDisplayValues(row) - row = Util.shallowCopy(row) local elapsed = os.clock()-row.timestamp - if elapsed < 60 then - row.timestamp = string.format("%ds", math.floor(elapsed)) - else - row.timestamp = string.format("%sm", math.floor(elapsed/6)/10) - end - row.status = row.isDead and 'error' or coroutine.status(row.co) - return row + return { + uid = row.uid, + title = row.title, + status = row.isDead and 'error' or coroutine.status(row.co), + timestamp = elapsed < 60 and + string.format("%ds", math.floor(elapsed)) or + string.format("%sm", math.floor(elapsed/6)/10), + } end Event.onInterval(1, function()