Skip to content

Commit

Permalink
CLI: Reset color instead of explicitly setting foreground color to wh…
Browse files Browse the repository at this point in the history
…ite, to produce better output on terminals using non-dark colour themes
  • Loading branch information
UnknownShadow200 committed Aug 8, 2022
1 parent d37eb29 commit 2f803e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
23 changes: 15 additions & 8 deletions CLI/Program.cs
Expand Up @@ -209,20 +209,27 @@ public static class Program {
char col = 'S';
message = UIHelpers.Format(message);

while (index < message.Length) {
while (index < message.Length)
{
char curCol = col;
string part = UIHelpers.OutputPart(ref col, ref index, message);
if (part.Length > 0) {
Console.ForegroundColor = GetConsoleCol(curCol);
Console.Write(part);

if (part.Length == 0) continue;
ConsoleColor color = GetConsoleColor(curCol);

if (color == ConsoleColor.White) {
Console.ResetColor();
} else {
Console.ForegroundColor = color;
}
Console.Write(part);
}
Console.ForegroundColor = ConsoleColor.White;

Console.ResetColor();
Console.WriteLine();
}

static ConsoleColor GetConsoleCol(char c) {
static ConsoleColor GetConsoleColor(char c) {
if (c == 'S') return ConsoleColor.White;
Colors.Map(ref c);

Expand All @@ -246,7 +253,7 @@ public static class Program {

default:
if (!Colors.IsDefined(c)) return ConsoleColor.White;
return GetConsoleCol(Colors.Get(c).Fallback);
return GetConsoleColor(Colors.Get(c).Fallback);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Server/OperatingSystem.cs
Expand Up @@ -187,6 +187,7 @@ class UnixOS : IOperatingSystem
byte** args = stackalloc byte*[2];
args[0] = path;
args[1] = (byte*)IntPtr.Zero;
// TODO add null argument at end, see if that works

byte[] tmp = Encoding.UTF8.GetBytes(Server.GetRestartPath());
Marshal.Copy(tmp, 0, (IntPtr)path, tmp.Length);
Expand Down

0 comments on commit 2f803e1

Please sign in to comment.