forked from Public-Mirror/Textractor
regex filter added
This commit is contained in:
parent
d07dd5c641
commit
0166df7209
@ -5,6 +5,7 @@
|
|||||||
#include "textthread.h"
|
#include "textthread.h"
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
TextThread::TextThread(ThreadParam tp, DWORD status) : handle(ThreadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {}
|
TextThread::TextThread(ThreadParam tp, DWORD status) : handle(ThreadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {}
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ void TextThread::Flush()
|
|||||||
|
|
||||||
void TextThread::AddSentence(std::wstring sentence)
|
void TextThread::AddSentence(std::wstring sentence)
|
||||||
{
|
{
|
||||||
|
sentence = std::regex_replace(sentence, std::wregex(filter), L"");
|
||||||
// Dispatch to extensions occurs here. Don't hold mutex! Extensions might take a while!
|
// Dispatch to extensions occurs here. Don't hold mutex! Extensions might take a while!
|
||||||
if (Output(this, sentence))
|
if (Output(this, sentence))
|
||||||
{
|
{
|
||||||
@ -49,7 +51,6 @@ void TextThread::AddText(const BYTE* data, int len)
|
|||||||
buffer += status & USING_UNICODE
|
buffer += status & USING_UNICODE
|
||||||
? std::wstring((wchar_t*)data, len / 2)
|
? std::wstring((wchar_t*)data, len / 2)
|
||||||
: StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
: StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS);
|
||||||
if (Filter) Filter(buffer.data(), storage.c_str());
|
|
||||||
timestamp = GetTickCount();
|
timestamp = GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ public:
|
|||||||
typedef std::function<bool(TextThread*, std::wstring&)> OutputCallback;
|
typedef std::function<bool(TextThread*, std::wstring&)> OutputCallback;
|
||||||
|
|
||||||
inline static OutputCallback Output;
|
inline static OutputCallback Output;
|
||||||
inline static std::function<void(wchar_t* buffer, const wchar_t* storage)> Filter = nullptr;
|
|
||||||
|
|
||||||
|
inline static std::wstring filter = L"";
|
||||||
inline static int FlushDelay = 250; // flush every 250ms by default
|
inline static int FlushDelay = 250; // flush every 250ms by default
|
||||||
inline static int MaxBufferSize = 200;
|
inline static int MaxBufferSize = 200;
|
||||||
inline static int ThreadCounter = 0;
|
inline static int ThreadCounter = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user