write shit

This commit is contained in:
yyc12345 2023-02-12 18:08:29 +08:00
parent 3b754f0434
commit 3de9e3d996
8 changed files with 78 additions and 11 deletions

View File

@ -94,6 +94,11 @@ namespace LibCmo {
return; return;
} }
void GetWcharStdin(std::string& u8_input, std::wstring& wc_input) {
// just redirect to prev func
CharToWchar(u8_input, wc_input, CP_UTF8);
}
#else #else
//todo: linux implementation //todo: linux implementation

14
Unvirt/InteractiveCmd.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "InteractiveCmd.hpp"
namespace Unvirt {
InteractiveCmd::InteractiveCmd() {
}
InteractiveCmd::~InteractiveCmd() {
}
}

32
Unvirt/InteractiveCmd.hpp Normal file
View File

@ -0,0 +1,32 @@
#pragma once
#include <unordered_map>
#include <string>
#include <functional>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/positional_options.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
namespace Unvirt {
struct CmdRegisteryEntry {
boost::program_options::options_description mOptDesc;
boost::program_options::positional_options_description mPosOptDesc;
std::function<void(boost::program_options::options_description&, boost::program_options::variables_map&)> mBindProc;
};
class InteractiveCmd {
public:
InteractiveCmd();
~InteractiveCmd();
void Run(void) { ; }
private:
std::unordered_map<std::string, CmdRegisteryEntry> mCmdDispatcher;
};
}

View File

@ -1,14 +1,16 @@
#include "ColorfulTerminal.hpp" #include "TerminalHelper.hpp"
#include <VTUtils.hpp> #include <VTUtils.hpp>
#include <cstdarg>
#if defined(LIBCMO_OS_WIN32) #if defined(LIBCMO_OS_WIN32)
#include <Windows.h> #include <Windows.h>
#include <cstdio> #include <cstdio>
#include <io.h> #include <io.h>
#include <fcntl.h>
#endif #endif
namespace Unvirt { namespace Unvirt {
namespace ColorfulTerminal { namespace TerminalHelper {
// all of these functions only works on Windows platform // all of these functions only works on Windows platform
// due to shitty Windows implementations. // due to shitty Windows implementations.
@ -34,6 +36,9 @@ namespace Unvirt {
#if defined(LIBCMO_OS_WIN32) #if defined(LIBCMO_OS_WIN32)
if (!SetConsoleCP(CP_UTF8)) return false; if (!SetConsoleCP(CP_UTF8)) return false;
if (!SetConsoleOutputCP(CP_UTF8)) return false; if (!SetConsoleOutputCP(CP_UTF8)) return false;
/*_setmode(_fileno(stdout), _O_U8TEXT);*/
_setmode(_fileno(stdin), _O_U16TEXT);
#endif #endif
return true; return true;
} }

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
namespace Unvirt{ namespace Unvirt{
namespace ColorfulTerminal { namespace TerminalHelper {
#define UNVIRT_REMOVE_PARENS_IMPL(...) __VA_ARGS__ #define UNVIRT_REMOVE_PARENS_IMPL(...) __VA_ARGS__
#define UNVIRT_REMOVE_PARENS(T) UNVIRT_REMOVE_PARENS_IMPL T #define UNVIRT_REMOVE_PARENS(T) UNVIRT_REMOVE_PARENS_IMPL T

View File

@ -1,17 +1,20 @@
#include "AccessibleValue.hpp" #include "AccessibleValue.hpp"
#include "ColorfulTerminal.hpp" #include "TerminalHelper.hpp"
#include "VTStruct.hpp" #include "VTStruct.hpp"
#include <cstdio> #include <cstdio>
#include <iostream>
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
Unvirt::ColorfulTerminal::EnsureTerminalColor(); Unvirt::TerminalHelper::EnsureTerminalColor();
Unvirt::ColorfulTerminal::EnsureTerminalEncoding(); Unvirt::TerminalHelper::EnsureTerminalEncoding();
LibCmo::Utils::VirtoolsContext vtctx; LibCmo::Utils::VirtoolsContext vtctx;
LibCmo::CKFile vtfile(vtctx); LibCmo::CKFile vtfile(vtctx);
vtfile.Load("Language.old.nmo", LibCmo::CK_LOAD_FLAGS::CK_LOAD_DEFAULT); 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; return 0;
} }

View File

@ -172,13 +172,15 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="AccessibleValue.cpp" /> <ClCompile Include="AccessibleValue.cpp" />
<ClCompile Include="ColorfulTerminal.cpp" /> <ClCompile Include="InteractiveCmd.cpp" />
<ClCompile Include="TerminalHelper.cpp" />
<ClCompile Include="StringHelper.cpp" /> <ClCompile Include="StringHelper.cpp" />
<ClCompile Include="Unvirt.cpp" /> <ClCompile Include="Unvirt.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="AccessibleValue.hpp" /> <ClInclude Include="AccessibleValue.hpp" />
<ClInclude Include="ColorfulTerminal.hpp" /> <ClInclude Include="InteractiveCmd.hpp" />
<ClInclude Include="TerminalHelper.hpp" />
<ClInclude Include="StringHelper.hpp" /> <ClInclude Include="StringHelper.hpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -24,7 +24,10 @@
<ClCompile Include="StringHelper.cpp"> <ClCompile Include="StringHelper.cpp">
<Filter>Sources</Filter> <Filter>Sources</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ColorfulTerminal.cpp"> <ClCompile Include="TerminalHelper.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="InteractiveCmd.cpp">
<Filter>Sources</Filter> <Filter>Sources</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -35,7 +38,10 @@
<ClInclude Include="StringHelper.hpp"> <ClInclude Include="StringHelper.hpp">
<Filter>Headers</Filter> <Filter>Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="ColorfulTerminal.hpp"> <ClInclude Include="TerminalHelper.hpp">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="InteractiveCmd.hpp">
<Filter>Headers</Filter> <Filter>Headers</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>