Files
integration/Source/Integration/ConsoleOutput.cpp

59 lines
1.1 KiB
C++
Raw Normal View History

#include "ConsoleOutput.h"
#include "CoreMinimal.h"
//////////////////////////////////////////////////////////////
//
// ConsoleOutput
//
2025-12-09 02:42:13 -05:00
// Storing the text that goes in the command console.
//
//////////////////////////////////////////////////////////////
2025-12-09 02:42:13 -05:00
void UlxConsoleOutput::Truncate() {
int lines = 50;
int csize = Content.Len();
int total = 0;
for (int i = csize - 1; i >= 0; i--) {
if (Content[i] == '\n') {
total += 1;
if (total == lines) {
Content = Content.RightChop(i + 1);
return;
}
}
}
}
2025-12-09 02:42:13 -05:00
bool UlxConsoleOutput::MaybeAppendNewline() {
int csize = Content.Len();
if ((csize > 0) && (Content[csize - 1] != '\n')) {
Content += TEXT("\n");
return true;
}
else {
return false;
}
}
2025-12-09 02:42:13 -05:00
bool UlxConsoleOutput::MaybeAppendText(const FString& text) {
if (!text.IsEmpty()) {
Content += text;
return true;
}
else {
return false;
}
}
2026-03-02 18:17:50 -05:00
void UlxConsoleOutput::Append(const FString& text, bool SeparateLine) {
bool modified = false;
if (SeparateLine) modified |= MaybeAppendNewline();
modified |= MaybeAppendText(text);
2026-03-02 18:17:50 -05:00
if (SeparateLine) modified |= MaybeAppendNewline();
if (modified) {
Dirty = true;
Truncate();
}
}