mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Trim whitespace and newlines when pasting text from clipboard.
This commit is contained in:
parent
fc688b53d2
commit
4d4ca0adc6
@ -237,11 +237,12 @@ namespace ClassicalSharp.Gui {
|
||||
CalculateCaretData();
|
||||
}
|
||||
|
||||
static char[] trimChars = {'\r', '\n', '\v', '\f', ' ', '\t', '\0'};
|
||||
bool OtherKey( Key key ) {
|
||||
if( key == Key.V && buffer.Length < TotalChars ) {
|
||||
string text = null;
|
||||
try {
|
||||
text = game.window.ClipboardText;
|
||||
text = game.window.ClipboardText.Trim( trimChars );
|
||||
} catch( Exception ex ) {
|
||||
ErrorHandler.LogError( "Paste from clipboard", ex );
|
||||
const string warning = "&cError while trying to paste from clipboard.";
|
||||
|
@ -86,7 +86,7 @@ namespace ClassicalSharp {
|
||||
if ( OpenTK.Configuration.RunningOnMacOS )
|
||||
return GetClipboardText();
|
||||
else
|
||||
return Clipboard.GetText();
|
||||
return Clipboard.GetText();
|
||||
}
|
||||
set {
|
||||
if ( OpenTK.Configuration.RunningOnMacOS )
|
||||
|
@ -169,7 +169,7 @@ namespace Launcher.Gui.Screens {
|
||||
mppass = "(none)";
|
||||
|
||||
ClientStartData data = new ClientStartData( user, mppass, ip, port );
|
||||
if( user.ToLowerInvariant() == "rand()" || user.ToLowerInvariant() == "random()") {
|
||||
if( Utils.CaselessEquals( user, "rand()" ) || Utils.CaselessEquals( user, "random()" ) ) {
|
||||
rnd.NextBytes( rndBytes );
|
||||
data.Username = Convert.ToBase64String( rndBytes ).TrimEnd( '=' );
|
||||
}
|
||||
|
@ -167,11 +167,12 @@ namespace Launcher.Gui.Widgets {
|
||||
if( !String.IsNullOrEmpty( Text ) )
|
||||
Clipboard.SetText( Text );
|
||||
}
|
||||
static char[] trimChars = {'\r', '\n', '\v', '\f', ' ', '\t', '\0'};
|
||||
|
||||
/// <summary> Sets the currently entered text to the contents of the system clipboard. </summary>
|
||||
/// <returns> true if a redraw is necessary, false otherwise. </returns>
|
||||
public bool CopyFromClipboard() {
|
||||
string text = Clipboard.GetText();
|
||||
string text = Clipboard.GetText().Trim( trimChars );
|
||||
if( String.IsNullOrEmpty( text ) || Text.Length >= MaxTextLength ) return false;
|
||||
|
||||
if( ClipboardFilter != null )
|
||||
|
Loading…
x
Reference in New Issue
Block a user