summaryrefslogtreecommitdiff
path: root/xmake/modules/utils/progress.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-28 22:46:24 +0800
committerruki <[email protected]>2025-10-29 10:37:58 +0800
commitd5caf9d3f6055c8565caac2a8a0d2b8503beb996 (patch)
tree3e79084e1c3ce1defd2a2da4704c516bd91dedd7 /xmake/modules/utils/progress.lua
parent8ec1b785c8c353a22f48fde609b5fbee8ffb2669 (diff)
check tty
Diffstat (limited to 'xmake/modules/utils/progress.lua')
-rw-r--r--xmake/modules/utils/progress.lua29
1 files changed, 28 insertions, 1 deletions
diff --git a/xmake/modules/utils/progress.lua b/xmake/modules/utils/progress.lua
index 7682d4bad..f202b11f3 100644
--- a/xmake/modules/utils/progress.lua
+++ b/xmake/modules/utils/progress.lua
@@ -81,12 +81,25 @@ function _is_scroll()
return is_scroll
end
+-- is multi-row refresh output?
+function _is_multirow_refresh()
+ local is_multirow_refresh = _g.is_multirow_refresh
+ if is_multirow_refresh == nil then
+ local style = theme.get("text.build.progress_style")
+ if style == "multirow_refresh" and tty.has_vtansi() and io.isatty() then
+ is_multirow_refresh = true
+ end
+ _g.is_multirow_refresh = is_multirow_refresh
+ end
+ return is_multirow_refresh
+end
+
-- is single-row refresh output?
function _is_singlerow_refresh()
local is_singlerow_refresh = _g.is_singlerow_refresh
if is_singlerow_refresh == nil then
local style = theme.get("text.build.progress_style")
- if style == "singlerow_refresh" then
+ if style == "singlerow_refresh" and tty.has_vtansi() and io.isatty() then
is_singlerow_refresh = true
end
_g.is_singlerow_refresh = is_singlerow_refresh
@@ -108,6 +121,16 @@ function _show_progress_with_scroll(progress, format, ...)
cprint(progress_prefix .. format, progress, ...)
end
+-- show progress with multi-row refresh
+-- @see https://github.com/xmake-io/xmake/issues/6805
+function _show_progress_with_multirow_refresh(progress, format, ...)
+ progress = type(progress) == "table" and progress:percent() or math.floor(progress)
+ local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
+
+ -- TODO
+ print("todo")
+end
+
-- show progress with single-row refresh (ninja style)
function _show_progress_with_singlerow_refresh(progress, format, ...)
progress = type(progress) == "table" and progress:percent() or math.floor(progress)
@@ -148,8 +171,12 @@ function show(progress, format, ...)
_show_progress_with_verbose(progress, format, ...)
elseif _is_scroll() then
_show_progress_with_scroll(progress, format, ...)
+ elseif _is_multirow_refresh() then
+ _show_progress_with_multirow_refresh(progress, format, ...)
elseif _is_singlerow_refresh() then
_show_progress_with_singlerow_refresh(progress, format, ...)
+ else
+ _show_progress_with_scroll(progress, format, ...)
end
end