TAsn's patch for LTR->RTL support in keyboard. (with formatting fixes).

SVN revision: 46550
This commit is contained in:
Christopher Michael 2010-02-27 04:28:43 +00:00
parent 7255cc7b32
commit d2a7162547
2 changed files with 38 additions and 3 deletions

View File

@ -434,6 +434,16 @@ _e_kbd_int_key_press_handle(E_Kbd_Int *ki, Evas_Coord dx, Evas_Coord dy)
static void
_e_kbd_int_stroke_handle(E_Kbd_Int *ki, int dir)
{
/* If the keyboard direction is RTL switch dir 3 and 1
* i.e, make forward backwards and the other way around */
if (ki->layout.direction == E_KBD_INT_DIRECTION_RTL)
{
if (dir == 3)
dir = 1;
else if (dir == 1)
dir = 3;
}
if (dir == 4) // up
_e_kbd_int_layout_next(ki);
else if (dir == 3) // left
@ -882,14 +892,18 @@ _e_kbd_int_layout_parse(E_Kbd_Int *ki, const char *layout)
E_Kbd_Int_Key *ky = NULL;
E_Kbd_Int_Key_State *st = NULL;
f = fopen(layout, "r");
if (!f) return;
if (!(f = fopen(layout, "r"))) return;
ki->layout.directory = ecore_file_dir_get(layout);
ki->layout.file = eina_stringshare_add(layout);
/* Make the default direction LTR */
ki->layout.direction = E_KBD_INT_DIRECTION_LTR;
while (fgets(buf, sizeof(buf), f))
{
int len;
char str[4096];
char str[PATH_MAX];
if (!isok)
{
@ -913,6 +927,19 @@ _e_kbd_int_layout_parse(E_Kbd_Int *ki, const char *layout)
sscanf(buf, "%*s %i\n", &(ki->layout.fuzz));
continue;
}
if (!strcmp(str, "direction"))
{
char direction[4];
sscanf(buf, "%*s %3s\n", direction);
/* If rtl mark as rtl, otherwise make it ltr */
if (!strcmp(direction, "rtl"))
ki->layout.direction = E_KBD_INT_DIRECTION_RTL;
else
ki->layout.direction = E_KBD_INT_DIRECTION_LTR;
continue;
}
if (!strcmp(str, "key"))
{
ky = calloc(1, sizeof(E_Kbd_Int_Key));

View File

@ -15,6 +15,13 @@ typedef enum _E_Kbd_Int_Type
E_KBD_INT_TYPE_PASSWORD = (1 << 6)
} E_Kbd_Int_Type;
/* The natural text direction of the keyboard */
typedef enum _E_kbd_Int_Direction
{
E_KBD_INT_DIRECTION_LTR = (1 << 0),
E_KBD_INT_DIRECTION_RTL = (1 << 1)
} E_Kbd_Int_Direction;
typedef struct _E_Kbd_Int E_Kbd_Int;
typedef struct _E_Kbd_Int_Key E_Kbd_Int_Key;
typedef struct _E_Kbd_Int_Key_State E_Kbd_Int_Key_State;
@ -35,6 +42,7 @@ struct _E_Kbd_Int
const char *file;
int w, h;
int fuzz;
int direction;
E_Kbd_Int_Type type;
Eina_List *keys;
E_Kbd_Int_Key *pressed;