legacy color support

This commit is contained in:
BruceChen 2022-12-14 14:45:51 +08:00
parent 7900108763
commit 7ee08092d4
14 changed files with 116 additions and 97 deletions

View file

@ -8,7 +8,7 @@ on:
env: env:
PROJECT: "MinecraftClient" 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" compile-flags: "--self-contained=true -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"
jobs: jobs:

View file

@ -26,8 +26,8 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
RESX_SortFileContentOnSave = True
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
RESX_ShowErrorsInErrorList = False RESX_ShowErrorsInErrorList = False
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
RESX_SortFileContentOnSave = False
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -163,7 +163,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
@ -233,7 +233,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -249,7 +249,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -265,7 +265,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -291,7 +291,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -420,12 +420,12 @@ namespace MinecraftClient.ChatBots
}); });
IsConnected = true; IsConnected = true;
LogToConsole(y§l§f" + Translations.bot_DiscordBridge_connected); LogToConsole(§2§l§f" + Translations.bot_DiscordBridge_connected);
await Task.Delay(-1); await Task.Delay(-1);
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_DiscordBridge_unknown_error); LogToConsole(§4§l§f" + Translations.bot_DiscordBridge_unknown_error);
LogToConsole(e); LogToConsole(e);
return; return;
} }

View file

@ -160,7 +160,7 @@ namespace MinecraftClient.ChatBots
{ {
if (!currentArg.Contains(':')) 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; continue;
} }
@ -168,7 +168,7 @@ namespace MinecraftClient.ChatBots
if (parts.Length != 2) 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; continue;
} }
@ -177,11 +177,11 @@ namespace MinecraftClient.ChatBots
case "r": case "r":
case "radius": case "radius":
if (!int.TryParse(parts[1], NumberStyles.Any, CultureInfo.CurrentCulture, out 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) if (radius <= 0)
{ {
LogToConsole(x§1§0" + Translations.bot_farmer_invalid_radius); LogToConsole(§6§1§0" + Translations.bot_farmer_invalid_radius);
radius = 30; radius = 30;
} }
@ -194,7 +194,7 @@ namespace MinecraftClient.ChatBots
if (parts[1].Equals("true") || parts[1].Equals("1")) 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; allowUnsafe = true;
} }
else allowUnsafe = false; else allowUnsafe = false;
@ -208,7 +208,7 @@ namespace MinecraftClient.ChatBots
if (parts[1].Equals("true") || parts[1].Equals("1")) 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; allowTeleport = true;
} }
else allowTeleport = false; else allowTeleport = false;
@ -252,9 +252,9 @@ namespace MinecraftClient.ChatBots
private void MainPorcess() private void MainPorcess()
{ {
LogToConsole(y§1§f" + Translations.bot_farmer_started); LogToConsole(§2§1§f" + Translations.bot_farmer_started);
LogToConsole(y§1§f " + Translations.bot_farmer_crop_type + ": " + cropType); LogToConsole(§2§1§f " + Translations.bot_farmer_crop_type + ": " + cropType);
LogToConsole(y§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius); LogToConsole(§2§1§f " + Translations.bot_farmer_radius + ": " + farmingRadius);
while (running) while (running)
{ {

View file

@ -159,7 +159,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
@ -209,7 +209,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -232,7 +232,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole(w§l§f" + Translations.bot_TelegramBridge_canceled_sending); LogToConsole(§4§l§f" + Translations.bot_TelegramBridge_canceled_sending);
LogDebugToConsole(e); LogDebugToConsole(e);
} }
} }
@ -254,7 +254,7 @@ namespace MinecraftClient.ChatBots
} }
if (string.IsNullOrEmpty(Config.ChannelId.Trim())) 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()); botClient = new TelegramBotClient(Config.Token.Trim());
cancellationToken = new CancellationTokenSource(); cancellationToken = new CancellationTokenSource();
@ -273,12 +273,12 @@ namespace MinecraftClient.ChatBots
IsConnected = true; IsConnected = true;
SendMessage($"✅ {Translations.bot_TelegramBridge_connected}"); 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) if (Config.Authorized_Chat_Ids.Length == 0)
{ {
SendMessage($"⚠️ *{Translations.bot_TelegramBridge_missing_authorized_channels}* ⚠️"); 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; return;
} }
@ -286,7 +286,7 @@ namespace MinecraftClient.ChatBots
} }
catch (Exception e) catch (Exception e)
{ {
LogToConsole($"§w§l§f{Translations.bot_TelegramBridge_unknown_error}"); LogToConsole($"§§4§l§f{Translations.bot_TelegramBridge_unknown_error}");
LogToConsole(e); LogToConsole(e);
return; return;
} }
@ -368,7 +368,7 @@ namespace MinecraftClient.ChatBots
_ => exception.ToString() _ => exception.ToString()
}; };
LogToConsole(w§l§f" + ErrorMessage); LogToConsole(§4§l§f" + ErrorMessage);
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

