From e4cae97dd77fdb1f4b4876a847aa91f802c28569 Mon Sep 17 00:00:00 2001 From: ORelio Date: Wed, 15 Apr 2020 14:51:53 +0200 Subject: [PATCH] ConsoleIO: Rewrite backspace handling Manually move the cursor instead of using the backspace character. Should help when deleting characters requiring multiple keypresses like Chinese characters. Fix attempt for #941 --- MinecraftClient/ConsoleIO.cs | 25 +++++++++++-------------- MinecraftClient/config/README.md | 8 ++++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/MinecraftClient/ConsoleIO.cs b/MinecraftClient/ConsoleIO.cs index fe57fd63..fc2af4ec 100644 --- a/MinecraftClient/ConsoleIO.cs +++ b/MinecraftClient/ConsoleIO.cs @@ -418,24 +418,18 @@ namespace MinecraftClient { try { - if (Console.CursorLeft == 0) - { - Console.CursorLeft = Console.BufferWidth - 1; - if (Console.CursorTop > 0) - Console.CursorTop--; - Console.Write(' '); - Console.CursorLeft = Console.BufferWidth - 1; - if (Console.CursorTop > 0) - Console.CursorTop--; - } - else Console.Write("\b \b"); + GoBack(); + Console.Write(' '); + GoBack(); } catch (ArgumentOutOfRangeException) { /* Console was resized!? */ } buffer = buffer.Substring(0, buffer.Length - 1); if (buffer2.Length > 0) { - Console.Write(buffer2 + " \b"); + Console.Write(buffer2); + Console.Write(' '); + GoBack(); for (int i = 0; i < buffer2.Length; i++) { GoBack(); @@ -457,7 +451,10 @@ namespace MinecraftClient if (Console.CursorTop > 0) Console.CursorTop--; } - else Console.Write('\b'); + else + { + Console.CursorLeft = Console.CursorLeft - 1; + } } catch (ArgumentOutOfRangeException) { /* Console was resized!? */ } } @@ -471,7 +468,7 @@ namespace MinecraftClient { buffer2 = "" + buffer[buffer.Length - 1] + buffer2; buffer = buffer.Substring(0, buffer.Length - 1); - Console.Write('\b'); + GoBack(); } } diff --git a/MinecraftClient/config/README.md b/MinecraftClient/config/README.md index 6e615444..e799c6e7 100644 --- a/MinecraftClient/config/README.md +++ b/MinecraftClient/config/README.md @@ -288,10 +288,10 @@ would not have been possible without the help of talented contributors: **Bug Hunters:** - 1092CQ, ambysdotnet, bearbear12345, c0dei, Cat7373, Darkaegis, dbear20, DigitalSniperz, - doranchak, drXor, FantomHD, gerik43, ibspa, iTzMrpitBull, JamieSinn, k3ldon, KenXeiko, - link3321, lyze237, mattman00000, Nicconyancat, Pokechu22, ridgewell, Ryan6578, Solethia, - TNT-UP, TorchRJ, TRTrident, WeedIsGood, xp9kus, Yoann166 + 1092CQ, ambysdotnet, bearbear12345, c0dei, Cat7373, Chtholly, Darkaegis, dbear20, + DigitalSniperz, doranchak, drXor, FantomHD, gerik43, ibspa, iTzMrpitBull, JamieSinn, + k3ldon, KenXeiko, link3321, lyze237, mattman00000, Nicconyancat, Pokechu22, ridgewell, + Ryan6578, Solethia, TNT-UP, TorchRJ, TRTrident, WeedIsGood, xp9kus, Yoann166 **Code contributions:**