Merge remote-tracking branch 'Blu3train/limitStringLength'
This commit is contained in:
commit
e72789a21d
@ -65,6 +65,7 @@ extern const char* FLUSH_DELAY;
|
|||||||
extern const char* FLUSH_DELAY_SPACING;
|
extern const char* FLUSH_DELAY_SPACING;
|
||||||
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;
|
||||||
@ -508,6 +509,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 },
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
@ -672,6 +674,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);
|
||||||
|
@ -113,7 +113,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ public:
|
|||||||
inline static bool flushDelaySpacing = false;
|
inline static bool flushDelaySpacing = 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
@ -95,6 +95,7 @@ const char* FLUSH_DELAY = u8"Flush delay";
|
|||||||
const char* FLUSH_DELAY_SPACING = u8"Flush delay string spacing";
|
const char* FLUSH_DELAY_SPACING = u8"Flush delay string spacing";
|
||||||
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";
|
||||||
@ -862,6 +863,7 @@ Per rimuovere un estenzione, selezionala e premi rimuovi)";
|
|||||||
FLUSH_DELAY_SPACING = u8"Spazia ritardo flush string";
|
FLUSH_DELAY_SPACING = u8"Spazia ritardo flush string";
|
||||||
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