View file

@ -1,5 +1,5 @@
using System; using System;
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig; using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig;
namespace MinecraftClient namespace MinecraftClient
{ {
@ -75,14 +75,37 @@ namespace MinecraftClient
public static string GetColorEscapeCode(byte R, byte G, byte B, bool foreground) 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) 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); ColorRGBA color = new(R, G, B);
int best_idx = 0; int best_idx = 0;
@ -99,7 +122,7 @@ namespace MinecraftClient
return string.Format("\u001b[{0}m", ColorMap4[best_idx].Item2 - (foreground ? 10 : 0)); 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); 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)); 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); 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); return string.Format("\u001B[{0};2;{1};{2};{3}m", (foreground ? 38 : 48), R, G, B);
default: default:

View file

@ -203,9 +203,9 @@ namespace MinecraftClient.Commands
for (int x = leftMost; x <= rightMost; ++x) for (int x = leftMost; x <= rightMost; ++x)
{ {
if (z == current.ChunkZ && x == current.ChunkX) 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) 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]; ChunkColumn? chunkColumn = world[x, z];
if (chunkColumn == null) if (chunkColumn == null)
@ -216,12 +216,12 @@ namespace MinecraftClient.Commands
sb.Append(chunkStatusStr[1]); sb.Append(chunkStatusStr[1]);
if ((z == current.ChunkZ && x == current.ChunkX) || (z == markChunkZ && x == markChunkX)) 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('\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()); handler.Log.Info(sb.ToString());
return r.SetAndReturn(Status.Done); return r.SetAndReturn(Status.Done);

View file

@ -9,7 +9,7 @@ namespace MinecraftClient.Crypto
{ {
public class AesCfb8Stream : Stream public class AesCfb8Stream : Stream
{ {
public static readonly int blockSize = 16; public const int blockSize = 16;
private readonly Aes? Aes = null; private readonly Aes? Aes = null;
private readonly FastAes? FastAes = null; private readonly FastAes? FastAes = null;
@ -109,7 +109,7 @@ namespace MinecraftClient.Crypto
if (inStreamEnded) if (inStreamEnded)
return 0; return 0;
Span<byte> blockOutput = FastAes != null ? stackalloc byte[blockSize] : null; Span<byte> blockOutput = stackalloc byte[blockSize];
byte[] inputBuf = new byte[blockSize + required]; byte[] inputBuf = new byte[blockSize + required];
Array.Copy(ReadStreamIV, inputBuf, blockSize); Array.Copy(ReadStreamIV, inputBuf, blockSize);
@ -135,18 +135,12 @@ namespace MinecraftClient.Crypto
} }
else else
{ {
OrderablePartitioner<Tuple<int, int>> rangePartitioner = curRead <= 256 ? for (int idx = readed; idx < processEnd; idx++)
Partitioner.Create(readed, processEnd, 32) : Partitioner.Create(readed, processEnd);
Parallel.ForEach(rangePartitioner, (range, loopState) =>
{
Span<byte> blockOutput = stackalloc byte[blockSize];
for (int idx = range.Item1; idx < range.Item2; idx++)
{ {
ReadOnlySpan<byte> blockInput = new(inputBuf, idx, blockSize); ReadOnlySpan<byte> blockInput = new(inputBuf, idx, blockSize);
Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None); Aes!.EncryptEcb(blockInput, blockOutput, PaddingMode.None);
buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]); buffer[outOffset + idx] = (byte)(blockOutput[0] ^ inputBuf[idx + blockSize]);
} }
});
} }
} }

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>

View file

