summaryrefslogtreecommitdiff
path: root/xmake/core/ui/program.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-12-22 00:51:41 +0800
committerruki <[email protected]>2017-12-21 23:10:09 +0800
commitfe6f634879645e86609dfb014bab5546bfe0e7fc (patch)
tree5c0c436390c8bc7aa3f209558b1f155d3f0a71a8 /xmake/core/ui/program.lua
parentbf0ea773b29ca4a85430dcb5ab024ed27a8eeb0c (diff)
rewrite refresh view
Diffstat (limited to 'xmake/core/ui/program.lua')
-rw-r--r--xmake/core/ui/program.lua58
1 files changed, 56 insertions, 2 deletions
diff --git a/xmake/core/ui/program.lua b/xmake/core/ui/program.lua
index af3cb09bf..8d30903c0 100644
--- a/xmake/core/ui/program.lua
+++ b/xmake/core/ui/program.lua
@@ -28,6 +28,7 @@ $Id: program.lua 18 2007-06-21 20:43:52Z tngd $
--------------------------------------------------------------------------]]
-- load modules
+local log = require("ui/log")
local rect = require("ui/rect")
local group = require("ui/group")
local event = require("ui/event")
@@ -147,8 +148,61 @@ function program:loop(argv)
-- save the current arguments
self._ARGV = argv
- -- execute group
- self:execute()
+ -- do message loop
+ local e = nil
+ local sleep = true
+ while true do
+
+ -- get the current event
+ e = self:event()
+
+ -- do event
+ if e then
+ self:event_on(e)
+ sleep = false
+ else
+ -- do idle event
+ self:event_on(event.idle())
+ end
+
+ -- draw views
+ self:draw()
+
+ -- refresh views
+ self:refresh()
+
+ -- wait some time, 50ms
+ if sleep then
+ curses.napms(50)
+ end
+ end
+end
+
+-- refresh program
+function program:refresh()
+
+ -- need not refresh? do not refresh it
+ if not self:state("refresh") then
+ return
+ end
+
+ -- refresh views
+ group.refresh(self)
+
+ -- trace
+ log:print("%s: refresh ..", self)
+
+ -- get main window
+ local main_window = curses.main_window()
+
+ -- refresh main window
+ self:window():copy(main_window, 0, 0, 0, 0, self:height() - 1, self:width() - 1)
+
+ -- mark as refresh
+ main_window:noutrefresh()
+
+ -- do update
+ curses.doupdate()
end
-- get key map