Skip to content

Commit

Permalink
1.1.15 - add max output lines config for console
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazingTwist committed Oct 20, 2021
1 parent 5144a03 commit 43b840b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions SoD_BaseMod/src/basemod/config/BTConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class BTConfig {
public int suggestionCount = 5;
public bool consoleOpenByDefault;
public bool consoleReverseOutput;
public int consoleMaxOutputLines = 256;
public string consoleDefaultCommand = "help";
public Dictionary<string, List<string>> commandBinds;

Expand Down
15 changes: 14 additions & 1 deletion SoD_BaseMod/src/basemod/console/BTConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,23 @@ public static void BuildMDHelpTable() {
}

public static void WriteLine(string line) {
if (ConfigHolder.config != null && ConfigHolder.config.consoleReverseOutput) {
bool reverseOutput = ConfigHolder.config?.consoleReverseOutput ?? false;
int maxLines = ConfigHolder.config?.consoleMaxOutputLines ?? 256;
if (reverseOutput) {
// newest lines are on top
consoleText = line + "\n" + consoleText;
string[] lines = consoleText.Split('\n');
if (lines.Length > maxLines) {
consoleText = string.Join("\n", lines, 0, maxLines);
}
} else {
// newest lines are at bottom
consoleText += line + "\n";
string[] lines = consoleText.Split('\n');
int lineCount = lines.Length;
if (lineCount > maxLines) {
consoleText = string.Join("\n", lines, lineCount - maxLines, maxLines);
}
}
}

Expand Down

0 comments on commit 43b840b

Please sign in to comment.