This commit is contained in:
Tristan 'Natrist' Cormier 2025-12-06 17:33:32 -05:00 committed by GitHub
commit fdc4c1b757
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 22 deletions

View File

@ -502,7 +502,7 @@ void CSimpleEditBox::Insert(uint32_t chr) {
} }
} }
void CSimpleEditBox::Insert(const char* a2, const char* a3, int32_t a4, int32_t a5, int32_t a6) { void CSimpleEditBox::Insert(const char* utf8string, const char* taintedstring, int32_t dispatchEvent, int32_t isIME, int32_t userInput) {
if ( if (
(this->m_textInfo[this->m_cursorPos] & 0x80000000) (this->m_textInfo[this->m_cursorPos] & 0x80000000)
&& this->m_cursorPos > 0 && this->m_cursorPos > 0
@ -512,49 +512,49 @@ void CSimpleEditBox::Insert(const char* a2, const char* a3, int32_t a4, int32_t
} }
if (this->m_highlightLeft != this->m_highlightRight) { if (this->m_highlightLeft != this->m_highlightRight) {
this->DeleteHighlight(a6); this->DeleteHighlight(userInput);
} }
if (!a2) { if (!utf8string) {
a2 = ""; utf8string = "";
} }
const char* v10 = a2; const char* v10 = utf8string;
if (this->m_numeric && !a5 && *v10) { if (this->m_numeric && !isIME && *v10) {
while (*v10) { while (*v10) {
int32_t v33; int32_t chars;
if (SUniSGetUTF8(reinterpret_cast<const uint8_t*>(a2), &v33) - 48 > 9) { if (SUniSGetUTF8(reinterpret_cast<const uint8_t*>(utf8string), &chars) - 48 > 9) {
return; return;
} }
v10 += v33; v10 += chars;
} }
} }
int32_t v11 = SStrLen(a2); int32_t amount = SStrLen(utf8string);
this->GrowText(this->m_textLength + v11); this->GrowText(this->m_textLength + amount);
char* v14 = this->m_text + this->m_cursorPos; char* insertPos = this->m_text + this->m_cursorPos;
if (this->m_cursorPos < this->m_textLength) { if (this->m_cursorPos < this->m_textLength) {
memcpy(v14 + v11, v14, this->m_textLength - this->m_cursorPos); memcpy(insertPos + amount, insertPos, this->m_textLength - this->m_cursorPos);
} }
memcpy(v14, a2, v11); memcpy(insertPos, utf8string, amount);
this->m_textLength += v11; this->m_textLength += amount;
*(this->m_text + this->m_textLength) = 0; *(this->m_text + this->m_textLength) = 0;
int32_t v31 = this->m_cursorPos; int32_t v31 = this->m_cursorPos;
this->m_cursorPos += v11; this->m_cursorPos += amount;
this->UpdateTextInfo(); this->UpdateTextInfo();
this->m_dirtyFlags |= (0x1 | 0x4); this->m_dirtyFlags |= (0x1 | 0x4);
a6 ? this->m_dirtyFlags &= ~0x8 : this->m_dirtyFlags |= 0x8; userInput ? this->m_dirtyFlags &= ~0x8 : this->m_dirtyFlags |= 0x8;
if (this->m_textLengthMax >= 0 && this->m_textLength > this->m_textLengthMax) { if (this->m_textLengthMax >= 0 && this->m_textLength > this->m_textLengthMax) {
// TODO // TODO
@ -564,7 +564,7 @@ void CSimpleEditBox::Insert(const char* a2, const char* a3, int32_t a4, int32_t
// TODO // TODO
} }
if (a5) { if (isIME) {
this->m_highlightLeft = v31; this->m_highlightLeft = v31;
this->m_highlightRight = std::min(this->m_textLength, this->m_cursorPos); this->m_highlightRight = std::min(this->m_textLength, this->m_cursorPos);
this->m_dirtyFlags |= 2u; this->m_dirtyFlags |= 2u;
@ -572,11 +572,11 @@ void CSimpleEditBox::Insert(const char* a2, const char* a3, int32_t a4, int32_t
// TODO // TODO
// if (!this->m_intC && this->m_textLength > 0) { // if (!this->m_intC && this->m_textLength > 0) {
// this->m_intC = a3; // this->m_intC = taintedstring;
// } // }
if (a4) { if (dispatchEvent) {
this->RunOnCharScript(a2); this->RunOnCharScript(utf8string);
// TODO // TODO
// - check for spaces and run onSpacePressed script // - check for spaces and run onSpacePressed script

View File

@ -103,7 +103,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
int32_t GetNumToLen(int32_t offset, int32_t amount, bool a4); int32_t GetNumToLen(int32_t offset, int32_t amount, bool a4);
void GrowText(int32_t size); void GrowText(int32_t size);
void Insert(uint32_t chr); void Insert(uint32_t chr);
void Insert(const char* a2, const char* a3, int32_t a4, int32_t a5, int32_t a6); void Insert(const char* utf8string, const char* taintedstring, int32_t dispatchEvent, int32_t isIME, int32_t userInput);
int32_t IsCurrentFocus(); int32_t IsCurrentFocus();
void Move(int32_t distance, int32_t highlight); void Move(int32_t distance, int32_t highlight);
void MoveBackward(int32_t highlight); void MoveBackward(int32_t highlight);