Optimise further, play beep on cut/copy, play beep when paste is successful.

This commit is contained in:
GoldenTails 2019-12-23 18:53:41 -06:00
parent ed847e831b
commit 1f93ab0e0f

View file

@ -10433,33 +10433,42 @@ static void M_HandleConnectIP(INT32 choice)
default: default:
l = strlen(setupm_ip); l = strlen(setupm_ip);
if (l >= 28-1)
break;
char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char
if ( ctrldown ) { if ( ctrldown ) {
switch (choice) { switch (choice) {
case 118: // ctrl+v, pasting case 118: // ctrl+v, pasting
;
char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char
if (paste != NULL) { if (paste != NULL) {
if (strlen(paste) + strlen(setupm_ip) >= 28-1) if (strlen(paste) + l >= 28-1)
paste[28-1 - strlen(setupm_ip)] = 0; paste[28-1 - l] = 0;
strcat(setupm_ip, paste); // Concat the ip field with clipboard strcat(setupm_ip, paste); // Concat the ip field with clipboard
if (strlen(paste) != 0) // Don't play sound if nothing was pasted
S_StartSound(NULL,sfx_menu1); // Tails
} }
break; break;
case 99: // ctrl+c, copying case 99: // ctrl+c, copying
I_ClipboardCopy(setupm_ip, l); I_ClipboardCopy(setupm_ip, l);
S_StartSound(NULL,sfx_menu1); // Tails
break; break;
case 120: // ctrl+x, cutting case 120: // ctrl+x, cutting
I_ClipboardCopy(setupm_ip, l); I_ClipboardCopy(setupm_ip, l);
S_StartSound(NULL,sfx_menu1); // Tails
setupm_ip[0] = 0; setupm_ip[0] = 0;
break; break;
default: // otherwise do nothing default: // otherwise do nothing
break; break;
} }
break; // break break; // don't check for typed keys
} }
if (l >= 28-1)
break;
// Rudimentary number and period enforcing - also allows letters so hostnames can be used instead // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead
if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')) if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z'))
{ {