Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_embed.c ewl_entry.c 


Log Message:
- handle all of the shift characters
- handle special characters correctly

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_embed.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -3 -r1.50 -r1.51
--- ewl_embed.c 22 Feb 2006 03:51:01 -0000      1.50
+++ ewl_embed.c 3 Mar 2006 01:59:54 -0000       1.51
@@ -1982,7 +1982,8 @@
                keyname = strdup("\n");
 
        /* fixup upper case chars */
-       } else if (key_modifiers & EWL_KEY_MODIFIER_SHIFT)
+       } else if ((key_modifiers & EWL_KEY_MODIFIER_SHIFT)
+                       && (strlen(keyname) == 1))
                strupper(keyname);
 
        ewl_embed_key_down_feed(embed, keyname, ewl_ev_modifiers_get());
@@ -2030,7 +2031,8 @@
                keyname = strdup("\n");
 
        /* fixup upper case chars */
-       } else if (key_modifiers & EWL_KEY_MODIFIER_SHIFT) 
+       } else if ((key_modifiers & EWL_KEY_MODIFIER_SHIFT) 
+                       && (strlen(keyname) == 1))
                strupper(keyname);
 
        ewl_embed_key_up_feed(embed, keyname, ewl_ev_modifiers_get());
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- ewl_entry.c 19 Feb 2006 16:13:53 -0000      1.49
+++ ewl_entry.c 3 Mar 2006 01:59:54 -0000       1.50
@@ -3,6 +3,10 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
+static void ewl_entry_keymap_set(void);
+
+static Ecore_Hash *shiftmap = NULL, *keymap = NULL;
+
 /**
  * @return Returns a new Ewl_Widget on success or NULL on failure
  * @brief Create and return a new Ewl_Entry widget
@@ -14,6 +18,9 @@
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
+       if (!keymap)
+               ewl_entry_keymap_set();
+
        w = NEW(Ewl_Entry, 1);
        if (!w)
        {
@@ -335,17 +342,39 @@
                                
ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)));
                }
        }
-       else if ((event->keyname) && (strlen(event->keyname) == 1))
+       else if (event->keyname)
        {
-               char *tmp;
+               char *tmp = NULL, *v;
 
                ewl_entry_selection_clear(e);
+               if (event->modifiers & EWL_KEY_MODIFIER_SHIFT)
+               {
+                       v = ecore_hash_get(shiftmap, event->keyname);
+                       if (v) 
+                               tmp = strdup(v);
+                       else if (strlen(event->keyname) == 1)
+                       {
+                               if (event->keyname[0] > 0x60)
+                                       event->keyname[0] -= 0x20;
 
-               tmp = calloc(2, sizeof(char));
-               snprintf(tmp, 2, "%s", event->keyname);
-               ewl_text_text_insert(EWL_TEXT(e), tmp,
-                               
ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)));
-               FREE(tmp);
+                               tmp = strdup(event->keyname);
+                       }
+               }
+               else if (strlen(event->keyname) != 1)
+               {
+                       v = ecore_hash_get(keymap, event->keyname);
+                       if (v) tmp = strdup(v);
+               }
+               else
+                       tmp = strdup(event->keyname);
+
+               if (tmp)
+               {
+                       ewl_text_text_insert(EWL_TEXT(e), tmp,
+                               ewl_entry_cursor_position_get(
+                                       EWL_ENTRY_CURSOR(e->cursor)));
+                       free(tmp);
+               }
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -531,6 +560,50 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+static void
+ewl_entry_keymap_set(void)
+{
+       int i;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       static const char *tmp_shiftmap[] = {
+               "grave", "~", "1", "!", "2", "@",
+               "3", "#", "4", "$", "5", "%",
+               "6", "^", "7", "&", "8", "*",
+               "9", "(", "0", ")", 
+               "minus", "_", "equal", "+", 
+               "bracketleft", "{", "bracketright", "}",
+               "backslash", "|", "semicolon", ":", "apostrophe", "\"",
+               "comma", "<", "period", ">", "slash", "?",
+               NULL, NULL
+       };
+
+       static const char *tmp_keymap[] = {
+               "grave", "`", "minus", "-", "equal", "=",
+               "bracketleft", "[", "bracketright", "]",
+               "backslash", "\\", "semicolon", ";",
+               "apostrophe", "'", "comma", ",",
+               "period", ".", "slash", "/",
+               NULL, NULL
+       };
+
+       shiftmap = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+       keymap = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+       if (!shiftmap) DRETURN(DLEVEL_STABLE);
+       if (!keymap) DRETURN(DLEVEL_STABLE);
+
+       for (i = 0; tmp_shiftmap[i]; i += 2)
+               ecore_hash_set(shiftmap, (char *)tmp_shiftmap[i], 
+                                       (char *)tmp_shiftmap[i + 1]);
+
+       for (i = 0; tmp_keymap[i]; i += 2)
+               ecore_hash_set(keymap, (char *)tmp_keymap[i],
+                                       (char *)tmp_keymap[i + 1]);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
 /*
  * cursor stuff
  */




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to