@ -18,6 +18,7 @@ using MinecraftClient.Scripting;
using MinecraftClient.WinAPI; using MinecraftClient.WinAPI;
using Tomlet; using Tomlet;
using static MinecraftClient.Settings; using static MinecraftClient.Settings;
using static MinecraftClient.Settings.ConsoleConfigHealper.ConsoleConfig;
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig; using static MinecraftClient.Settings.MainConfigHealper.MainConfig.AdvancedConfig;
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig; using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
@ -98,9 +99,7 @@ namespace MinecraftClient
//Build information to facilitate processing of bug reports //Build information to facilitate processing of bug reports
if (BuildInfo != null) if (BuildInfo != null)
{
ConsoleIO.WriteLineFormatted("§8" + BuildInfo); ConsoleIO.WriteLineFormatted("§8" + BuildInfo);
}
//Debug input ? //Debug input ?
if (args.Length == 1 && args[0] == "--keyboard-debug") 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"; InternalConfig.Username = "New Window";
Console.Title = Config.AppVar.ExpandVars(Config.Main.Advanced.ConsoleTitle); Console.Title = Config.AppVar.ExpandVars(Config.Main.Advanced.ConsoleTitle);
@ -319,28 +318,28 @@ namespace MinecraftClient
Random random = new(); Random random = new();
{ // Test 8 bit color { // Test 8 bit color
StringBuilder sb = new(); StringBuilder sb = new();
sb.Append("[0123456789]: (8bit)["); sb.Append("[0123456789]: (vt100 8bit)[");
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255), sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255),
(byte)random.Next(255), (byte)random.Next(255),
(byte)random.Next(255), (byte)random.Next(255),
true, true,
TerminalColorDepthType.bit_8)).Append(i); ConsoleColorModeType.vt100_8bit)).Append(i);
} }
sb.Append(ColorHelper.GetResetEscapeCode()).Append(']'); sb.Append(ColorHelper.GetResetEscapeCode()).Append(']');
ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString())); ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString()));
} }
{ // Test 24 bit color { // Test 24 bit color
StringBuilder sb = new(); StringBuilder sb = new();
sb.Append("[0123456789]: (24bit)["); sb.Append("[0123456789]: (vt100 24bit)[");
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255), sb.Append(ColorHelper.GetColorEscapeCode((byte)random.Next(255),
(byte)random.Next(255), (byte)random.Next(255),
(byte)random.Next(255), (byte)random.Next(255),
true, true,
TerminalColorDepthType.bit_24)).Append(i); ConsoleColorModeType.vt100_24bit)).Append(i);
} }
sb.Append(ColorHelper.GetResetEscapeCode()).Append(']'); sb.Append(ColorHelper.GetResetEscapeCode()).Append(']');
ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString())); ConsoleIO.WriteLine(string.Format(Translations.debug_color_test, sb.ToString()));

View file

@ -119,7 +119,7 @@ namespace MinecraftClient.Protocol.Message
if (message.isSystemChat) if (message.isSystemChat)
{ {
if (Config.Signature.MarkSystemMessage) if (Config.Signature.MarkSystemMessage)
color = z §r "; // Custom color code §z : Background Gray color = §7 §§r "; // Background Gray
} }
else else
{ {
@ -128,18 +128,18 @@ namespace MinecraftClient.Protocol.Message
if (Config.Signature.ShowModifiedChat && message.unsignedContent != null) if (Config.Signature.ShowModifiedChat && message.unsignedContent != null)
{ {
if (Config.Signature.MarkModifiedMsg) if (Config.Signature.MarkModifiedMsg)
color = x §r "; // Custom color code §x : Background Yellow color = §6 §§r "; // Background Yellow
} }
else else
{ {
if (Config.Signature.MarkLegallySignedMsg) if (Config.Signature.MarkLegallySignedMsg)
color = y §r "; // Custom color code §y : Background Green color = §2 §§r "; // Background Green
} }
} }
else else
{ {
if (Config.Signature.MarkIllegallySignedMsg) if (Config.Signature.MarkIllegallySignedMsg)
color = w §r "; // Custom color code §w : Background Red color = §4 §§r "; // Background Red
} }
} }
return color + text; return color + text;

View file

