mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Revert "Merge branch 'master' into master"
This reverts commitb91fab3474, reversing changes made to78812727c7.
This commit is contained in:
+48
-21
@@ -253,8 +253,39 @@ int EditClass::Action(unsigned flags, KeyNumType & key)
|
||||
} else {
|
||||
#ifdef WIN32
|
||||
|
||||
//KeyASCIIType ascii = (KeyASCIIType)(Keyboard->To_ASCII(key) & 0xff);
|
||||
Handle_Key(key, flags);
|
||||
KeyASCIIType ascii = (KeyASCIIType)(Keyboard->To_ASCII(key) & 0xff);
|
||||
|
||||
/*
|
||||
** Allow numeric keypad presses to map to ascii numbers
|
||||
*/
|
||||
if ((key & WWKEY_VK_BIT) && ascii >='0' && ascii <= '9') {
|
||||
|
||||
key = (KeyNumType)(key & ~WWKEY_VK_BIT);
|
||||
if ( (!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) {
|
||||
if (Handle_Key (ascii) ) {
|
||||
flags &= ~KEYBOARD;
|
||||
key = KN_NONE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
** Filter out all special keys except return and backspace
|
||||
*/ if ((!(key & WWKEY_VK_BIT) && ascii >= ' ' && ascii <= 255)
|
||||
|| key == KN_RETURN || key == KN_BACKSPACE) {
|
||||
|
||||
|
||||
|
||||
if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) {
|
||||
if (Handle_Key(Keyboard->To_ASCII(key))) {
|
||||
flags &= ~KEYBOARD;
|
||||
key = KN_NONE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flags &= ~KEYBOARD;
|
||||
key = KN_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else //WIN32
|
||||
@@ -343,11 +374,11 @@ void EditClass::Draw_Text(char const * text)
|
||||
* HISTORY: *
|
||||
* 01/21/1995 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
bool EditClass::Handle_Key(KeyASCIIType ascii)
|
||||
{
|
||||
unsigned rawKey = key & 0xff;
|
||||
unsigned char testAscii = (unsigned char)ascii;
|
||||
|
||||
switch (rawKey) {
|
||||
switch (ascii) {
|
||||
/*
|
||||
** Handle the special case of a non-keyboard event. It is possible that this
|
||||
** key code might be passed to this routine if this routine has been overridden
|
||||
@@ -356,7 +387,6 @@ bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
case 0:
|
||||
break;
|
||||
|
||||
|
||||
/*
|
||||
** If the return key is pressed, then remove the focus from this edit
|
||||
** gadget but otherwise let the normal gadget processing proceed. This
|
||||
@@ -364,14 +394,14 @@ bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
** so that the controlling program will know that the text can be
|
||||
** processed.
|
||||
*/
|
||||
case KN_RETURN:
|
||||
case KA_RETURN:
|
||||
Clear_Focus();
|
||||
return(false);
|
||||
|
||||
/*
|
||||
** When the BACKSPACE key is pressed, remove the last character in the edit string.
|
||||
*/
|
||||
case KN_BACKSPACE:
|
||||
case KA_BACKSPACE:
|
||||
if (Length) {
|
||||
Length--;
|
||||
String[Length] = '\0';
|
||||
@@ -384,13 +414,11 @@ bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
** if it can legally be added to the edit string and do so if possible.
|
||||
*/
|
||||
default:
|
||||
unsigned char keyAscii = UserInput.KeyB.ASCII;
|
||||
if (key & KN_SHIFT_BIT || key & KN_CAPSLOCK_BIT) keyAscii = toupper(keyAscii);
|
||||
|
||||
/*
|
||||
** Don't add a character if the length is greater than edit width.
|
||||
*/
|
||||
if (((int)String_Pixel_Width(String) + (int)Char_Pixel_Width(keyAscii) ) >= (Width-2)) {
|
||||
if (((int)String_Pixel_Width(String) + (int)Char_Pixel_Width(testAscii) ) >= (Width-2)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -403,21 +431,21 @@ bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
** Invisible characters are never added to the string. This is
|
||||
** especially true for spaces at the beginning of the string.
|
||||
*/
|
||||
if (!isgraph(keyAscii) && keyAscii != ' ') break;
|
||||
if (keyAscii == ' ' && Length == 0) break;
|
||||
if (!isgraph(testAscii) && testAscii != ' ') break;
|
||||
if (testAscii == ' ' && Length == 0) break;
|
||||
|
||||
/*
|
||||
** If this is an upper case only edit gadget, then force the alphabetic
|
||||
** character to upper case.
|
||||
*/
|
||||
if ((EditFlags & UPPERCASE) && isalpha(keyAscii)) {
|
||||
rawKey = (KeyASCIIType)toupper(keyAscii);
|
||||
if ((EditFlags & UPPERCASE) && isalpha(testAscii)) {
|
||||
testAscii = (KeyASCIIType)toupper(testAscii);
|
||||
}
|
||||
|
||||
if ((!(EditFlags & NUMERIC) || !isdigit(keyAscii)) &&
|
||||
(!(EditFlags & ALPHA) || !isalpha(keyAscii)) &&
|
||||
(!(EditFlags & MISC) || isalnum(keyAscii)) &&
|
||||
rawKey != ' ') {
|
||||
if ((!(EditFlags & NUMERIC) || !isdigit(testAscii)) &&
|
||||
(!(EditFlags & ALPHA) || !isalpha(testAscii)) &&
|
||||
(!(EditFlags & MISC) || isalnum(testAscii)) &&
|
||||
testAscii != ' ') {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -427,9 +455,8 @@ bool EditClass::Handle_Key(KeyNumType key, unsigned flags)
|
||||
** because the event flag has been cleared. This prevents the gadget's ID
|
||||
** number from being returned just because the gadget has been edited.
|
||||
*/
|
||||
String[Length++] = keyAscii;
|
||||
String[Length++] = testAscii;
|
||||
String[Length] = '\0';
|
||||
|
||||
Flag_To_Redraw();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user