fixed handling of some non-ASCII character elements in level editor
authorHolger Schemel <info@artsoft.org>
Thu, 9 Oct 2014 15:26:49 +0000 (17:26 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 9 Oct 2014 15:26:49 +0000 (17:26 +0200)
src/conftime.h
src/libgame/misc.c
src/libgame/text.h

index ac6e95e0c468ecaaceafc8bc9d342f5105a52b2d..7eb8292b274fa40cab26037177bd92b70c84aff8 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2014-10-09 16:40"
+#define COMPILE_DATE_STRING "2014-10-09 17:21"
index 883dd7d2afd7b18cc4b94db45622b2f12f012883..cd9d3e93cf7e3a477db76ebb5a1684255fed46ee 100644 (file)
@@ -1418,7 +1418,7 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode)
     { KSYM_braceright, "XK_braceright",        "brace right" },
     { KSYM_asciitilde, "XK_asciitilde",        "~" },
 
     { KSYM_braceright, "XK_braceright",        "brace right" },
     { KSYM_asciitilde, "XK_asciitilde",        "~" },
 
-    /* special (non-ASCII) keys (ISO-Latin-1) */
+    /* special (non-ASCII) keys */
     { KSYM_degree,     "XK_degree",            "degree" },
     { KSYM_Adiaeresis, "XK_Adiaeresis",        "A umlaut" },
     { KSYM_Odiaeresis, "XK_Odiaeresis",        "O umlaut" },
     { KSYM_degree,     "XK_degree",            "degree" },
     { KSYM_Adiaeresis, "XK_Adiaeresis",        "A umlaut" },
     { KSYM_Odiaeresis, "XK_Odiaeresis",        "O umlaut" },
@@ -1699,6 +1699,26 @@ Key getKeyFromX11KeyName(char *x11name)
 
 char getCharFromKey(Key key)
 {
 
 char getCharFromKey(Key key)
 {
+  static struct
+  {
+    Key key;
+    byte key_char;
+  } translate_key_char[] =
+  {
+    /* special (non-ASCII) keys (ISO-8859-1) */
+    { KSYM_degree,     CHAR_BYTE_DEGREE        },
+    { KSYM_Adiaeresis, CHAR_BYTE_UMLAUT_A      },
+    { KSYM_Odiaeresis, CHAR_BYTE_UMLAUT_O      },
+    { KSYM_Udiaeresis, CHAR_BYTE_UMLAUT_U      },
+    { KSYM_adiaeresis, CHAR_BYTE_UMLAUT_a      },
+    { KSYM_odiaeresis, CHAR_BYTE_UMLAUT_o      },
+    { KSYM_udiaeresis, CHAR_BYTE_UMLAUT_u      },
+    { KSYM_ssharp,     CHAR_BYTE_SHARP_S       },
+
+    /* end-of-array identifier */
+    { 0,                0                      }
+  };
+
   char *keyname = getKeyNameFromKey(key);
   char c = 0;
 
   char *keyname = getKeyNameFromKey(key);
   char c = 0;
 
@@ -1706,6 +1726,21 @@ char getCharFromKey(Key key)
     c = keyname[0];
   else if (strEqual(keyname, "space"))
     c = ' ';
     c = keyname[0];
   else if (strEqual(keyname, "space"))
     c = ' ';
+  else
+  {
+    int i = 0;
+
+    do
+    {
+      if (key == translate_key_char[i].key)
+      {
+       c = translate_key_char[i].key_char;
+
+       break;
+      }
+    }
+    while (translate_key_char[++i].key_char);
+  }
 
   return c;
 }
 
   return c;
 }
index 1273f3992ec26b4f77a84a9233ecaa289fe0a9a3..08d14cdb6eb56d72a77a3fe90644d0aa0fcdaf0a 100644 (file)
 #define MAX_OUTPUT_LINESIZE    1024
 
 /* special constants for old ISO-8859-1 character byte values */
 #define MAX_OUTPUT_LINESIZE    1024
 
 /* special constants for old ISO-8859-1 character byte values */
-#define CHAR_BYTE_UMLAUT_A     (0xc4)
-#define CHAR_BYTE_UMLAUT_O     (0xd6)
-#define CHAR_BYTE_UMLAUT_U     (0xdc)
-#define CHAR_BYTE_UMLAUT_a     (0xe4)
-#define CHAR_BYTE_UMLAUT_o     (0xf6)
-#define CHAR_BYTE_UMLAUT_u     (0xfc)
-#define CHAR_BYTE_SHARP_S      (0xdf)
-#define CHAR_BYTE_COPYRIGHT    (0xa9)
-#define CHAR_BYTE_REGISTERED   (0xae)
-#define CHAR_BYTE_DEGREE       (0xb0)
-#define CHAR_BYTE_CURSOR       (0xa0)
+#define CHAR_BYTE_UMLAUT_A     ((char)0xc4)
+#define CHAR_BYTE_UMLAUT_O     ((char)0xd6)
+#define CHAR_BYTE_UMLAUT_U     ((char)0xdc)
+#define CHAR_BYTE_UMLAUT_a     ((char)0xe4)
+#define CHAR_BYTE_UMLAUT_o     ((char)0xf6)
+#define CHAR_BYTE_UMLAUT_u     ((char)0xfc)
+#define CHAR_BYTE_SHARP_S      ((char)0xdf)
+#define CHAR_BYTE_COPYRIGHT    ((char)0xa9)
+#define CHAR_BYTE_REGISTERED   ((char)0xae)
+#define CHAR_BYTE_DEGREE       ((char)0xb0)
+#define CHAR_BYTE_CURSOR       ((char)0xa0)
 
 /* special character mapping for default fonts */
 #define FONT_ASCII_CURSOR      ((char)160)
 
 /* special character mapping for default fonts */
 #define FONT_ASCII_CURSOR      ((char)160)