diff options
| author | ruki <[email protected]> | 2021-12-19 00:53:36 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-19 00:53:36 +0800 |
| commit | cbff24314b4fb76b2617f56d4f202389feb259fd (patch) | |
| tree | ccfef243ae29218ea696315f7959d51feee92676 /xmake | |
| parent | 7be1bc272914b757a4a7fe1792f7590de4a91cdf (diff) | |
| parent | 2ab866f4457c9074255d0104b32fce420bb8b13e (diff) | |
Merge pull request #1926 from xmake-io/term_mode
fix term mode
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/base/os.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/tty.lua | 20 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/install_packages.lua | 9 |
3 files changed, 29 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 5c3057e5a..18b59f61c 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -761,8 +761,6 @@ function os.execv(program, argv, opt) -- cannot execute process return nil, os.strerror() end - - -- ok? return ok end diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index 0417f9b8f..a744f12e0 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -24,6 +24,9 @@ local tty = tty or {} -- load modules local io = require("base/io") +-- save metatable and builtin functions +tty._term_mode = tty._term_mode or tty.term_mode + -- @see http://www.termsys.demon.co.uk/vtansi.htm -- write control characters @@ -392,5 +395,22 @@ function tty.has_color24() return has_color24 end +-- get term mode, e.g. stdin, stdout, stderr +-- +-- local oldmode = tty.term_mode(stdtype) +-- local oldmode = tty.term_mode(stdtype, newmode) +-- +function tty.term_mode(stdtype, newmode) + local oldmode = 0 + if stdtype == "stdin" then + oldmode = tty._term_mode(1, newmode) + elseif stdtype == "stdout" then + oldmode = tty._term_mode(2, newmode) + elseif stdtype == "stderr" then + oldmode = tty._term_mode(3, newmode) + end + return oldmode +end + -- return module return tty diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 714b98461..f62a0fb52 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -268,6 +268,9 @@ function _install_packages(packages_install, packages_download, installdeps) packages_installed[tostring(instance)] = false end + -- save terminal mode for stdout, @see https://github.com/xmake-io/xmake/issues/1924 + local term_mode_stdout = tty.term_mode("stdout") + -- do install local progress_helper = show_wait and progress.new() or nil local packages_installing = {} @@ -438,6 +441,12 @@ function _install_packages(packages_install, packages_download, installdeps) end end + -- fix terminal mode to avoid some subprocess to change it + -- @see https://github.com/xmake-io/xmake/issues/1924 + if term_mode_stdout ~= tty.term_mode("stdout") then + tty.term_mode("stdout", term_mode_stdout) + end + -- trace progress_helper:clear() tty.erase_line_to_start().cr() |
