20 lines
399 B
C
20 lines
399 B
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
namespace XCEngine::UI::Editor::Support {
|
||
|
|
|
||
|
|
inline std::string TruncateText(const std::string& text, std::size_t maxLength) {
|
||
|
|
if (text.size() <= maxLength) {
|
||
|
|
return text;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (maxLength <= 3u) {
|
||
|
|
return text.substr(0u, maxLength);
|
||
|
|
}
|
||
|
|
|
||
|
|
return text.substr(0u, maxLength - 3u) + "...";
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace XCEngine::UI::Editor::Support
|