remove unused code from textthread
This commit is contained in:
parent
2cf987bef5
commit
bb0133bc58
@ -220,162 +220,6 @@ void TextThread::RemoveSingleRepeatAuto(const BYTE *con, int &len)
|
||||
}
|
||||
}
|
||||
|
||||
void TextThread::RemoveSingleRepeatForce(BYTE *con,int &len)
|
||||
{
|
||||
// jichi 9/1/2013: manual repetition count removed
|
||||
WORD *text = (WORD *)con;
|
||||
//if (repeat_single_count<setman->GetValue(SETTING_REPEAT_COUNT)&&last==*text) {
|
||||
// len=0;
|
||||
// repeat_single_count++;
|
||||
//}
|
||||
//else
|
||||
{
|
||||
last = *text;
|
||||
repeat_single_count=0;
|
||||
}
|
||||
}
|
||||
void TextThread::RemoveCyclicRepeat(BYTE* &con, int &len)
|
||||
{
|
||||
DWORD current_time = GetTickCount();
|
||||
if (status & REPEAT_SUPPRESS) {
|
||||
if (current_time - last_time < (unsigned)settings->splittingInterval &&
|
||||
::memcmp(storage + last_sentence + repeat_index, con, len) == 0) {
|
||||
repeat_index += len;
|
||||
if (repeat_index>=sentence_length)
|
||||
repeat_index -= sentence_length;
|
||||
len = 0;
|
||||
} else {
|
||||
repeat_index = 0;
|
||||
status &= ~REPEAT_SUPPRESS;
|
||||
}
|
||||
} else if (status & REPEAT_DETECT) {
|
||||
if (::memcmp(storage + last_sentence + repeat_index, con, len) == 0) {
|
||||
int half_length=repeat_index+len;
|
||||
if (::memcmp(storage + last_sentence, storage + last_sentence + half_length, repeat_index) == 0) {
|
||||
len=0;
|
||||
sentence_length=half_length;
|
||||
status&=~REPEAT_DETECT;
|
||||
status|=REPEAT_SUPPRESS;
|
||||
|
||||
// jichi 10/27/2013: Not used
|
||||
//if (status&CURRENT_SELECT)
|
||||
// ReplaceSentence(storage+last_sentence+half_length,repeat_index);
|
||||
ClearMemory(last_sentence+half_length,repeat_index);
|
||||
used-=repeat_index;
|
||||
repeat_index=0;
|
||||
}
|
||||
else
|
||||
repeat_index += len;
|
||||
}
|
||||
else {
|
||||
repeat_index=0;
|
||||
status &= ~REPEAT_DETECT;
|
||||
}
|
||||
} else {
|
||||
if (sentence_length == 0)
|
||||
return;
|
||||
else if (len <= (int)sentence_length) {
|
||||
if (memcmp(storage + last_sentence, con, len) == 0) {
|
||||
status |= REPEAT_DETECT;
|
||||
repeat_index = len;
|
||||
if (repeat_index == sentence_length) {
|
||||
repeat_index = 0;
|
||||
len = 0;
|
||||
}
|
||||
} else if (sentence_length > repeat_detect_limit) {
|
||||
if (len > 2) {
|
||||
DWORD u = used;
|
||||
while (memcmp(storage + u - len, con, len) == 0)
|
||||
u -= len;
|
||||
ClearMemory(u, used - u);
|
||||
used = u;
|
||||
repeat_index = 0;
|
||||
// jichi 10/27/2013: Not used
|
||||
//if (status & CURRENT_SELECT)
|
||||
// ReplaceSentence(storage + last_sentence, used - u);
|
||||
status |= REPEAT_SUPPRESS;
|
||||
len = 0;
|
||||
} else if (len <= 2)
|
||||
{
|
||||
WORD tmp = *(WORD *)(storage + last_sentence);
|
||||
DWORD index, last_index, tmp_len;
|
||||
index = used-len;
|
||||
if (index < last_sentence)
|
||||
index = last_sentence;
|
||||
//Locate position of current input.
|
||||
_again:
|
||||
*(WORD *)(storage+last_sentence) = *(WORD *)con;
|
||||
while (*(WORD *)(storage + index) != *(WORD *)con)
|
||||
index--;
|
||||
*(WORD *)(storage + last_sentence) = tmp;
|
||||
if (index > last_sentence) {
|
||||
tmp_len = used - index;
|
||||
if (tmp_len <= 2) {
|
||||
repeat_detect_limit += 0x40;
|
||||
last_time = current_time;
|
||||
return;
|
||||
}
|
||||
if (index - last_sentence >= tmp_len &&
|
||||
memcmp(storage + index - tmp_len, storage + index, tmp_len) == 0) {
|
||||
repeat_detect_limit = 0x80;
|
||||
sentence_length =tmp_len;
|
||||
index -= tmp_len;
|
||||
while (memcmp(storage + index - sentence_length, storage + index, sentence_length) == 0)
|
||||
index -= sentence_length;
|
||||
repeat_index = 2;
|
||||
len = 0;
|
||||
last_index = index;
|
||||
if (status&USING_UNICODE) {
|
||||
while (storage[index] == storage[index + sentence_length])
|
||||
index -= 2;
|
||||
index += 2;
|
||||
while (true) {
|
||||
tmp = *(WORD *)(storage + index);
|
||||
if (tmp >= 0x3000 && tmp < 0x3020)
|
||||
index += 2;
|
||||
else
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
DWORD last_char_len;
|
||||
while (storage[index] == storage[index + sentence_length]) {
|
||||
last_char_len = LeadByteTable[storage[index]];
|
||||
index -= last_char_len;
|
||||
}
|
||||
index += last_char_len;
|
||||
while (storage[index] == 0x81) {
|
||||
if ((storage[index+1]>>4) == 4)
|
||||
index += 2;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
repeat_index += last_index - index;
|
||||
status |= REPEAT_SUPPRESS;
|
||||
last_sentence = index;
|
||||
|
||||
index += sentence_length;
|
||||
// jichi 10/27/2013: Not used
|
||||
//if (status&CURRENT_SELECT)
|
||||
// ReplaceSentence(storage + index, used - index);
|
||||
|
||||
ClearMemory(index, used - index);
|
||||
//memset(storage + index, 0, used - index);
|
||||
used = index;
|
||||
} else {
|
||||
index--;
|
||||
goto _again;
|
||||
}
|
||||
}
|
||||
else
|
||||
repeat_detect_limit += 0x40;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
last_time = current_time;
|
||||
}
|
||||
|
||||
void TextThread::ResetRepeatStatus()
|
||||
{
|
||||
last=0;
|
||||
@ -485,20 +329,6 @@ void TextThread::AddText(const BYTE *con, int len, bool new_line, bool space)
|
||||
}
|
||||
}
|
||||
|
||||
void TextThread::AddTextDirect(const BYTE* con, int len, bool space) // Add to store directly, penetrating repetition filters.
|
||||
{
|
||||
// jichi 10/27/2013: Accordig to the logic, both len and con must be > 0
|
||||
if (status & BUFF_NEWLINE)
|
||||
AddLineBreak();
|
||||
//SetNewLineTimer();
|
||||
sentence_length += len;
|
||||
|
||||
BYTE *data = const_cast<BYTE *>(con); // jichi 10/27/2013: TODO: Figure out where con is modified
|
||||
if (output)
|
||||
len = output(this, data, len, false, app_data, space);
|
||||
AddToStore(data, len);
|
||||
}
|
||||
|
||||
DWORD TextThread::GetEntryString(LPSTR str, DWORD max)
|
||||
{
|
||||
DWORD len = 0;
|
||||
@ -686,32 +516,4 @@ void TextThread::SetNewLineTimer()
|
||||
timer = SetTimer(dummyWindow, (UINT_PTR)this, settings->splittingInterval, NewLineBuff);
|
||||
}
|
||||
|
||||
DWORD TextThread::GetThreadString(LPSTR str, DWORD max)
|
||||
{
|
||||
DWORD len = 0;
|
||||
if (max) {
|
||||
char buffer[0x200];
|
||||
char c;
|
||||
if (thread_string == nullptr)
|
||||
GetEntryString(buffer, 0x200); //This will allocate thread_string.
|
||||
LPSTR end = thread_string;
|
||||
for (; *end; end++);
|
||||
c = thread_string[0];
|
||||
thread_string[0] = ':';
|
||||
LPSTR p1 = end;
|
||||
for (; *p1 != ':'; p1--);
|
||||
thread_string[0] = c;
|
||||
if (p1 == thread_string)
|
||||
return 0;
|
||||
p1++;
|
||||
len = end - p1;
|
||||
if (len >= max)
|
||||
len = max - 1;
|
||||
::memcpy(str, p1, len);
|
||||
str[len] = 0;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -44,31 +44,16 @@ class TextThread : public MyVector<BYTE, 0x200>
|
||||
public:
|
||||
TextThread(DWORD pid, DWORD hook, DWORD retn, DWORD spl, WORD num);
|
||||
~TextThread();
|
||||
//virtual void CopyLastSentence(LPWSTR str);
|
||||
//virtual void SetComment(LPWSTR);
|
||||
//virtual void ExportTextToFile(LPWSTR filename);
|
||||
|
||||
virtual DWORD GetThreadString(LPSTR str, DWORD max);
|
||||
virtual DWORD GetEntryString(LPSTR str, DWORD max = 0x200);
|
||||
|
||||
void Reset();
|
||||
void AddText(const BYTE *con,int len, bool new_line, bool space); // jichi 10/27/2013: add const; remove console; add space
|
||||
void RemoveSingleRepeatAuto(const BYTE *con, int &len); // jichi 10/27/2013: add const
|
||||
void RemoveSingleRepeatForce(BYTE *con, int &len);
|
||||
void RemoveCyclicRepeat(BYTE *&con, int &len);
|
||||
void ResetRepeatStatus();
|
||||
void AddLineBreak();
|
||||
//void ResetEditText();
|
||||
void ComboSelectCurrent();
|
||||
void UnLinkAll();
|
||||
void DispatchLastSentence();
|
||||
|
||||
//void AdjustPrevRepeat(DWORD len);
|
||||
//void PrevRepeatLength(DWORD &len);
|
||||
|
||||
//bool AddToCombo();
|
||||
bool RemoveFromCombo();
|
||||
|
||||
void SetNewLineFlag();
|
||||
void SetNewLineTimer();
|
||||
|
||||
@ -78,9 +63,6 @@ public:
|
||||
DWORD Addr() const {return tp.hook; }
|
||||
DWORD &Status() { return status; }
|
||||
WORD Number() const { return thread_number; }
|
||||
WORD &Last() { return last; }
|
||||
WORD &LinkNumber() { return link_number; }
|
||||
UINT_PTR &Timer() { return timer; }
|
||||
ThreadParameter *GetThreadParameter() { return &tp; }
|
||||
//LPCWSTR GetComment() { return comment; }
|
||||
|
||||
@ -100,9 +82,6 @@ public:
|
||||
void ClearNewLineFlag() { status &= ~BUFF_NEWLINE; }
|
||||
void ClearRepeatFlag() { status &= ~CYCLIC_REPEAT; }
|
||||
|
||||
protected:
|
||||
void AddTextDirect(const BYTE *con, int len, bool space); // jichi 10/27/2013: add const; add space; change to protected
|
||||
|
||||
private:
|
||||
ThreadParameter tp;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user