diff options
| author | ruki <[email protected]> | 2017-12-16 00:57:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-15 23:44:19 +0800 |
| commit | e5ed897840214b66fd746292fff15c56606d3251 (patch) | |
| tree | 6a5820bfcb1acf95536b673cd79587aff198dab5 /xmake/core/ui/statusbar.lua | |
| parent | d81f894af27987981ef3fe39e013ad3f1fadfbcf (diff) | |
add event to ui
Diffstat (limited to 'xmake/core/ui/statusbar.lua')
| -rw-r--r-- | xmake/core/ui/statusbar.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/xmake/core/ui/statusbar.lua b/xmake/core/ui/statusbar.lua index bd61c2f91..fbdc46ff8 100644 --- a/xmake/core/ui/statusbar.lua +++ b/xmake/core/ui/statusbar.lua @@ -28,14 +28,21 @@ $Id: statusbar.lua 18 2007-06-21 20:43:52Z tngd $ --------------------------------------------------------------------------]] -- load modules -local view = require("ui/view") +local view = require("ui/view") +local curses = require("ui/curses") -- define module local statusbar = statusbar or view() -- init statusbar function statusbar:init(name, bounds) + + -- init view view.init(self, name, bounds) + + -- init attributes + self:attr_set("key", curses.color_pair("red", "white")) + self:attr_set("text", curses.color_pair("black", "white")) end -- exit statusbar @@ -43,5 +50,26 @@ function statusbar:exit() view.exit(self) end +-- draw view +function statusbar:draw() + + -- get canvas + local c = self:canvas() + c:move(0, 0) + + -- draw status + local x = 0 + local kattr = self:attr("key") + local tattr = self:attr("text") + if x < self:width() then + c:attr(tattr):write(string.rep(' ', self:width() - x)) + end +end + +-- do event +function statusbar:do_event(e) + view.do_event(self, e) +end + -- return module return statusbar |
