rodecomp/Source/UI/Edit/EditTextState.cpp
ragnarok-clanker 848ae448da Decompile fn_10959 (UIEditCtrl::Trim)
Batch #16006 by Yommy: 1 byte-identical, 0 confirmed by peer review.

- fn_10959 UIEditCtrl::Trim: byte-identical

Merged automatically: every function is byte-identical to the original.
2026-11-10 12:47:52 +00:00

43 lines
1.1 KiB
C++

#include "Client/Input/InputCharset.h"
#include "Client/Input/Language.h"
#include "Network/TextEncoding.h"
#include "UI/Edit/UIEditCtrl.h"
#include "UI/Window/UIWindowMgr.h"
#include <cstring>
// OFFSET: 0x00868450
// FUNCTION: fn_10959
void UIEditCtrl::Trim() {
const auto length = this->text.size();
if (static_cast<int>(length) <= this->maximum) {
return;
}
const char* next = CharNextExA(static_cast<WORD>(g_textCodePage), this->text.c_str(), 0);
while (length - std::strlen(next) <= static_cast<unsigned>(this->maximum)) {
next = CharNextExA(static_cast<WORD>(g_textCodePage), next, 0);
}
const char* previous = CharPrevExA(static_cast<WORD>(g_textCodePage), this->text.c_str(), next, 0);
this->text.resize(length - std::strlen(previous));
while (this->text.size() < static_cast<unsigned>(this->maximum)) {
this->text += " ";
}
}
// OFFSET: 0x0085A590
// FUNCTION: fn_10778
void UIEditCtrl::SelectAll() {
if (g_windowMgr.GetHoverWindow() == this) {
g_serverLanguage->Select(0, static_cast<int>(g_serverLanguage->text.size()));
} else {
this->anchor = 0;
this->cursor = static_cast<int>(this->text.size());
}
}