diff -NurBb xvkbd-2.7a/Imakefile xvkbd-2.7a-coptic/Imakefile --- xvkbd-2.7a/Imakefile 2005-05-04 03:40:56.000000000 +0200 +++ xvkbd-2.7a-coptic/Imakefile 2006-05-17 19:08:25.000000000 +0200 @@ -13,8 +13,8 @@ #define I18N -SRCS = xvkbd.c findwidget.c -OBJS = xvkbd.o findwidget.o +SRCS = xvkbd.c findwidget.c u8_u16.c +OBJS = xvkbd.o findwidget.o u8_u16.o DEPLIBS = XawClientDepLibs SYS_LIBRARIES = XawClientLibs diff -NurBb xvkbd-2.7a/u8_u16.c xvkbd-2.7a-coptic/u8_u16.c --- xvkbd-2.7a/u8_u16.c 1970-01-01 01:00:00.000000000 +0100 +++ xvkbd-2.7a-coptic/u8_u16.c 2006-05-17 19:08:25.000000000 +0200 @@ -0,0 +1,82 @@ +/* code for converting UTF-8 code into UTF-16 + stolen from Hunspell, + + Author of Hunspell: + Németh László nemeth (at) OpenOffice.org +*/ + +#include +#include +#include +#include "u8_u16.h" + + +/* only UTF-16 (BMP) implementation */ +int u8_u16(w_char * dest, int size, const char * src) { + const char * u8 = src; + w_char * u2 = dest; + w_char * u2_max = u2 + size; + + while (*u8 && (u2 < u2_max)) { + switch ((*u8) & 0xf0) { + case 0x00: + case 0x10: + case 0x20: + case 0x30: + case 0x40: + case 0x50: + case 0x60: + case 0x70: { + u2->h = 0; + u2->l = *u8; + break; + } + case 0x80: + case 0x90: + case 0xa0: + case 0xb0: { + //fprintf(stderr, "UTF-8 encoding error. Unexpected continuation bytes in %d. character position\n%s\n", u8 - src, src); + return(-1); + break; + } + case 0xc0: + case 0xd0: { // 2-byte UTF-8 codes + if ((*(u8+1) & 0xc0) == 0x80) { + u2->h = (*u8 & 0x1f) >> 2; + u2->l = (*u8 << 6) + (*(u8+1) & 0x3f); + u8++; + } else { + //fprintf(stderr, "UTF-8 encoding error. Missing continuation byte in %d. character position:\n%s\n", u8 - src, src); + return(-2); + } + break; + } + case 0xe0: { // 3-byte UTF-8 codes + if ((*(u8+1) & 0xc0) == 0x80) { + u2->h = ((*u8 & 0x0f) << 4) + ((*(u8+1) & 0x3f) >> 2); + u8++; + if ((*(u8+1) & 0xc0) == 0x80) { + u2->l = (*u8 << 6) + (*(u8+1) & 0x3f); + u8++; + } else { + //fprintf(stderr, "UTF-8 encoding error. Missing continuation byte in %d. character position:\n%s\n", u8 - src, src); + return(-3); + } + } else { + //fprintf(stderr, "UTF-8 encoding error. Missing continuation byte in %d. character position:\n%s\n", u8 - src, src); + return(-4); + } + break; + } + case 0xf0: { // 4 or more byte UTF-8 codes + //fprintf(stderr, "This UTF-8 encoding can't convert to UTF-16:\n%s\n", src); + return(-5); + break; + } + } + u8++; + u2++; + } + return u2 - dest; +} + diff -NurBb xvkbd-2.7a/u8_u16.h xvkbd-2.7a-coptic/u8_u16.h --- xvkbd-2.7a/u8_u16.h 1970-01-01 01:00:00.000000000 +0100 +++ xvkbd-2.7a-coptic/u8_u16.h 2006-05-17 19:08:25.000000000 +0200 @@ -0,0 +1,6 @@ +typedef struct { + unsigned char h; + unsigned char l; +} w_char; + +int u8_u16(w_char * dest, int size, const char * src); diff -NurBb xvkbd-2.7a/xvkbd.c xvkbd-2.7a-coptic/xvkbd.c --- xvkbd-2.7a/xvkbd.c 2005-05-07 00:46:02.000000000 +0200 +++ xvkbd-2.7a-coptic/xvkbd.c 2006-05-18 10:33:03.000000000 +0200 @@ -54,6 +54,7 @@ #endif #include "resources.h" +#include "u8_u16.h" #define PROGRAM_NAME_WITH_VERSION "xvkbd (v2.7)" /* @@ -586,6 +587,32 @@ } } +void UpdateLabel(Widget w , unsigned char *label) +{ + w_char w_str[50]; + int w_len=0; + + /* a single char label can only be (ASCII or iso_8859_x) */ + if (strlen(label) == 1) + { + XtVaSetValues(w, XtNlabel, label, XtNencoding, XawTextEncoding8bit, NULL); + return; + } + + /* the label could be either utf8 or iso_8859_x, assume it is iso_8859_x and + try to convert into 2b format. If this fails, then it was probably iso_8859_x */ + + w_len = u8_u16(w_str, 50, label); + + /* string was successfully converted from utf8 to 2b */ + if((w_str[0].h) && (w_len > 0) ) + { + XtVaSetValues(w, XtNlabel, w_str, XtNencoding, XawTextEncodingChar2b, NULL); + } + else + XtVaSetValues(w, XtNlabel, label, XtNencoding, XawTextEncoding8bit, NULL); +} + /* * Read keyboard mapping and modifier mapping. * Keyboard mapping is used to know what keys are in shifted position. @@ -1377,7 +1404,7 @@ } /* - * Highlight/unhighligh keys on the screen to reflect the state. + * Highlight/unhighlight keys on the screen to reflect the state. */ static void RefreshShiftState(Boolean force) { @@ -1461,7 +1488,8 @@ label = ""; } if (strcmp(label, "space") == 0) label = ""; - XtVaSetValues(key_widgets[row][col], XtNlabel, label, NULL); + //XtVaSetValues(key_widgets[row][col], XtNlabel, label, NULL); + UpdateLabel(key_widgets[row][col], label); } } } @@ -2116,7 +2144,7 @@ /* * Create keyboard on the screen. */ -static Widget MakeKey(Widget parent, const char *name, const char *label, Pixel color) +static Widget MakeKey(Widget parent, const char *name, char *label, Pixel color) { static Pixmap up_pixmap = None; static Pixmap down_pixmap = None; @@ -2125,7 +2153,7 @@ static Pixmap back_pixmap = None; Widget w; Window scr = RootWindow(dpy, DefaultScreen(dpy)); - char str[50]; + unsigned char str[50]; int len; if (!appres.auto_repeat @@ -2153,7 +2181,7 @@ if (str[1] == '_') str[1] = ' '; if (str[len - 2] == '_') str[len - 2] = ' '; } - XtVaSetValues(w, XtNlabel, str, NULL); + UpdateLabel(w, label); if (strcmp(label, "up") == 0) { if (up_pixmap == None) diff -NurBb xvkbd-2.7a/XVkbd-coptic.ad xvkbd-2.7a-coptic/XVkbd-coptic.ad --- xvkbd-2.7a/XVkbd-coptic.ad 1970-01-01 01:00:00.000000000 +0100 +++ xvkbd-2.7a-coptic/XVkbd-coptic.ad 2006-05-17 19:08:25.000000000 +0200 @@ -0,0 +1,112 @@ +!! XVkbd-coptic.ad, by Moheb Mekhaiel, mohebm@gmx.de +!! ATTENTION: edit only with an UTF-8 capable editor!! +!! Version, v0.1, 15 May 2006 +!! adapted the keyboard mapping as suggested by Logos Research Systems + +#include "XVkbd-common" +!xvkbd.Debug: true +xvkbd.title: xvkbd - Virtual Keyboard (Coptic) + +! enable changing the labels whenever Shift or AltGr mode is active +xvkbd.modalKeytop: true +xvkbd*Font: -misc-new athena unicode-medium-r-normal--24-*-*-*-*-*-iso10646-1 +xvkbd*MenuButton*Font: -*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1 + +xvkbd*Mode_switch.width: 50 +xvkbd*space.width: 131 +XVkbd*Command.height: 45 +XVkbd*Repeater.height: 45 +XVkbd*banner.height: 45 +XVkbd*Command.width: 45 +XVkbd*Repeater.width: 45 +XVkbd*Tab.width: 80 +XVkbd*Control_L.width: 85 +XVkbd*Shift_L.width: 85 +XVkbd*Shift_R.width: 85 +XVkbd*Caps_Lock.width: 58 +XVkbd*Alt_L.width: 58 +XVkbd*Alt_R.width: 58 +XVkbd*Meta_L.width: 57 +XVkbd*Meta_R.width: 57 +XVkbd*Delete.width: 72 +XVkbd*Return.width: 112 +xvkbd*Mode_switch.width: 67 +XVkbd*row0.BackSpace.width: 114 +XVkbd*row0.Repeater.height: 40 +XVkbd*row0.Repeater.width: 47 +XVkbd*row1.Escape.width: 62 +XVkbd*row4.Multi_key.width: 72 +XVkbd*row5.Focus.width: 85 +XVkbd*row5.MainMenu.width: 56 + +xvkbd.keypad: false + +xvkbd.NormalKeys: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 BackSpace \n\ + Escape 1 2 3 4 5 6 7 8 9 0 U00B7 U2E17 U0300 U0308 \n\ + Tab U2C91 U2CB1 U2C89 U2CA3 U2CA7 U2CAF U2CA9 U2C93 U2C9F U2CA1 bracketleft bracketright Delete \n\ + Control_L U2C81 U2CA5 U2C87 U2CAB U2C85 U2C8F U03EB U2C95 U2C97 semicolon apostrophe Return \n\ + Shift_L U2C8D U2C9D U2CAD U03E3 U2C83 U2C9B U2C99 comma period U0301 Multi_key Shift_R \n\ + MainMenu Caps_Lock Alt_L Meta_L space Mode_switch Left Right Up Down Focus + +xvkbd.ShiftKeys: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 BackSpace \n\ + Escape U0304 U0306 U0374 U0375 U0307 U0323 U2CE4 U002A parenleft parenright underscore U0305 U007C U0311 \n\ + Tab U2C90 U2CB0 U2C88 U2CA2 U2CA6 U2CAE U2CA8 U2C92 U2C9E U2CA0 braceleft braceright Delete \n\ + Control_L U2C80 U2CA4 U2C86 U2CAA U2C84 U2C8E U03EA U2C94 U2C96 colon U2CFF" Return \n\ + Shift_L U2C8C U2C9C U2CAC U03E2 U2C82 U2C9A U2C98 less greater U2CFE Multi_key Shift_R \n\ + MainMenu Caps_Lock Alt_L Meta_L space Mode_switch Left Right Up Down Focus + +xvkbd.AltgrKeys: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 BackSpace \n\ + Escape \271 U2CFD U2056 U2058 U2059 U2C8B \251 U2026 U201C U201D U2013 U033F backslash U0361 \n\ + Tab \340 \341 \342 \343 U03EF \345 \346 \347 \350 \351 U2018 \U2019 Delete \n\ + Control_L \354 U03E3 U03EF U03E5 U03EB U03E9 U03EB U03E7 \364 U2053 U0022 Return \n\ + Shift \370 \371 U03ED U03E3 \374 \375 \376 U00AB U00BB slash Multi_key Shift_R \n\ + MainMenu Caps_Lock Alt_L Meta_L space Mode_switch Left Right Up Down Focus + +xvkbd.ShiftAltgrKeys: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 BackSpace \n\ + Escape U2CE6 U2CE7 U2CE8 U2CE9 U2CEA U2C8A \256 \252 plusminus degree U2014 \264 U007C U2CE5 \n\ + Tab \300 \301 \302 \303 U03EE \305 \306 \307 \310 \311 \312 \313 Delete \n\ + Control_L \314 U03E2 U03EE U03E4 U03EA U03E8 U03EA U03E6 \324 \325 \326 Return \n\ + Shift \330 \331 U03EC U03E2 \334 \335 \336 U2039 U203A \077 Multi_key Shift_R \n\ + MainMenu Caps_Lock Alt_L Meta_L space Mode_switch Left Right Up Down Focus + +xvkbd.NormalKeyLabels: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Backspace \n\ + Esc 1 2 3 4 5 6 7 8 9 0 \267 ⸗ ` ..\n_ \n\ + Tab ⲑ ⲱ ⲉ ⲣ ⲧ ⲯ ⲩ ⲓ ⲟ ⲡ [ ] Delete \n\ + Ctrl ⲁ ⲥ ⲇ ⲫ ⲅ ⲏ ϫ ⲕ ⲗ ; ́ Return \n\ + Shift ⲍ ⲝ ⲭ ϣ ⲃ ⲛ ⲙ , . ' Comp Shift \n\ + MainMenu Caps Alt Meta space AltGr left right up down Focus + +xvkbd.ShiftKeyLabels: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Backspace \n\ + Esc ̄ ̆ ʹ ͵ .\n_ . ⳤ * ( ) - \257 | ̑ \n\ + Tab Ⲑ Ⲱ Ⲉ Ⲣ Ⲧ Ⲯ Ⲩ Ⲓ Ⲟ Ⲡ { } Del \n\ + Ctrl Ⲁ Ⲥ Ⲇ Ⲫ Ⲅ Ⲏ Ϫ Ⲕ Ⲗ : ` \n\ + Shift Ⲍ Ⲝ Ⲭ Ϣ Ⲃ Ⲛ Ⲙ < > ⳾ Comp Shift \n\ + MainMenu Caps Alt Meta space AltGr left right up down Focus + +xvkbd.AltgrKeyLabels: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Backspace \n\ + Esc \271 ⳽ ⁖ ⁘ ⁙ ⲋ \251 … “ ” – ̿\134 \134 ͡ \n\ + Tab \340 \341 \342 \343 ϯ \345 \346 \347 \350 \351 ‘ ’ Del \n\ + Ctrl \354 ϣ ϯ ϥ ϫ ϩ ϫ ϧ \364 ~ " Return \n\ + Shift \370 \371 ϭ ϣ \374 \375 \376 \253 \273 / Comp Shift \n\ + MainMenu Caps Alt Meta space AltGr left right up down Focus + +xvkbd.ShiftAltgrKeyLabels: \ + F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Backspace \n\ + Esc ⳦ ⳧ ⳨ ⳩ ⳪ Ⲋ \256 \252 \261 \260 __\n_ \264 | ⳥ \n\ + Tab \300 \301 \302 \303 Ϯ \305 \306 \307 \310 \311 \312 \313 Del \n\ + Ctrl \314 Ϣ Ϯ Ϥ Ϫ Ϩ Ϫ Ϧ \324 \325 \326 Return \n\ + Shift \330 \331 Ϭ Ϣ \334 \335 \336 ‹ › ? Comp Shift \n\ + MainMenu Caps Alt Meta space AltGr left right up down Focus + + + + + +