summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/tty.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua
index d35705770..742b819ab 100644
--- a/xmake/core/base/tty.lua
+++ b/xmake/core/base/tty.lua
@@ -26,6 +26,7 @@ local io = require("base/io")
-- save metatable and builtin functions
tty._term_mode = tty._term_mode or tty.term_mode
+tty._session_id = tty._session_id or tty.session_id
-- @see https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm
-- http://www.termsys.demon.co.uk/vtansi.htm
@@ -538,6 +539,22 @@ function tty.term_mode(stdtype, newmode)
return oldmode
end
+-- get session id
+function tty.session_id()
+ local session_id = tty._SESSION_ID
+ if session_id == nil then
+ if tty._session_id then
+ local sid = tty._session_id()
+ if sid then
+ local hash = require("base/hash")
+ session_id = hash.strhash32(sid)
+ end
+ end
+ tty._SESSION_ID = session_id or 0
+ end
+ return session_id
+end
+
-- return module
return tty