summaryrefslogtreecommitdiff
path: root/xmake/core/base/tty.lua
diff options
context:
space:
mode:
authorÂngelo Andrade Cirino <[email protected]>2022-01-10 10:23:17 -0300
committerÂngelo Andrade Cirino <[email protected]>2022-01-10 10:23:17 -0300
commited0c0c5e0249aa966ea7061b30710abdd0b09d87 (patch)
tree2a51c869a3aea1a093ed569e749bdf0465634a6c /xmake/core/base/tty.lua
parent885d00da8caf74aeed758d030b9a1b50d9078e1f (diff)
parent2431dd7e6142ff98b55741cfd4de4d2e69f4f8b5 (diff)
Merged from upstream/master
Diffstat (limited to 'xmake/core/base/tty.lua')
-rw-r--r--xmake/core/base/tty.lua20
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