66 lines
1.2 KiB
C++
66 lines
1.2 KiB
C++
#include "ConsoleOutput.h"
|
|
#include "CoreMinimal.h"
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
//
|
|
// ConsoleOutput
|
|
//
|
|
// Storing the text that goes in the unreal console.
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
void FlxConsoleOutput::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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool FlxConsoleOutput::MaybeAppendNewline() {
|
|
int csize = Content.Len();
|
|
if ((csize > 0) && (Content[csize - 1] != '\n')) {
|
|
Content += TEXT("\n");
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool FlxConsoleOutput::MaybeAppendText(const FString& text) {
|
|
if (!text.IsEmpty()) {
|
|
Content += text;
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void FlxConsoleOutput::Append(const FString& text) {
|
|
bool modified = MaybeAppendText(text);
|
|
if (modified) {
|
|
Dirty = true;
|
|
Truncate();
|
|
}
|
|
}
|
|
|
|
void FlxConsoleOutput::AppendLine(const FString& text) {
|
|
bool modified = MaybeAppendNewline();
|
|
modified |= MaybeAppendText(text);
|
|
modified |= MaybeAppendNewline();
|
|
if (modified) {
|
|
Dirty = true;
|
|
Truncate();
|
|
}
|
|
}
|