| 3 | #include "types.h" |
| 4 | |
| 5 | class TextThread |
| 6 | { |
| 7 | public: |
| 8 | using OutputCallback = bool(*)(TextThread&, std::wstring&); |
| 9 | inline static OutputCallback Output; |
| 10 | |
| 11 | inline static bool filterRepetition = false; |
| 12 | inline static int flushDelay = 500; // flush every 500ms by default |
| 13 | inline static int maxBufferSize = 3000; |
| 14 | inline static int maxHistorySize = 10'000'000; |
| 15 | |
| 16 | TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {}); |
| 17 | |
| 18 | void Start(); |
| 19 | void Stop(); |
| 20 | void AddSentence(std::wstring sentence); |
| 21 | void Push(BYTE* data, int length); |
| 22 | void Push(const wchar_t* data); |
| 23 | |
| 24 | Synchronized<std::wstring> storage; |
| 25 | const int64_t handle; |
| 26 | const std::wstring name; |
| 27 | const ThreadParam tp; |
| 28 | const HookParam hp; |
| 29 | |
| 30 | private: |
| 31 | inline static int threadCounter = 0; |
| 32 | |
| 33 | void Flush(); |
| 34 | |
| 35 | std::wstring buffer; |
| 36 | BYTE leadByte = 0; |
| 37 | std::unordered_set<wchar_t> repeatingChars; |
| 38 | std::mutex bufferMutex; |
| 39 | DWORD64 lastPushTime = 0; |
| 40 | Synchronized<std::vector<std::wstring>> queuedSentences; |
| 41 | struct TimerDeleter { void operator()(HANDLE h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } }; |
| 42 | AutoHandle<TimerDeleter> timer = NULL; |
| 43 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected