diff options
| author | ruki <[email protected]> | 2017-12-14 00:46:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-12-13 22:39:31 +0800 |
| commit | 42cc615918ee1e4cc3ce435172e9f91dc1df1086 (patch) | |
| tree | 323c0dbb450f137d1b15eb31a0f279dcd2675309 /xmake/core/ui/view.lua | |
| parent | 2694f86469cdd776ba2caba9bcd7ec261457aa2c (diff) | |
fix log and application bug
Diffstat (limited to 'xmake/core/ui/view.lua')
| -rw-r--r-- | xmake/core/ui/view.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/xmake/core/ui/view.lua b/xmake/core/ui/view.lua index 4008ce547..bf7bd8f45 100644 --- a/xmake/core/ui/view.lua +++ b/xmake/core/ui/view.lua @@ -36,23 +36,23 @@ local curses = require("ui/curses") local view = view or object() -- new view instance -function view:new(bounds) +function view:new(name, bounds) -- create instance self = self() -- init view - self:init(bounds) + self:init(name, bounds) -- done return self end -- init view -function view:init(bounds) +function view:init(name, bounds) -- check - assert(type(bounds) == 'table') + assert(name and type(bounds) == 'table') -- init state local state = object() @@ -65,6 +65,9 @@ function view:init(bounds) state.modal = false -- is modal view? self._STATE = state + -- init name + self._NAME = name + -- init bounds and window self:bounds_set(bounds) end @@ -79,6 +82,11 @@ function view:exit() end end +-- get view name +function view:name() + return self._NAME +end + -- set window bounds function view:bounds_set(bounds) @@ -181,5 +189,10 @@ function view:state_set(name, enable) end end +-- tostring(view) +function view:__tostring() + return string.format("<view: %s %s>", self:name(), tostring(self:bounds())) +end + -- return module return view |
