Commit c56038e12994171b966e29455dc5faa0e3e721ef

Authored by Perry Werneck
1 parent 589167f0
Exists in master and in 1 other branch develop

Implementando identificação de caracteres pelo nome "X"

Showing 1 changed file with 230 additions and 2 deletions   Show diff stats
charset.c
... ... @@ -31,6 +31,7 @@
31 31 #include "private.h"
32 32 #include <lib3270/charset.h>
33 33 #include <lib3270/log.h>
  34 + #include <lib3270/X11keysym.h>
34 35  
35 36 #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME)
36 37  
... ... @@ -54,6 +55,222 @@
54 55  
55 56 static unsigned short getChar(const gchar *id, GError **error) {
56 57  
  58 + static struct
  59 + {
  60 + const char * name;
  61 + unsigned short keysym;
  62 + } latin[] =
  63 + {
  64 + { "space", XK_space },
  65 + { "exclam", XK_exclam },
  66 + { "quotedbl", XK_quotedbl },
  67 + { "numbersign", XK_numbersign },
  68 + { "dollar", XK_dollar },
  69 + { "percent", XK_percent },
  70 + { "ampersand", XK_ampersand },
  71 + { "apostrophe", XK_apostrophe },
  72 + { "quoteright", XK_quoteright },
  73 + { "parenleft", XK_parenleft },
  74 + { "parenright", XK_parenright },
  75 + { "asterisk", XK_asterisk },
  76 + { "plus", XK_plus },
  77 + { "comma", XK_comma },
  78 + { "minus", XK_minus },
  79 + { "period", XK_period },
  80 + { "slash", XK_slash },
  81 + { "0", XK_0 },
  82 + { "1", XK_1 },
  83 + { "2", XK_2 },
  84 + { "3", XK_3 },
  85 + { "4", XK_4 },
  86 + { "5", XK_5 },
  87 + { "6", XK_6 },
  88 + { "7", XK_7 },
  89 + { "8", XK_8 },
  90 + { "9", XK_9 },
  91 + { "colon", XK_colon },
  92 + { "semicolon", XK_semicolon },
  93 + { "less", XK_less },
  94 + { "equal", XK_equal },
  95 + { "greater", XK_greater },
  96 + { "question", XK_question },
  97 + { "at", XK_at },
  98 + { "A", XK_A },
  99 + { "B", XK_B },
  100 + { "C", XK_C },
  101 + { "D", XK_D },
  102 + { "E", XK_E },
  103 + { "F", XK_F },
  104 + { "G", XK_G },
  105 + { "H", XK_H },
  106 + { "I", XK_I },
  107 + { "J", XK_J },
  108 + { "K", XK_K },
  109 + { "L", XK_L },
  110 + { "M", XK_M },
  111 + { "N", XK_N },
  112 + { "O", XK_O },
  113 + { "P", XK_P },
  114 + { "Q", XK_Q },
  115 + { "R", XK_R },
  116 + { "S", XK_S },
  117 + { "T", XK_T },
  118 + { "U", XK_U },
  119 + { "V", XK_V },
  120 + { "W", XK_W },
  121 + { "X", XK_X },
  122 + { "Y", XK_Y },
  123 + { "Z", XK_Z },
  124 + { "bracketleft", XK_bracketleft },
  125 + { "backslash", XK_backslash },
  126 + { "bracketright", XK_bracketright },
  127 + { "asciicircum", XK_asciicircum },
  128 + { "underscore", XK_underscore },
  129 + { "grave", XK_grave },
  130 + { "quoteleft", XK_quoteleft },
  131 + { "a", XK_a },
  132 + { "b", XK_b },
  133 + { "c", XK_c },
  134 + { "d", XK_d },
  135 + { "e", XK_e },
  136 + { "f", XK_f },
  137 + { "g", XK_g },
  138 + { "h", XK_h },
  139 + { "i", XK_i },
  140 + { "j", XK_j },
  141 + { "k", XK_k },
  142 + { "l", XK_l },
  143 + { "m", XK_m },
  144 + { "n", XK_n },
  145 + { "o", XK_o },
  146 + { "p", XK_p },
  147 + { "q", XK_q },
  148 + { "r", XK_r },
  149 + { "s", XK_s },
  150 + { "t", XK_t },
  151 + { "u", XK_u },
  152 + { "v", XK_v },
  153 + { "w", XK_w },
  154 + { "x", XK_x },
  155 + { "y", XK_y },
  156 + { "z", XK_z },
  157 + { "braceleft", XK_braceleft },
  158 + { "bar", XK_bar },
  159 + { "braceright", XK_braceright },
  160 + { "asciitilde", XK_asciitilde },
  161 + { "nobreakspace", XK_nobreakspace },
  162 + { "exclamdown", XK_exclamdown },
  163 + { "cent", XK_cent },
  164 + { "sterling", XK_sterling },
  165 + { "currency", XK_currency },
  166 + { "yen", XK_yen },
  167 + { "brokenbar", XK_brokenbar },
  168 + { "section", XK_section },
  169 + { "diaeresis", XK_diaeresis },
  170 + { "copyright", XK_copyright },
  171 + { "ordfeminine", XK_ordfeminine },
  172 + { "guillemotleft", XK_guillemotleft },
  173 + { "notsign", XK_notsign },
  174 + { "hyphen", XK_hyphen },
  175 + { "registered", XK_registered },
  176 + { "macron", XK_macron },
  177 + { "degree", XK_degree },
  178 + { "plusminus", XK_plusminus },
  179 + { "twosuperior", XK_twosuperior },
  180 + { "threesuperior", XK_threesuperior },
  181 + { "acute", XK_acute },
  182 + { "mu", XK_mu },
  183 + { "paragraph", XK_paragraph },
  184 + { "periodcentered", XK_periodcentered },
  185 + { "cedilla", XK_cedilla },
  186 + { "onesuperior", XK_onesuperior },
  187 + { "masculine", XK_masculine },
  188 + { "guillemotright", XK_guillemotright },
  189 + { "onequarter", XK_onequarter },
  190 + { "onehalf", XK_onehalf },
  191 + { "threequarters", XK_threequarters },
  192 + { "questiondown", XK_questiondown },
  193 + { "Agrave", XK_Agrave },
  194 + { "Aacute", XK_Aacute },
  195 + { "Acircumflex", XK_Acircumflex },
  196 + { "Atilde", XK_Atilde },
  197 + { "Adiaeresis", XK_Adiaeresis },
  198 + { "Aring", XK_Aring },
  199 + { "AE", XK_AE },
  200 + { "Ccedilla", XK_Ccedilla },
  201 + { "Egrave", XK_Egrave },
  202 + { "Eacute", XK_Eacute },
  203 + { "Ecircumflex", XK_Ecircumflex },
  204 + { "Ediaeresis", XK_Ediaeresis },
  205 + { "Igrave", XK_Igrave },
  206 + { "Iacute", XK_Iacute },
  207 + { "Icircumflex", XK_Icircumflex },
  208 + { "Idiaeresis", XK_Idiaeresis },
  209 + { "ETH", XK_ETH },
  210 + { "Eth", XK_Eth },
  211 + { "Ntilde", XK_Ntilde },
  212 + { "Ograve", XK_Ograve },
  213 + { "Oacute", XK_Oacute },
  214 + { "Ocircumflex", XK_Ocircumflex },
  215 + { "Otilde", XK_Otilde },
  216 + { "Odiaeresis", XK_Odiaeresis },
  217 + { "multiply", XK_multiply },
  218 + { "Ooblique", XK_Ooblique },
  219 + { "Ugrave", XK_Ugrave },
  220 + { "Uacute", XK_Uacute },
  221 + { "Ucircumflex", XK_Ucircumflex },
  222 + { "Udiaeresis", XK_Udiaeresis },
  223 + { "Yacute", XK_Yacute },
  224 + { "THORN", XK_THORN },
  225 + { "Thorn", XK_Thorn },
  226 + { "ssharp", XK_ssharp },
  227 + { "agrave", XK_agrave },
  228 + { "aacute", XK_aacute },
  229 + { "acircumflex", XK_acircumflex },
  230 + { "atilde", XK_atilde },
  231 + { "adiaeresis", XK_adiaeresis },
  232 + { "aring", XK_aring },
  233 + { "ae", XK_ae },
  234 + { "ccedilla", XK_ccedilla },
  235 + { "egrave", XK_egrave },
  236 + { "eacute", XK_eacute },
  237 + { "ecircumflex", XK_ecircumflex },
  238 + { "ediaeresis", XK_ediaeresis },
  239 + { "igrave", XK_igrave },
  240 + { "iacute", XK_iacute },
  241 + { "icircumflex", XK_icircumflex },
  242 + { "idiaeresis", XK_idiaeresis },
  243 + { "eth", XK_eth },
  244 + { "ntilde", XK_ntilde },
  245 + { "ograve", XK_ograve },
  246 + { "oacute", XK_oacute },
  247 + { "ocircumflex", XK_ocircumflex },
  248 + { "otilde", XK_otilde },
  249 + { "odiaeresis", XK_odiaeresis },
  250 + { "division", XK_division },
  251 + { "oslash", XK_oslash },
  252 + { "ugrave", XK_ugrave },
  253 + { "uacute", XK_uacute },
  254 + { "ucircumflex", XK_ucircumflex },
  255 + { "udiaeresis", XK_udiaeresis },
  256 + { "yacute", XK_yacute },
  257 + { "thorn", XK_thorn },
  258 + { "ydiaeresis", XK_ydiaeresis },
  259 +
  260 + // The following are, umm, hacks to allow symbolic names for
  261 + // control codes.
  262 + #if !defined(_WIN32)
  263 + { "BackSpace", 0x08 },
  264 + { "Tab", 0x09 },
  265 + { "Linefeed", 0x0a },
  266 + { "Return", 0x0d },
  267 + { "Escape", 0x1b },
  268 + { "Delete", 0x7f },
  269 + #endif
  270 + };
  271 +
  272 + size_t ix;
  273 +
57 274 if(*error) {
58 275 return 0;
59 276 }
... ... @@ -62,15 +279,26 @@
62 279  
63 280 unsigned int rc = 0;
64 281  
65   - if(sscanf(id + 2, "%x", &rc) != 1) {
  282 + if(sscanf(id + 2, "%x", &rc) != 1)
  283 + {
66 284 *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Can't parse character value" ));
67   - return;
  285 + return 0;
68 286 }
69 287  
70 288 return (unsigned short) rc;
71 289  
72 290 }
73 291  
  292 + for(ix=0;ix < G_N_ELEMENTS(latin);ix++) {
  293 + if(!g_ascii_strcasecmp(id,latin[ix].name))
  294 + return latin[ix].keysym;
  295 + }
  296 +
  297 + if(strlen(id) != 1)
  298 + {
  299 + *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Invalid character value" ));
  300 + return 0;
  301 + }
74 302  
75 303 return (unsigned short) *id;
76 304 }
... ...