fix view.window
This commit is contained in:
@@ -93,8 +93,8 @@ end
|
|||||||
function view:exit()
|
function view:exit()
|
||||||
|
|
||||||
-- close window
|
-- close window
|
||||||
if self:window() then
|
if self._WINDOW then
|
||||||
self:window():close()
|
self._WINDOW:close()
|
||||||
self._WINDOW = nil
|
self._WINDOW = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -156,6 +156,15 @@ end
|
|||||||
|
|
||||||
-- get the view window
|
-- get the view window
|
||||||
function view:window()
|
function view:window()
|
||||||
|
if not self._WINDOW then
|
||||||
|
|
||||||
|
-- create window
|
||||||
|
self._WINDOW = curses.new_pad(self:height() > 0 and self:height() or 1, self:width() > 0 and self:width() or 1)
|
||||||
|
assert(self._WINDOW, "cannot create window!")
|
||||||
|
|
||||||
|
-- disable cursor
|
||||||
|
self._WINDOW:leaveok(true)
|
||||||
|
end
|
||||||
return self._WINDOW
|
return self._WINDOW
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -217,21 +226,14 @@ function view:on_resize()
|
|||||||
log:print("%s: resize ..", self)
|
log:print("%s: resize ..", self)
|
||||||
|
|
||||||
-- close the previous windows first
|
-- close the previous windows first
|
||||||
if self:window() then
|
if self._WINDOW then
|
||||||
self:window():close()
|
self._WINDOW:close()
|
||||||
self._WINDOW = nil
|
self._WINDOW = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- need renew canvas
|
-- need renew canvas
|
||||||
self._CANVAS = nil
|
self._CANVAS = nil
|
||||||
|
|
||||||
-- create a new window
|
|
||||||
self._WINDOW = curses.new_pad(self:height() > 0 and self:height() or 1, self:width() > 0 and self:width() or 1)
|
|
||||||
assert(self._WINDOW, "cannot create window!")
|
|
||||||
|
|
||||||
-- disable cursor
|
|
||||||
self:window():leaveok(true)
|
|
||||||
|
|
||||||
-- clear mark
|
-- clear mark
|
||||||
self:state_set("resize", false)
|
self:state_set("resize", false)
|
||||||
|
|
||||||
|
@@ -126,6 +126,7 @@ end
|
|||||||
-- on resize
|
-- on resize
|
||||||
function demo:on_resize()
|
function demo:on_resize()
|
||||||
self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
|
self:dialog_main():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
|
||||||
|
self:dialog_help():bounds_set(rect {1, 1, self:width() - 1, self:height() - 1})
|
||||||
self:center(self:dialog_input(), {centerx = true, centery = true})
|
self:center(self:dialog_input(), {centerx = true, centery = true})
|
||||||
self:center(self:dialog_tips(), {centerx = true, centery = true})
|
self:center(self:dialog_tips(), {centerx = true, centery = true})
|
||||||
application.on_resize(self)
|
application.on_resize(self)
|
||||||
|
Reference in New Issue
Block a user