mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 18:40:50 +08:00 
			
		
		
		
	Delete based on character width when pressing Backspace.
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						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");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user