diff options
| author | ruki <[email protected]> | 2025-12-15 23:24:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-15 23:24:55 +0800 |
| commit | b9116ea123e77faec8a4a0cfbfcbb38f2ebc2e66 (patch) | |
| tree | bc8976c77263b6941f181fef460dad43dc2f5ee6 /xmake | |
| parent | fb06feeb88ecd2512a4a737d7e543b88892ad783 (diff) | |
add tty.session_id
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/base/tty.lua | 17 |
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 |
