Limit string length option
This commit is contained in:
parent
f3fbe04409
commit
0505417247
@ -64,6 +64,7 @@ extern const char* DEFAULT_CODEPAGE;
|
|||||||
extern const char* FLUSH_DELAY;
|
extern const char* FLUSH_DELAY;
|
||||||
extern const char* MAX_BUFFER_SIZE;
|
extern const char* MAX_BUFFER_SIZE;
|
||||||
extern const char* MAX_HISTORY_SIZE;
|
extern const char* MAX_HISTORY_SIZE;
|
||||||
|
extern const char* LIMIT_STRING_LENGTH;
|
||||||
extern const char* CONFIG_JP_LOCALE;
|
extern const char* CONFIG_JP_LOCALE;
|
||||||
extern const wchar_t* ABOUT;
|
extern const wchar_t* ABOUT;
|
||||||
extern const wchar_t* CL_OPTIONS;
|
extern const wchar_t* CL_OPTIONS;
|
||||||
@ -503,6 +504,7 @@ namespace
|
|||||||
{ TextThread::maxBufferSize, MAX_BUFFER_SIZE },
|
{ TextThread::maxBufferSize, MAX_BUFFER_SIZE },
|
||||||
{ TextThread::flushDelay, FLUSH_DELAY },
|
{ TextThread::flushDelay, FLUSH_DELAY },
|
||||||
{ TextThread::maxHistorySize, MAX_HISTORY_SIZE },
|
{ TextThread::maxHistorySize, MAX_HISTORY_SIZE },
|
||||||
|
{ TextThread::limitStringLength, LIMIT_STRING_LENGTH },
|
||||||
{ Host::defaultCodepage, DEFAULT_CODEPAGE },
|
{ Host::defaultCodepage, DEFAULT_CODEPAGE },
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
@ -666,6 +668,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt();
|
TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt();
|
||||||
TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt();
|
TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt();
|
||||||
TextThread::maxHistorySize = settings.value(MAX_HISTORY_SIZE, TextThread::maxHistorySize).toInt();
|
TextThread::maxHistorySize = settings.value(MAX_HISTORY_SIZE, TextThread::maxHistorySize).toInt();
|
||||||
|
TextThread::limitStringLength = settings.value(LIMIT_STRING_LENGTH, TextThread::limitStringLength).toInt();
|
||||||
Host::defaultCodepage = settings.value(DEFAULT_CODEPAGE, Host::defaultCodepage).toInt();
|
Host::defaultCodepage = settings.value(DEFAULT_CODEPAGE, Host::defaultCodepage).toInt();
|
||||||
|
|
||||||
Host::Start(ProcessConnected, ProcessDisconnected, ThreadAdded, ThreadRemoved, SentenceReceived);
|
Host::Start(ProcessConnected, ProcessDisconnected, ThreadAdded, ThreadRemoved, SentenceReceived);
|
||||||
|
@ -112,7 +112,8 @@ void TextThread::Flush()
|
|||||||
if (buffer.empty()) return;
|
if (buffer.empty()) return;
|
||||||
if (buffer.size() > maxBufferSize || GetTickCount64() - lastPushTime > flushDelay)
|
if (buffer.size() > maxBufferSize || GetTickCount64() - lastPushTime > flushDelay)
|
||||||
{
|
{
|
||||||
AddSentence(std::move(buffer));
|
if (limitStringLength==0 || buffer.length()<limitStringLength) // Limit string length (0=disabled)
|
||||||
|
AddSentence(std::move(buffer));
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ public:
|
|||||||
inline static bool filterRepetition = false;
|
inline static bool filterRepetition = false;
|
||||||
inline static int flushDelay = 500; // flush every 500ms by default
|
inline static int flushDelay = 500; // flush every 500ms by default
|
||||||
inline static int maxBufferSize = 3000;
|
inline static int maxBufferSize = 3000;
|
||||||
|
inline static int limitStringLength = 1000; // Limit string length to 1000 chars by default
|
||||||
inline static int maxHistorySize = 10'000'000;
|
inline static int maxHistorySize = 10'000'000;
|
||||||
|
|
||||||
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
||||||
|
2
text.cpp
2
text.cpp
@ -94,6 +94,7 @@ const char* DEFAULT_CODEPAGE = u8"Default codepage";
|
|||||||
const char* FLUSH_DELAY = u8"Flush delay";
|
const char* FLUSH_DELAY = u8"Flush delay";
|
||||||
const char* MAX_BUFFER_SIZE = u8"Max buffer size";
|
const char* MAX_BUFFER_SIZE = u8"Max buffer size";
|
||||||
const char* MAX_HISTORY_SIZE = u8"Max history size";
|
const char* MAX_HISTORY_SIZE = u8"Max history size";
|
||||||
|
const char* LIMIT_STRING_LENGTH = u8"Limit string length (0=Off)";
|
||||||
const char* CONFIG_JP_LOCALE = u8"Launch with JP locale";
|
const char* CONFIG_JP_LOCALE = u8"Launch with JP locale";
|
||||||
const wchar_t* CONSOLE = L"Console";
|
const wchar_t* CONSOLE = L"Console";
|
||||||
const wchar_t* CLIPBOARD = L"Clipboard";
|
const wchar_t* CLIPBOARD = L"Clipboard";
|
||||||
@ -860,6 +861,7 @@ Per rimuovere un estenzione, selezionala e premi rimuovi)";
|
|||||||
FLUSH_DELAY = u8"Ritardo flush";
|
FLUSH_DELAY = u8"Ritardo flush";
|
||||||
MAX_BUFFER_SIZE = u8"Massima dimensione buffer";
|
MAX_BUFFER_SIZE = u8"Massima dimensione buffer";
|
||||||
MAX_HISTORY_SIZE = u8"Massima dimensione cronologia";
|
MAX_HISTORY_SIZE = u8"Massima dimensione cronologia";
|
||||||
|
LIMIT_STRING_LENGTH = u8"Limita lunghezza stringa (0=Off)";
|
||||||
CONFIG_JP_LOCALE = u8"Avvia con il JP locale";
|
CONFIG_JP_LOCALE = u8"Avvia con il JP locale";
|
||||||
CONSOLE = L"Console";
|
CONSOLE = L"Console";
|
||||||
CLIPBOARD = L"Appunti";
|
CLIPBOARD = L"Appunti";
|
||||||
|
Loading…
Reference in New Issue
Block a user