summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-16 15:35:31 +0800
committerruki <[email protected]>2017-08-16 15:35:31 +0800
commit19a8933bcbbd3513916ad3d0ec67ebf1bb8b88ec (patch)
tree91ca398588dc6d70efaba0ee33f2dc37c9dc3ac6
parent1801533d6ec2b2f981c58bf1a5a5e4aea56d633a (diff)
fix require print info
-rw-r--r--xmake/actions/require/action/download.lua17
-rw-r--r--xmake/actions/require/install.lua1
-rw-r--r--xmake/core/base/process.lua5
-rw-r--r--xmake/core/sandbox/modules/os.lua1
-rw-r--r--xmake/core/sandbox/modules/utils.lua6
5 files changed, 21 insertions, 9 deletions
diff --git a/xmake/actions/require/action/download.lua b/xmake/actions/require/action/download.lua
index cfc41706f..1b32b6ec4 100644
--- a/xmake/actions/require/action/download.lua
+++ b/xmake/actions/require/action/download.lua
@@ -30,7 +30,16 @@ import("utils.archive")
-- empty chars
function _emptychars()
- return " "
+
+ -- get left width
+ local width = os.getwinsize()["width"] or 64
+
+ -- make empty chars
+ local emptychars = ""
+ for i = 1, width do
+ emptychars = emptychars .. " "
+ end
+ return emptychars
end
-- checkout codes from git
@@ -70,7 +79,8 @@ function _checkout(package, url, sourcedir)
os.mv(sourcedir .. ".tmp", sourcedir)
-- trace
- cprint("\r${yellow} => ${clear}clone %s %s .. ${green}ok%s", url, package:version_str(), _emptychars())
+ printf("\r" .. _emptychars())
+ cprint("\r${yellow} => ${clear}clone %s %s .. ${green}ok", url, package:version_str())
end
-- download codes from ftp/http/https
@@ -104,7 +114,8 @@ function _download(package, url, sourcedir)
os.mv(sourcedir .. ".tmp", sourcedir)
-- trace
- cprint("\r${yellow} => ${clear}download %s .. ${green}ok%s", url, _emptychars())
+ printf("\r" .. _emptychars())
+ cprint("\r${yellow} => ${clear}download %s .. ${green}ok", url)
end
-- get sorted urls
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua
index 421945d52..aa4194dde 100644
--- a/xmake/actions/require/install.lua
+++ b/xmake/actions/require/install.lua
@@ -76,6 +76,7 @@ function main(requires)
-- trace
cprintf("\r${yellow} => ${clear}downloading %s .. %s", table.concat(downloading, ", "), waitchars[waitindex + 1])
+ io.flush()
end)
-- install all required packages from repositories
diff --git a/xmake/core/base/process.lua b/xmake/core/base/process.lua
index 565eabbbb..297b8f696 100644
--- a/xmake/core/base/process.lua
+++ b/xmake/core/base/process.lua
@@ -40,6 +40,7 @@ function process.asyncrun(task, waitchars)
local waitindex = 0
local waitchars = waitchars or {'\\', '|', '/', '-'}
utils.printf(waitchars[waitindex + 1])
+ io.flush()
-- start and wait this task
local ok, errors = coroutine.resume(task)
@@ -47,6 +48,7 @@ function process.asyncrun(task, waitchars)
-- remove wait charactor
utils.printf("\b")
+ io.flush()
-- failed
return false, errors
@@ -58,6 +60,7 @@ function process.asyncrun(task, waitchars)
-- trace
waitindex = ((waitindex + 1) % #waitchars)
utils.printf("\b" .. waitchars[waitindex + 1])
+ io.flush()
-- wait some time
os.sleep(300)
@@ -68,6 +71,7 @@ function process.asyncrun(task, waitchars)
-- remove wait charactor
utils.printf("\b")
+ io.flush()
-- failed
return false, errors
@@ -76,6 +80,7 @@ function process.asyncrun(task, waitchars)
-- remove wait charactor
utils.printf("\b")
+ io.flush()
-- ok
return true
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 65608327b..3e60b52d8 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -56,6 +56,7 @@ sandbox_os.programfile = os.programfile
sandbox_os.projectdir = os.projectdir
sandbox_os.projectfile = os.projectfile
sandbox_os.versioninfo = os.versioninfo
+sandbox_os.getwinsize = os.getwinsize
-- copy file or directory
function sandbox_os.cp(...)
diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua
index e282ef80e..4e3c8858f 100644
--- a/xmake/core/sandbox/modules/utils.lua
+++ b/xmake/core/sandbox/modules/utils.lua
@@ -92,22 +92,16 @@ end
-- print format string and the builtin variables without newline
function sandbox_utils.printf(format, ...)
-
- -- done
utils._iowrite(vformat(format, ...))
end
-- print format string, the builtin variables and colors with newline
function sandbox_utils.cprint(format, ...)
-
- -- done
utils._print(colors(vformat(format, ...)))
end
-- print format string, the builtin variables and colors without newline
function sandbox_utils.cprintf(format, ...)
-
- -- done
utils._iowrite(colors(vformat(format, ...)))
end