From 0b7db9e5cadeab6cdc0629be970ec242bbf61078 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 4 Oct 2018 23:23:57 -0400 Subject: [PATCH] add prefilter --- GUI/host/host.cc | 1 + GUI/host/textthread.cc | 1 + GUI/host/textthread.h | 1 + 3 files changed, 3 insertions(+) diff --git a/GUI/host/host.cc b/GUI/host/host.cc index 6daa845..3056fcf 100644 --- a/GUI/host/host.cc +++ b/GUI/host/host.cc @@ -144,6 +144,7 @@ namespace Host void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove) { OnAttach = onAttach; OnDetach = onDetach; OnCreate = onCreate; OnRemove = onRemove; + TextThread::Prefilter = (int(*)(wchar_t*, const wchar_t*))GetProcAddress(LoadLibraryW(L"0_Prefilter.dll"), "OnNewData"); OnCreate(textThreadsByParams[CONSOLE] = new TextThread(CONSOLE, USING_UNICODE)); StartPipe(); } diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index e8d69f5..b518eab 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -47,6 +47,7 @@ void TextThread::AddText(const BYTE* data, int len) ? std::wstring((wchar_t*)data, len / 2) : StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS); LOCK(ttMutex); + if (Prefilter) wData.resize(Prefilter(wData.data(), storage.c_str())); buffer.append(wData); timestamp = GetTickCount(); } diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index a806269..868c81e 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -24,6 +24,7 @@ public: const std::wstring name; const ThreadParam tp; + inline static int(*Prefilter)(wchar_t*, const wchar_t*) = nullptr; inline static int FlushDelay = 250; // flush every 250ms by default inline static int MaxBufferSize = 200; inline static int ThreadCounter = 0;