This commit is contained in:
恍兮惚兮 2024-05-12 14:00:34 +08:00
parent a3c109d5e4
commit c6fb89599a
2 changed files with 11 additions and 4 deletions

View File

@ -369,8 +369,15 @@ void LunaHost::on_text_recv_checkissaved(TextThread& thread)
}
std::wstring sanitize(const std::wstring& s1) {
std::wstring s=s1;
s.erase(std::remove_if(s.begin(), s.end(), [](wchar_t ch) {
return (ch >= 0xD800 && ch <= 0xDBFF) || (ch >= 0xDC00 && ch <= 0xDFFF);
}), s.end());
return s;
}
void LunaHost::showtext(const std::wstring&text,bool clear){
auto output=text;
auto output=sanitize(text);
strReplace(output,L"\n",L"\r\n");
if(clear)
{
@ -385,7 +392,7 @@ void LunaHost::showtext(const std::wstring&text,bool clear){
void LunaHost::updatelisttext(const std::wstring&text,LONG_PTR data){
auto idx=g_hListBox_listtext->querydataidx(data);
if(idx>=0){
auto __output=text;
auto __output=sanitize(text);
strReplace(__output,L"\n",L" ");
if(__output.size()>0x40){
__output=__output.substr(0,0x40)+L"...";

View File

@ -200,8 +200,8 @@ namespace Host
{
OnConnect = [=](auto &&...args){std::lock_guard _(syncmutex);Connect(args...);};
OnDisconnect = [=](auto &&...args){std::lock_guard _(syncmutex);Disconnect(args...);};
OnCreate = [=](TextThread& thread) {std::lock_guard _(syncmutex); Create(thread); thread.Start(); };
OnDestroy = [=](TextThread& thread) {std::lock_guard _(syncmutex); thread.Stop(); Destroy(thread); };
OnCreate = [=](TextThread& thread) {{std::lock_guard _(syncmutex); Create(thread);} thread.Start(); };
OnDestroy = [=](TextThread& thread) {thread.Stop(); {std::lock_guard _(syncmutex); Destroy(thread);} };
TextThread::Output = [=](auto &&...args){std::lock_guard _(syncmutex);return Output(args...);};
textThreadsByParams->try_emplace(console, console, HookParam{}, CONSOLE);