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
This commit is contained in:
ORelio 2020-04-15 14:51:53 +02:00
parent 0acb17e105
commit e4cae97dd7
2 changed files with 15 additions and 18 deletions

View file

@ -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();
}
}