diff options
| author | ruki <[email protected]> | 2021-12-18 23:17:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-12-18 23:17:45 +0800 |
| commit | e02a05e5fa50f21a6d4128582bf8a15141d6a763 (patch) | |
| tree | 79e7ed1eaabe8b28b15bcab32a964641ea0acc26 /xmake/core/base/tty.lua | |
| parent | 7be1bc272914b757a4a7fe1792f7590de4a91cdf (diff) | |
fix term mode
Diffstat (limited to 'xmake/core/base/tty.lua')
| -rw-r--r-- | xmake/core/base/tty.lua | 20 |
1 files changed, 20 insertions, 0 deletions
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 |
