diff --git a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs index 0b4d03581..e713a339e 100644 --- a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs +++ b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.Handlers.cs @@ -37,8 +37,8 @@ namespace ClassicalSharp.Gui { else if( key == Key.End ) EndKey(); else if( game.Network.ServerSupportsFullCP437 && key == game.InputHandler.Keys[KeyBinding.ExtendedInput] ) - altText.SetActive( !altText.Active ); - else if( clipboardDown && !OtherKey( key ) ) return false; + altText.SetActive( !altText.Active ); + else if( clipboardDown && !OtherKey( key ) ) return false; return true; } @@ -113,22 +113,22 @@ namespace ClassicalSharp.Gui { Dispose(); Init(); } else if( !buffer.Empty && caretPos != 0 ) { - DeleteChar(); - BackspaceColourCode(); + if( !BackspaceColourCode()) + DeleteChar(); Dispose(); Init(); } } - void BackspaceColourCode() { + bool BackspaceColourCode() { // If text is XYZ%eH, backspaces to XYZ. int index = caretPos == -1 ? buffer.Length - 1 : caretPos; - if( index <= 0 ) return; + if( index <= 1 ) return false; - if( index == 0 || buffer.value[index - 1] != '%' - || !game.Drawer2D.ValidColour( buffer.value[index] ) ) - return; + if( buffer.value[index - 1] != '%' || !game.Drawer2D.ValidColour( buffer.value[index] ) ) + return false; DeleteChar(); DeleteChar(); + return true; } void DeleteChar() {