mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-13 15:42:50 +08:00
Delete based on character width when pressing Backspace.
This commit is contained in:
parent
d79e6adc5f
commit
bb72b44d60
@ -52,11 +52,19 @@ public static partial class AnsiConsoleExtensions
|
||||
{
|
||||
if (text.Length > 0)
|
||||
{
|
||||
var lastChar = text.Last();
|
||||
text = text.Substring(0, text.Length - 1);
|
||||
|
||||
if (mask != null)
|
||||
{
|
||||
console.Write("\b \b");
|
||||
if (UnicodeCalculator.GetWidth(lastChar) == 1)
|
||||
{
|
||||
console.Write("\b \b");
|
||||
}
|
||||
else if (UnicodeCalculator.GetWidth(lastChar) == 2)
|
||||
{
|
||||
console.Write("\b \b\b \b");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user