From 3de9e3d9960e843f69b57963441f7b808346d175 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 12 Feb 2023 18:08:29 +0800 Subject: [PATCH] write shit --- LibCmo/VTEncoding.cpp | 5 +++ Unvirt/InteractiveCmd.cpp | 14 ++++++++ Unvirt/InteractiveCmd.hpp | 32 +++++++++++++++++++ ...olorfulTerminal.cpp => TerminalHelper.cpp} | 9 ++++-- ...olorfulTerminal.hpp => TerminalHelper.hpp} | 2 +- Unvirt/Unvirt.cpp | 11 ++++--- Unvirt/Unvirt.vcxproj | 6 ++-- Unvirt/Unvirt.vcxproj.filters | 10 ++++-- 8 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 Unvirt/InteractiveCmd.cpp create mode 100644 Unvirt/InteractiveCmd.hpp rename Unvirt/{ColorfulTerminal.cpp => TerminalHelper.cpp} (82%) rename Unvirt/{ColorfulTerminal.hpp => TerminalHelper.hpp} (98%) diff --git a/LibCmo/VTEncoding.cpp b/LibCmo/VTEncoding.cpp index dc4fefc..0564363 100644 --- a/LibCmo/VTEncoding.cpp +++ b/LibCmo/VTEncoding.cpp @@ -94,6 +94,11 @@ namespace LibCmo { return; } + void GetWcharStdin(std::string& u8_input, std::wstring& wc_input) { + // just redirect to prev func + CharToWchar(u8_input, wc_input, CP_UTF8); + } + #else //todo: linux implementation diff --git a/Unvirt/InteractiveCmd.cpp b/Unvirt/InteractiveCmd.cpp new file mode 100644 index 0000000..319c193 --- /dev/null +++ b/Unvirt/InteractiveCmd.cpp @@ -0,0 +1,14 @@ +#include "InteractiveCmd.hpp" + +namespace Unvirt { + + InteractiveCmd::InteractiveCmd() { + + } + + InteractiveCmd::~InteractiveCmd() { + + } + + +} diff --git a/Unvirt/InteractiveCmd.hpp b/Unvirt/InteractiveCmd.hpp new file mode 100644 index 0000000..2c2ce69 --- /dev/null +++ b/Unvirt/InteractiveCmd.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace Unvirt { + + struct CmdRegisteryEntry { + boost::program_options::options_description mOptDesc; + boost::program_options::positional_options_description mPosOptDesc; + std::function mBindProc; + }; + + class InteractiveCmd { + public: + InteractiveCmd(); + ~InteractiveCmd(); + + void Run(void) { ; } + + private: + std::unordered_map mCmdDispatcher; + + + }; + +} diff --git a/Unvirt/ColorfulTerminal.cpp b/Unvirt/TerminalHelper.cpp similarity index 82% rename from Unvirt/ColorfulTerminal.cpp rename to Unvirt/TerminalHelper.cpp index 34e849e..7d1c8a6 100644 --- a/Unvirt/ColorfulTerminal.cpp +++ b/Unvirt/TerminalHelper.cpp @@ -1,14 +1,16 @@ -#include "ColorfulTerminal.hpp" +#include "TerminalHelper.hpp" #include +#include #if defined(LIBCMO_OS_WIN32) #include #include #include +#include #endif namespace Unvirt { - namespace ColorfulTerminal { + namespace TerminalHelper { // all of these functions only works on Windows platform // due to shitty Windows implementations. @@ -34,6 +36,9 @@ namespace Unvirt { #if defined(LIBCMO_OS_WIN32) if (!SetConsoleCP(CP_UTF8)) return false; if (!SetConsoleOutputCP(CP_UTF8)) return false; + + /*_setmode(_fileno(stdout), _O_U8TEXT);*/ + _setmode(_fileno(stdin), _O_U16TEXT); #endif return true; } diff --git a/Unvirt/ColorfulTerminal.hpp b/Unvirt/TerminalHelper.hpp similarity index 98% rename from Unvirt/ColorfulTerminal.hpp rename to Unvirt/TerminalHelper.hpp index 914290f..d2aad4b 100644 --- a/Unvirt/ColorfulTerminal.hpp +++ b/Unvirt/TerminalHelper.hpp @@ -1,7 +1,7 @@ #pragma once namespace Unvirt{ - namespace ColorfulTerminal { + namespace TerminalHelper { #define UNVIRT_REMOVE_PARENS_IMPL(...) __VA_ARGS__ #define UNVIRT_REMOVE_PARENS(T) UNVIRT_REMOVE_PARENS_IMPL T diff --git a/Unvirt/Unvirt.cpp b/Unvirt/Unvirt.cpp index ea2d90b..7f46a9b 100644 --- a/Unvirt/Unvirt.cpp +++ b/Unvirt/Unvirt.cpp @@ -1,17 +1,20 @@ #include "AccessibleValue.hpp" -#include "ColorfulTerminal.hpp" +#include "TerminalHelper.hpp" #include "VTStruct.hpp" #include +#include int main(int argc, char* argv[]) { - Unvirt::ColorfulTerminal::EnsureTerminalColor(); - Unvirt::ColorfulTerminal::EnsureTerminalEncoding(); + Unvirt::TerminalHelper::EnsureTerminalColor(); + Unvirt::TerminalHelper::EnsureTerminalEncoding(); LibCmo::Utils::VirtoolsContext vtctx; LibCmo::CKFile vtfile(vtctx); vtfile.Load("Language.old.nmo", LibCmo::CK_LOAD_FLAGS::CK_LOAD_DEFAULT); - printf(UNVIRT_TERMCOL_LIGHT_YELLOW(("Hello, %s")), u8"㴮!"); + printf(UNVIRT_TERMCOL_LIGHT_YELLOW(("Hello, %s\n")), u8"㴮!"); + + return 0; } diff --git a/Unvirt/Unvirt.vcxproj b/Unvirt/Unvirt.vcxproj index 47ded24..0ddf306 100644 --- a/Unvirt/Unvirt.vcxproj +++ b/Unvirt/Unvirt.vcxproj @@ -172,13 +172,15 @@ - + + - + + diff --git a/Unvirt/Unvirt.vcxproj.filters b/Unvirt/Unvirt.vcxproj.filters index f1be490..6f340fb 100644 --- a/Unvirt/Unvirt.vcxproj.filters +++ b/Unvirt/Unvirt.vcxproj.filters @@ -24,7 +24,10 @@ Sources - + + Sources + + Sources @@ -35,7 +38,10 @@ Headers - + + Headers + + Headers