From 4dd0fbac93fcd18a8074f5021ca60be4bb87e979 Mon Sep 17 00:00:00 2001 From: Thijs Date: Mon, 24 Jun 2024 23:18:10 +0200 Subject: enable Windows support requires LuaSystem to be installed --- term/init.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'term') diff --git a/term/init.lua b/term/init.lua index bd2024b..b0387a6 100644 --- a/term/init.lua +++ b/term/init.lua @@ -18,6 +18,19 @@ -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. +do -- set console to utf-8 and enable ANSI escape sequences on Windows + local ok, sys = pcall(require, "system") + if ok and sys.setconsoleflags and sys.windows then + sys.setconsoleoutputcp(sys.CODEPAGE_UTF8) + if sys.isatty(io.stdout) then + sys.setconsoleflags(io.stdout, sys.getconsoleflags(io.stdout) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) + end + if sys.isatty(io.stderr) then + sys.setconsoleflags(io.stderr, sys.getconsoleflags(io.stderr) + sys.COF_VIRTUAL_TERMINAL_PROCESSING) + end + end +end + local term = require 'term.core' local sformat = string.format local iotype = io.type -- cgit v1.2.3-55-g6feb