@ -1085,7 +1085,8 @@ namespace MinecraftClient {
} }
/// <summary> /// <summary>
/// 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 &quot;vt100_24bit&quot; color mode..
/// </summary> /// </summary>
internal static string Console_CommandSuggestion { internal static string Console_CommandSuggestion {
get { get {
@ -1112,20 +1113,20 @@ namespace MinecraftClient {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to If a garbled code like &quot;←[0m&quot; appears on the terminal, you can turn off this.. /// Looks up a localized string similar to Use &quot;disable&quot;, &quot;legacy_4bit&quot;, &quot;vt100_4bit&quot;, &quot;vt100_8bit&quot; or &quot;vt100_24bit&quot;. If a garbled code like &quot;←[0m&quot; appears on the terminal, you can try switching to &quot;legacy_4bit&quot; mode, or just disable it..
/// </summary> /// </summary>
internal static string Console_Enable_Color { internal static string Console_General_ConsoleColorMode {
get { get {
return ResourceManager.GetString("Console.Enable_Color", resourceCulture); return ResourceManager.GetString("Console.General.ConsoleColorMode", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to You can use &quot;Ctrl+P&quot; to print out the current input and cursor position.. /// Looks up a localized string similar to You can use &quot;Ctrl+P&quot; to print out the current input and cursor position..
/// </summary> /// </summary>
internal static string Console_General_Display_Uesr_Input { internal static string Console_General_Display_Input {
get { get {
return ResourceManager.GetString("Console.General.Display_Uesr_Input", resourceCulture); return ResourceManager.GetString("Console.General.Display_Input", resourceCulture);
} }
} }
@ -1559,15 +1560,6 @@ namespace MinecraftClient {
} }
} }
/// <summary>
/// Looks up a localized string similar to Use &quot;none&quot;, &quot;bit_4&quot;, &quot;bit_8&quot; or &quot;bit_24&quot;. This can be checked by opening the debug log..
/// </summary>
internal static string Main_Advanced_TerminalColorDepth {
get {
return ResourceManager.GetString("Main.Advanced.TerminalColorDepth", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Uses more ram, cpu, bandwidth but allows you to move around.. /// Looks up a localized string similar to Uses more ram, cpu, bandwidth but allows you to move around..
/// </summary> /// </summary>

View file

@ -539,7 +539,8 @@ When this happens, you'll need to configure chat format below, see https://mccte
<value>Console-related settings.</value> <value>Console-related settings.</value>
</data> </data>
<data name="Console.CommandSuggestion" xml:space="preserve"> <data name="Console.CommandSuggestion" xml:space="preserve">
<value>The settings for command completion suggestions.</value> <value>The settings for command completion suggestions.
Custom colors are only available when using "vt100_24bit" color mode.</value>
</data> </data>
<data name="Console.CommandSuggestion.Enable" xml:space="preserve"> <data name="Console.CommandSuggestion.Enable" xml:space="preserve">
<value>Whether to display command suggestions in the console.</value> <value>Whether to display command suggestions in the console.</value>
@ -547,10 +548,10 @@ When this happens, you'll need to configure chat format below, see https://mccte
<data name="Console.CommandSuggestion.Use_Basic_Arrow" xml:space="preserve"> <data name="Console.CommandSuggestion.Use_Basic_Arrow" xml:space="preserve">
<value>Enable this option if the arrows in the command suggestions are not displayed properly in your terminal.</value> <value>Enable this option if the arrows in the command suggestions are not displayed properly in your terminal.</value>
</data> </data>
<data name="Console.Enable_Color" xml:space="preserve"> <data name="Console.General.ConsoleColorMode" xml:space="preserve">
<value>If a garbled code like "←[0m" appears on the terminal, you can turn off this.</value> <value>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.</value>
</data> </data>
<data name="Console.General.Display_Uesr_Input" xml:space="preserve"> <data name="Console.General.Display_Input" xml:space="preserve">
<value>You can use "Ctrl+P" to print out the current input and cursor position.</value> <value>You can use "Ctrl+P" to print out the current input and cursor position.</value>
</data> </data>
<data name="Head" xml:space="preserve"> <data name="Head" xml:space="preserve">
@ -701,9 +702,6 @@ Usage examples: "/tell &lt;mybot&gt; connect Server1", "/connect Server2"</value
<data name="Main.Advanced.temporary_fix_badpacket" xml:space="preserve"> <data name="Main.Advanced.temporary_fix_badpacket" xml:space="preserve">
<value>Temporary fix for Badpacket issue on some servers.</value> <value>Temporary fix for Badpacket issue on some servers.</value>
</data> </data>
<data name="Main.Advanced.TerminalColorDepth" xml:space="preserve">
<value>Use "none", "bit_4", "bit_8" or "bit_24". This can be checked by opening the debug log.</value>
</data>
<data name="Main.Advanced.terrain_and_movements" xml:space="preserve"> <data name="Main.Advanced.terrain_and_movements" xml:space="preserve">
<value>Uses more ram, cpu, bandwidth but allows you to move around.</value> <value>Uses more ram, cpu, bandwidth but allows you to move around.</value>
</data> </data>

View file

@ -605,9 +605,6 @@ namespace MinecraftClient
[TomlInlineComment("$Main.Advanced.enable_emoji$")] [TomlInlineComment("$Main.Advanced.enable_emoji$")]
public bool EnableEmoji = true; public bool EnableEmoji = true;
[TomlInlineComment("$Main.Advanced.TerminalColorDepth$")]
public TerminalColorDepthType TerminalColorDepth = TerminalColorDepthType.bit_24;
[TomlInlineComment("$Main.Advanced.MinTerminalWidth$")] [TomlInlineComment("$Main.Advanced.MinTerminalWidth$")]
public int MinTerminalWidth = 16; public int MinTerminalWidth = 16;
@ -640,8 +637,6 @@ namespace MinecraftClient
public enum ResolveSrvRecordType { no, fast, yes }; public enum ResolveSrvRecordType { no, fast, yes };
public enum ForgeConfigType { no, auto, force }; public enum ForgeConfigType { no, auto, force };
public enum TerminalColorDepthType { bit_4, bit_8, bit_24 };
} }
public struct AccountInfoConfig public struct AccountInfoConfig
@ -788,12 +783,26 @@ namespace MinecraftClient
public void OnSettingUpdate() 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.EnableColor = CommandSuggestion.Enable_Color;
ConsoleInteractive.ConsoleSuggestion.Enable24bitColor = General.ConsoleColorMode == ConsoleColorModeType.vt100_24bit;
ConsoleInteractive.ConsoleSuggestion.UseBasicArrow = CommandSuggestion.Use_Basic_Arrow; ConsoleInteractive.ConsoleSuggestion.UseBasicArrow = CommandSuggestion.Use_Basic_Arrow;
CommandSuggestion.Max_Suggestion_Width = CommandSuggestion.Max_Suggestion_Width =
@ -802,7 +811,7 @@ namespace MinecraftClient
CommandSuggestion.Max_Displayed_Suggestions = CommandSuggestion.Max_Displayed_Suggestions =
ConsoleInteractive.ConsoleSuggestion.SetMaxSuggestionCount(CommandSuggestion.Max_Displayed_Suggestions); ConsoleInteractive.ConsoleSuggestion.SetMaxSuggestionCount(CommandSuggestion.Max_Displayed_Suggestions);
// CommandSuggestion color settings // Suggestion color settings
{ {
if (!CheckColorCode(CommandSuggestion.Text_Color)) if (!CheckColorCode(CommandSuggestion.Text_Color))
{ {
@ -872,11 +881,14 @@ namespace MinecraftClient
[TomlDoNotInlineObject] [TomlDoNotInlineObject]
public class MainConfig public class MainConfig
{ {
[TomlInlineComment("$Console.Enable_Color$")] [TomlInlineComment("$Console.General.ConsoleColorMode$")]
public bool Enable_Color = true; public ConsoleColorModeType ConsoleColorMode = ConsoleColorModeType.vt100_24bit;
[TomlInlineComment("$Console.General.Display_Uesr_Input$")] [TomlInlineComment("$Console.General.Display_Input$")]
public bool Display_Uesr_Input = true; public bool Display_Input = true;
[TomlInlineComment("$Console.General.History_Input_Records$")]
public int History_Input_Records = 32;
} }
[TomlDoNotInlineObject] [TomlDoNotInlineObject]
@ -885,7 +897,6 @@ namespace MinecraftClient
[TomlInlineComment("$Console.CommandSuggestion.Enable$")] [TomlInlineComment("$Console.CommandSuggestion.Enable$")]
public bool Enable = true; public bool Enable = true;
[TomlInlineComment("$Console.Enable_Color$")]
public bool Enable_Color = true; public bool Enable_Color = true;
[TomlInlineComment("$Console.CommandSuggestion.Use_Basic_Arrow$")] [TomlInlineComment("$Console.CommandSuggestion.Use_Basic_Arrow$")]
@ -909,6 +920,8 @@ namespace MinecraftClient
public string Arrow_Symbol_Color = "#d1d5db"; public string Arrow_Symbol_Color = "#d1d5db";
} }
public enum ConsoleColorModeType { disable, legacy_4bit, vt100_4bit, vt100_8bit, vt100_24bit };
} }
} }