From 7ee08092d4f4888fb4465723bdef3bc91cf69795 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Wed, 14 Dec 2022 14:45:51 +0800 Subject: [PATCH] legacy color support --- .github/workflows/build-and-release.yml | 2 +- MinecraftClient.sln | 4 +- MinecraftClient/ChatBots/DiscordBridge.cs | 14 +++---- MinecraftClient/ChatBots/Farmer.cs | 18 ++++----- MinecraftClient/ChatBots/TelegramBridge.cs | 16 ++++---- MinecraftClient/ColorHelper.cs | 35 ++++++++++++++--- MinecraftClient/Commands/Chunk.cs | 8 ++-- MinecraftClient/Crypto/AesCfb8Stream.cs | 20 ++++------ MinecraftClient/MinecraftClient.csproj | 2 +- MinecraftClient/Program.cs | 13 +++---- .../Protocol/Message/ChatParser.cs | 8 ++-- .../ConfigComments/ConfigComments.Designer.cs | 22 ++++------- .../ConfigComments/ConfigComments.resx | 12 +++--- MinecraftClient/Settings.cs | 39 ++++++++++++------- 14 files changed, 116 insertions(+), 97 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0ab15085..5e74359a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,7 +8,7 @@ on: env: PROJECT: "MinecraftClient" - target-version: "net6.0" + target-version: "net7.0" compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None" jobs: diff --git a/MinecraftClient.sln b/MinecraftClient.sln index d769e6ae..8f0049d8 100644 --- a/MinecraftClient.sln +++ b/MinecraftClient.sln @@ -26,8 +26,8 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - RESX_SortFileContentOnSave = True - SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487} RESX_ShowErrorsInErrorList = False + SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487} + RESX_SortFileContentOnSave = False EndGlobalSection EndGlobal diff --git a/MinecraftClient/ChatBots/DiscordBridge.cs b/MinecraftClient/ChatBots/DiscordBridge.cs index b9d5a50e..b46ad770 100644 --- a/MinecraftClient/ChatBots/DiscordBridge.cs +++ b/MinecraftClient/ChatBots/DiscordBridge.cs @@ -163,7 +163,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogDebugToConsole(e); } @@ -233,7 +233,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogDebugToConsole(e); } } @@ -249,7 +249,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogDebugToConsole(e); } } @@ -265,7 +265,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogDebugToConsole(e); } } @@ -291,7 +291,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogDebugToConsole(e); } } @@ -420,12 +420,12 @@ namespace MinecraftClient.ChatBots }); IsConnected = true; - LogToConsole("§y§l§f" + Translations.bot_DiscordBridge_connected); + LogToConsole("§§2§l§f" + Translations.bot_DiscordBridge_connected); await Task.Delay(-1); } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_DiscordBridge_unknown_error); + LogToConsole("§§4§l§f" + Translations.bot_DiscordBridge_unknown_error); LogToConsole(e); return; } diff --git a/MinecraftClient/ChatBots/Farmer.cs b/MinecraftClient/ChatBots/Farmer.cs index 072fe270..b035e22c 100644 --- a/MinecraftClient/ChatBots/Farmer.cs +++ b/MinecraftClient/ChatBots/Farmer.cs @@ -160,7 +160,7 @@ namespace MinecraftClient.ChatBots { if (!currentArg.Contains(':')) { - LogToConsole("§x§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg)); + LogToConsole("§§6§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg)); continue; } @@ -168,7 +168,7 @@ namespace MinecraftClient.ChatBots if (parts.Length != 2) { - LogToConsole("§x§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg)); + LogToConsole("§§6§1§0" + string.Format(Translations.bot_farmer_warining_invalid_parameter, currentArg)); continue; } @@ -177,11 +177,11 @@ namespace MinecraftClient.ChatBots case "r": case "radius": if (!int.TryParse(parts[1], NumberStyles.Any, CultureInfo.CurrentCulture, out radius)) - LogToConsole("§x§1§0" + Translations.bot_farmer_invalid_radius); + LogToConsole("§§6§1§0" + Translations.bot_farmer_invalid_radius); if (radius <= 0) { - LogToConsole("§x§1§0" + Translations.bot_farmer_invalid_radius); + LogToConsole("§§6§1§0" + Translations.bot_farmer_invalid_radius); radius = 30; } @@ -194,7 +194,7 @@ namespace MinecraftClient.ChatBots if (parts[1].Equals("true") || parts[1].Equals("1")) { - LogToConsole("§x§1§0" + Translations.bot_farmer_warining_force_unsafe); + LogToConsole("§§6§1§0" + Translations.bot_farmer_warining_force_unsafe); allowUnsafe = true; } else allowUnsafe = false; @@ -208,7 +208,7 @@ namespace MinecraftClient.ChatBots if (parts[1].Equals("true") || parts[1].Equals("1")) { - LogToConsole("§w§1§f" + Translations.bot_farmer_warining_allow_teleport); + LogToConsole("§§4§1§f" + Translations.bot_farmer_warining_allow_teleport); allowTeleport = true; } else allowTeleport = false; @@ -252,9 +252,9 @@ namespace MinecraftClient.ChatBots private void MainPorcess() { - LogToConsole("§y§1§f" + Translations.bot_farmer_started); - LogToConsole("§y§1§f " + Translations.bot_farmer_crop_type + ": " + cropType); - LogToConsole("§y§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius); + LogToConsole("§§2§1§f" + Translations.bot_farmer_started); + LogToConsole("§§2§1§f " + Translations.bot_farmer_crop_type + ": " + cropType); + LogToConsole("§§2§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius); while (running) { diff --git a/MinecraftClient/ChatBots/TelegramBridge.cs b/MinecraftClient/ChatBots/TelegramBridge.cs index 6139a8d0..eac48542 100644 --- a/MinecraftClient/ChatBots/TelegramBridge.cs +++ b/MinecraftClient/ChatBots/TelegramBridge.cs @@ -159,7 +159,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogDebugToConsole(e); } @@ -209,7 +209,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogDebugToConsole(e); } } @@ -232,7 +232,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_canceled_sending); + LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogDebugToConsole(e); } } @@ -254,7 +254,7 @@ namespace MinecraftClient.ChatBots } if (string.IsNullOrEmpty(Config.ChannelId.Trim())) - LogToConsole("§w§l§f" + Translations.bot_TelegramBridge_missing_channel_id); + LogToConsole("§§4§l§f" + Translations.bot_TelegramBridge_missing_channel_id); botClient = new TelegramBotClient(Config.Token.Trim()); cancellationToken = new CancellationTokenSource(); @@ -273,12 +273,12 @@ namespace MinecraftClient.ChatBots IsConnected = true; SendMessage($"✅ {Translations.bot_TelegramBridge_connected}"); - LogToConsole($"§y§l§f{Translations.bot_TelegramBridge_connected}"); + LogToConsole($"§§2§l§f{Translations.bot_TelegramBridge_connected}"); if (Config.Authorized_Chat_Ids.Length == 0) { SendMessage($"⚠️ *{Translations.bot_TelegramBridge_missing_authorized_channels}* ⚠️"); - LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_missing_authorized_channels}"); + LogToConsole($"§§4§l§f{Translations.bot_TelegramBridge_missing_authorized_channels}"); return; } @@ -286,7 +286,7 @@ namespace MinecraftClient.ChatBots } catch (Exception e) { - LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_unknown_error}"); + LogToConsole($"§§4§l§f{Translations.bot_TelegramBridge_unknown_error}"); LogToConsole(e); return; } @@ -368,7 +368,7 @@ namespace MinecraftClient.ChatBots _ => exception.ToString() }; - LogToConsole("§w§l§f" + ErrorMessage); + LogToConsole("§§4§l§f" + ErrorMessage); return Task.CompletedTask; } } diff --git a/MinecraftClient/ColorHelper.cs b/MinecraftClient/ColorHelper.cs index 3f35b304..fe91a780 100644 --- a/MinecraftClient/ColorHelper.cs +++ b/MinecraftClient/ColorHelper.cs @@ -1,5 +1,5 @@ using System; -using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig; +using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig; namespace MinecraftClient { @@ -75,14 +75,37 @@ namespace MinecraftClient public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground) { - return GetColorEscapeCode(R, G, B, foreground, Settings.Config.Main.Advanced.TerminalColorDepth); + return GetColorEscapeCode(R, G, B, foreground, Settings.Config.Console.General.ConsoleColorMode); } - public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground, TerminalColorDepthType colorDepth) + public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground, ConsoleColorModeType colorDepth) { switch (colorDepth) { - case TerminalColorDepthType.bit_4: + case ConsoleColorModeType.disable: + return string.Empty; + + case ConsoleColorModeType.legacy_4bit: + { + ColorRGBA color = new(R, G, B); + int best_idx = 0; + double min_distance = ColorMap4[0].Item1.Distance(color); + for (int i = 1; i < ColorMap4.Length; ++i) + { + double distance = ColorMap4[i].Item1.Distance(color); + if (distance < min_distance) + { + min_distance = distance; + best_idx = i; + } + } + if (foreground) + return $"§{best_idx:X}"; + else + return $"§§{best_idx:X}"; + } + + case ConsoleColorModeType.vt100_4bit: { ColorRGBA color = new(R, G, B); int best_idx = 0; @@ -99,7 +122,7 @@ namespace MinecraftClient return string.Format("\u001b[{0}m", ColorMap4[best_idx].Item2 - (foreground ? 10 : 0)); } - case TerminalColorDepthType.bit_8: + case ConsoleColorModeType.vt100_8bit: { ColorRGBA color = new(R, G, B); int R_idx = (int)(R <= 95 ? Math.Round(R / 95.0) : 1 + Math.Round((R - 95.0) / 40.0)); @@ -126,7 +149,7 @@ namespace MinecraftClient return string.Format("\u001B[{0};5;{1}m", (foreground ? 38 : 48), ColorMap8[best_idx].Item2); } - case TerminalColorDepthType.bit_24: + case ConsoleColorModeType.vt100_24bit: return string.Format("\u001B[{0};2;{1};{2};{3}m", (foreground ? 38 : 48), R, G, B); default: diff --git a/MinecraftClient/Commands/Chunk.cs b/MinecraftClient/Commands/Chunk.cs index 3452716b..cdc26e14 100644 --- a/MinecraftClient/Commands/Chunk.cs +++ b/MinecraftClient/Commands/Chunk.cs @@ -203,9 +203,9 @@ namespace MinecraftClient.Commands for (int x = leftMost; x <= rightMost; ++x) { if (z == current.ChunkZ && x == current.ChunkX) - sb.Append("§z"); // Player Location: background gray + sb.Append("§§7"); // Player Location: background gray else if (z == markChunkZ && x == markChunkX) - sb.Append("§w"); // Marked chunk: background red + sb.Append("§§4"); // Marked chunk: background red ChunkColumn? chunkColumn = world[x, z]; if (chunkColumn == null) @@ -216,12 +216,12 @@ namespace MinecraftClient.Commands sb.Append(chunkStatusStr[1]); if ((z == current.ChunkZ && x == current.ChunkX) || (z == markChunkZ && x == markChunkX)) - sb.Append("§r"); // Reset background color + sb.Append("§§r"); // Reset background color } sb.Append('\n'); } - sb.Append(string.Format(Translations.cmd_chunk_icon, "§z §r", "§w §r", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2])); + sb.Append(string.Format(Translations.cmd_chunk_icon, "§§7 §§r", "§§4 §§r", chunkStatusStr[0], chunkStatusStr[1], chunkStatusStr[2])); handler.Log.Info(sb.ToString()); return r.SetAndReturn(Status.Done); diff --git a/MinecraftClient/Crypto/AesCfb8Stream.cs b/MinecraftClient/Crypto/AesCfb8Stream.cs index f653546c..d50aaa54 100644 --- a/MinecraftClient/Crypto/AesCfb8Stream.cs +++ b/MinecraftClient/Crypto/AesCfb8Stream.cs @@ -9,7 +9,7 @@ namespace MinecraftClient.Crypto { public class AesCfb8Stream : Stream { - public static readonly int blockSize = 16; + public const int blockSize = 16; private readonly Aes? Aes = null; private readonly FastAes? FastAes = null; @@ -109,7 +109,7 @@ namespace MinecraftClient.Crypto if (inStreamEnded) return 0; - Span blockOutput = FastAes != null ? stackalloc byte[blockSize] : null; + Span blockOutput = stackalloc byte[blockSize]; byte[] inputBuf = new byte[blockSize + required]; Array.Copy(ReadStreamIV, inputBuf, blockSize); @@ -135,18 +135,12 @@ namespace MinecraftClient.Crypto } else { - OrderablePartitioner> rangePartitioner = curRead <= 256 ? - Partitioner.Create(readed, processEnd, 32) : Partitioner.Create(readed, processEnd); - Parallel.ForEach(rangePartitioner, (range, loopState) => + for (int idx = readed; idx < processEnd; idx++) { - Span blockOutput = stackalloc byte[blockSize]; - for (int idx = range.Item1; idx < range.Item2; idx++) - { - ReadOnlySpan blockInput = new(inputBuf, idx, blockSize); - Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None); - buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]); - } - }); + ReadOnlySpan blockInput = new(inputBuf, idx, blockSize); + Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None); + buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]); + } } } diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 95597b42..b0faada9 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -1,6 +1,6 @@  - net6.0 + net7.0 Exe publish\ false diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index cd525fb4..503f4f40 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -18,6 +18,7 @@ using MinecraftClient.Scripting; using MinecraftClient.WinAPI; using Tomlet; using static MinecraftClient.Settings; +using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig; using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig; using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig; @@ -98,9 +99,7 @@ namespace MinecraftClient //Build information to facilitate processing of bug reports if (BuildInfo != null) - { ConsoleIO.WriteLineFormatted("§8" + BuildInfo); - } //Debug input ? if (args.Length == 1 && args[0] == "--keyboard-debug") @@ -288,7 +287,7 @@ namespace MinecraftClient } } - if (Config.Main.Advanced.ConsoleTitle != "") + if (!string.IsNullOrWhiteSpace(Config.Main.Advanced.ConsoleTitle)) { InternalConfig.Username = "New Window"; Console.Title = Config.AppVar.ExpandVars(Config.Main.Advanced.ConsoleTitle); @@ -319,28 +318,28 @@ namespace MinecraftClient Random random = new(); { // Test 8 bit color StringBuilder sb = new(); - sb.Append("[0123456789]: (8bit)["); + sb.Append("[0123456789]: (vt100 8bit)["); for (int i = 0; i < 10; ++i) { sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255), (byte)random.Next(255), (byte)random.Next(255), true, - TerminalColorDepthType.bit_8)).Append(i); + ConsoleColorModeType.vt100_8bit)).Append(i); } sb.Append(ColorHelper.GetResetEscapeCode()).Append(']'); ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString())); } { // Test 24 bit color StringBuilder sb = new(); - sb.Append("[0123456789]: (24bit)["); + sb.Append("[0123456789]: (vt100 24bit)["); for (int i = 0; i < 10; ++i) { sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255), (byte)random.Next(255), (byte)random.Next(255), true, - TerminalColorDepthType.bit_24)).Append(i); + ConsoleColorModeType.vt100_24bit)).Append(i); } sb.Append(ColorHelper.GetResetEscapeCode()).Append(']'); ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString())); diff --git a/MinecraftClient/Protocol/Message/ChatParser.cs b/MinecraftClient/Protocol/Message/ChatParser.cs index 3df06572..2aa87b00 100644 --- a/MinecraftClient/Protocol/Message/ChatParser.cs +++ b/MinecraftClient/Protocol/Message/ChatParser.cs @@ -119,7 +119,7 @@ namespace MinecraftClient.Protocol.Message if (message.isSystemChat) { if (Config.Signature.MarkSystemMessage) - color = "§z §r "; // Custom color code §z : Background Gray + color = "§§7 §§r "; // Background Gray } else { @@ -128,18 +128,18 @@ namespace MinecraftClient.Protocol.Message if (Config.Signature.ShowModifiedChat && message.unsignedContent != null) { if (Config.Signature.MarkModifiedMsg) - color = "§x §r "; // Custom color code §x : Background Yellow + color = "§§6 §§r "; // Background Yellow } else { if (Config.Signature.MarkLegallySignedMsg) - color = "§y §r "; // Custom color code §y : Background Green + color = "§§2 §§r "; // Background Green } } else { if (Config.Signature.MarkIllegallySignedMsg) - color = "§w §r "; // Custom color code §w : Background Red + color = "§§4 §§r "; // Background Red } } return color + text; diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs index bf0cbc7f..8f358c62 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.Designer.cs @@ -1085,7 +1085,8 @@ namespace MinecraftClient { } /// - /// Looks up a localized string similar to The settings for command completion suggestions.. + /// Looks up a localized string similar to The settings for command completion suggestions. + ///Custom colors are only available when using "vt100_24bit" color mode.. /// internal static string Console_CommandSuggestion { get { @@ -1112,20 +1113,20 @@ namespace MinecraftClient { } /// - /// Looks up a localized string similar to If a garbled code like "←[0m" appears on the terminal, you can turn off this.. + /// Looks up a localized string similar to Use "disable", "legacy_4bit", "vt100_4bit", "vt100_8bit" or "vt100_24bit". If a garbled code like "←[0m" appears on the terminal, you can try switching to "legacy_4bit" mode, or just disable it.. /// - internal static string Console_Enable_Color { + internal static string Console_General_ConsoleColorMode { get { - return ResourceManager.GetString("Console.Enable_Color", resourceCulture); + return ResourceManager.GetString("Console.General.ConsoleColorMode", resourceCulture); } } /// /// Looks up a localized string similar to You can use "Ctrl+P" to print out the current input and cursor position.. /// - internal static string Console_General_Display_Uesr_Input { + internal static string Console_General_Display_Input { get { - return ResourceManager.GetString("Console.General.Display_Uesr_Input", resourceCulture); + return ResourceManager.GetString("Console.General.Display_Input", resourceCulture); } } @@ -1559,15 +1560,6 @@ namespace MinecraftClient { } } - /// - /// Looks up a localized string similar to Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log.. - /// - internal static string Main_Advanced_TerminalColorDepth { - get { - return ResourceManager.GetString("Main.Advanced.TerminalColorDepth", resourceCulture); - } - } - /// /// Looks up a localized string similar to Uses more ram, cpu, bandwidth but allows you to move around.. /// diff --git a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx index 1b71fcd9..bd3a27de 100644 --- a/MinecraftClient/Resources/ConfigComments/ConfigComments.resx +++ b/MinecraftClient/Resources/ConfigComments/ConfigComments.resx @@ -539,7 +539,8 @@ When this happens, you'll need to configure chat format below, see https://mccte Console-related settings. - The settings for command completion suggestions. + The settings for command completion suggestions. +Custom colors are only available when using "vt100_24bit" color mode. Whether to display command suggestions in the console. @@ -547,10 +548,10 @@ When this happens, you'll need to configure chat format below, see https://mccte Enable this option if the arrows in the command suggestions are not displayed properly in your terminal. - - If a garbled code like "←[0m" appears on the terminal, you can turn off this. + + Use "disable", "legacy_4bit", "vt100_4bit", "vt100_8bit" or "vt100_24bit". If a garbled code like "←[0m" appears on the terminal, you can try switching to "legacy_4bit" mode, or just disable it. - + You can use "Ctrl+P" to print out the current input and cursor position. @@ -701,9 +702,6 @@ Usage examples: "/tell <mybot> connect Server1", "/connect Server2" Temporary fix for Badpacket issue on some servers. - - Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log. - Uses more ram, cpu, bandwidth but allows you to move around. diff --git a/MinecraftClient/Settings.cs b/MinecraftClient/Settings.cs index 0a07bb40..8ddd556b 100644 --- a/MinecraftClient/Settings.cs +++ b/MinecraftClient/Settings.cs @@ -605,9 +605,6 @@ namespace MinecraftClient [TomlInlineComment("$Main.Advanced.enable_emoji$")] public bool EnableEmoji = true; - [TomlInlineComment("$Main.Advanced.TerminalColorDepth$")] - public TerminalColorDepthType TerminalColorDepth = TerminalColorDepthType.bit_24; - [TomlInlineComment("$Main.Advanced.MinTerminalWidth$")] public int MinTerminalWidth = 16; @@ -640,8 +637,6 @@ namespace MinecraftClient public enum ResolveSrvRecordType { no, fast, yes }; public enum ForgeConfigType { no, auto, force }; - - public enum TerminalColorDepthType { bit_4, bit_8, bit_24 }; } public struct AccountInfoConfig @@ -788,12 +783,26 @@ namespace MinecraftClient public void OnSettingUpdate() { - ConsoleInteractive.ConsoleWriter.EnableColor = General.Enable_Color; + // Reader + ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Input; - ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Uesr_Input; + // Writer + ConsoleInteractive.ConsoleWriter.EnableColor = General.ConsoleColorMode != ConsoleColorModeType.disable; + + ConsoleInteractive.ConsoleWriter.UseVT100ColorCode = General.ConsoleColorMode != ConsoleColorModeType.legacy_4bit; + + // Buffer + General.History_Input_Records = + ConsoleInteractive.ConsoleBuffer.SetBackreadBufferLimit(General.History_Input_Records); + + // Suggestion + if (General.ConsoleColorMode == ConsoleColorModeType.disable) + CommandSuggestion.Enable_Color = false; ConsoleInteractive.ConsoleSuggestion.EnableColor = CommandSuggestion.Enable_Color; + ConsoleInteractive.ConsoleSuggestion.Enable24bitColor = General.ConsoleColorMode == ConsoleColorModeType.vt100_24bit; + ConsoleInteractive.ConsoleSuggestion.UseBasicArrow = CommandSuggestion.Use_Basic_Arrow; CommandSuggestion.Max_Suggestion_Width = @@ -802,7 +811,7 @@ namespace MinecraftClient CommandSuggestion.Max_Displayed_Suggestions = ConsoleInteractive.ConsoleSuggestion.SetMaxSuggestionCount(CommandSuggestion.Max_Displayed_Suggestions); - // CommandSuggestion color settings + // Suggestion color settings { if (!CheckColorCode(CommandSuggestion.Text_Color)) { @@ -872,11 +881,14 @@ namespace MinecraftClient [TomlDoNotInlineObject] public class MainConfig { - [TomlInlineComment("$Console.Enable_Color$")] - public bool Enable_Color = true; + [TomlInlineComment("$Console.General.ConsoleColorMode$")] + public ConsoleColorModeType ConsoleColorMode = ConsoleColorModeType.vt100_24bit; - [TomlInlineComment("$Console.General.Display_Uesr_Input$")] - public bool Display_Uesr_Input = true; + [TomlInlineComment("$Console.General.Display_Input$")] + public bool Display_Input = true; + + [TomlInlineComment("$Console.General.History_Input_Records$")] + public int History_Input_Records = 32; } [TomlDoNotInlineObject] @@ -885,7 +897,6 @@ namespace MinecraftClient [TomlInlineComment("$Console.CommandSuggestion.Enable$")] public bool Enable = true; - [TomlInlineComment("$Console.Enable_Color$")] public bool Enable_Color = true; [TomlInlineComment("$Console.CommandSuggestion.Use_Basic_Arrow$")] @@ -909,6 +920,8 @@ namespace MinecraftClient public string Arrow_Symbol_Color = "#d1d5db"; } + + public enum ConsoleColorModeType { disable, legacy_4bit, vt100_4bit, vt100_8bit, vt100_24bit }; } }