From ce255c4a536089f074f39fd1a91636241abcd3ab Mon Sep 17 00:00:00 2001 From: vylsaz Date: Tue, 11 Jul 2023 01:11:28 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Enable=20=E2=80=A2file.CreateDir=20on=20Win?= =?UTF-8?q?dows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/file.c b/src/utils/file.c index a09c66bf..ecd08010 100644 --- a/src/utils/file.c +++ b/src/utils/file.c @@ -7,6 +7,7 @@ #include #if defined(_WIN32) || defined(_WIN64) + #include #include "../windows/realpath.c" #endif @@ -338,7 +339,7 @@ void mmap_init() { } bool dir_create(B path) { char* p = toCStr(path); #if defined(_WIN32) || defined(_WIN64) - bool r = 0; + bool r = _mkdir(p) == 0; #else bool r = mkdir(p, S_IRWXU) == 0; #endif From e4542f70a6f4e21743fd38352f204f4f490b1955 Mon Sep 17 00:00:00 2001 From: vylsaz Date: Tue, 11 Jul 2023 03:15:48 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Implement=20=E2=80=A2term.CharN=20and=20?= =?UTF-8?q?=E2=80=A2term.RawMode=20for=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/sysfn.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 46b98768..9b3ab7e9 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -9,6 +9,7 @@ #include #if defined(_WIN32) || defined(_WIN64) + #include #include "../windows/getline.c" #endif #include @@ -1151,6 +1152,26 @@ B tCharN_c1(B t, B x) { fcntl(0, F_SETFL, 0); return n>=0? m_c32(n) : m_f64(0); } +#elif defined(_WIN32) || defined(_WIN64) +#include +B tRawMode_c1(B t, B x) { + HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); + DWORD dwMode; + GetConsoleMode(hIn, &dwMode); + if (o2b(x)) dwMode&= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); + else dwMode|= ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT; + SetConsoleMode(hIn, dwMode); + return x; +} +B tCharN_c1(B t, B x) { + dec(x); + if (_kbhit()) { + int n = _getch(); + return n>=0? m_c32(n) : m_f64(0); + } else { + return m_f64(0); + } +} #else B tRawMode_c1(B t, B x) { thrM("•term.RawMode not available"); } B tCharN_c1(B t, B x) { thrM("•term.CharN not available"); }