diff --git a/GUI/host/textthread.cpp b/GUI/host/textthread.cpp index 95ef1ac..c12f3a8 100644 --- a/GUI/host/textthread.cpp +++ b/GUI/host/textthread.cpp @@ -72,7 +72,7 @@ void TextThread::Push(BYTE* data, int length) void TextThread::Flush() { - if (storage->size() > 10'000'000) storage->erase(0, 8'000'000); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983 + if (storage->size() > maxHistorySize) storage->erase(0, maxHistorySize / 2); // https://github.com/Artikash/Textractor/issues/127#issuecomment-486882983 std::deque sentences; queuedSentences->swap(sentences); diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 0456278..e244a7d 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -12,6 +12,7 @@ public: inline static bool filterRepetition = true; inline static int flushDelay = 400; // flush every 400ms by default inline static int maxBufferSize = 1000; + inline static int maxHistorySize = 10'000'000; TextThread(ThreadParam tp, HookParam hp, std::optional name = {}); diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index d5d6edb..a5f0be4 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -48,6 +48,7 @@ extern const char* SHOW_SYSTEM_PROCESSES; extern const char* DEFAULT_CODEPAGE; extern const char* FLUSH_DELAY; extern const char* MAX_BUFFER_SIZE; +extern const char* MAX_HISTORY_SIZE; extern const wchar_t* ABOUT; extern const wchar_t* CL_OPTIONS; extern const wchar_t* LAUNCH_FAILED; @@ -91,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) : showSystemProcesses = settings.value(SHOW_SYSTEM_PROCESSES, showSystemProcesses).toBool(); TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt(); TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt(); + TextThread::maxHistorySize = settings.value(MAX_HISTORY_SIZE, TextThread::maxHistorySize).toInt(); Host::defaultCodepage = settings.value(DEFAULT_CODEPAGE, Host::defaultCodepage).toInt(); Host::Start( @@ -535,6 +537,7 @@ void MainWindow::Settings() for (auto [value, label] : Array>{ { TextThread::maxBufferSize, MAX_BUFFER_SIZE }, { TextThread::flushDelay, FLUSH_DELAY }, + { TextThread::maxHistorySize, MAX_HISTORY_SIZE }, { Host::defaultCodepage, DEFAULT_CODEPAGE }, }) { diff --git a/text.cpp b/text.cpp index 3ba37fc..c162bef 100644 --- a/text.cpp +++ b/text.cpp @@ -74,6 +74,7 @@ const char* SHOW_SYSTEM_PROCESSES = u8"Show system processes"; const char* DEFAULT_CODEPAGE = u8"Default codepage"; const char* FLUSH_DELAY = u8"Flush delay"; const char* MAX_BUFFER_SIZE = u8"Max buffer size"; +const char* MAX_HISTORY_SIZE = u8"Max history size"; const wchar_t* CONSOLE = L"Console"; const wchar_t* CLIPBOARD = L"Clipboard"; const wchar_t* ABOUT = L"Textractor " ARCH L" v" VERSION LR"( made by me: Artikash (email: akashmozumdar@gmail.com)