Change order of key processing parts. Use fix keyvalue mapping before running
the gdk_keyval_to_unicode(). This should be a little faster and avoids bugs,
when compiled against the GTK3 libs, where the GDK_Return is handled by
gdk_keyval_to_unicode() which wasn't th fact with GDK2.
#define KEY_TAB '\x09'
#define KEY_NL '\x15'
-#define KEY_CR '\x0a'
+#define KEY_CR '\x0d'
#define KEY_ESC '\x1b'
#define KEY_BS '\x08'
#define KEY_SHIFT_TAB TERMCAP2KEY('k', 'B')
vb_set_input_text("");
break;
- case '\n':
+ case KEY_CR:
input_activate();
break;
int len;
guint32 uc;
- if ((uc = gdk_keyval_to_unicode(keyval))) {
- if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) {
- len = 1;
- if (uc >= '@') {
- string[0] = uc & 0x1f;
- } else if (uc == '8') {
- string[0] = KEY_BS;
+ len = 1;
+ switch (keyval) {
+ case GDK_Tab:
+ case GDK_KP_Tab:
+ case GDK_ISO_Left_Tab:
+ string[0] = KEY_TAB;
+ break;
+
+ case GDK_Linefeed:
+ string[0] = KEY_NL;
+ break;
+
+ case GDK_Return:
+ case GDK_ISO_Enter:
+ case GDK_3270_Enter:
+ string[0] = KEY_CR;
+ break;
+
+ case GDK_Escape:
+ string[0] = KEY_ESC;
+ break;
+
+ case GDK_BackSpace:
+ string[0] = KEY_BS;
+ break;
+
+ default:
+ if ((uc = gdk_keyval_to_unicode(keyval))) {
+ if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) {
+ if (uc >= '@') {
+ string[0] = uc & 0x1f;
+ } else if (uc == '8') {
+ string[0] = KEY_BS;
+ } else {
+ string[0] = uc;
+ }
+ } else {
+ /* translate a normal key to utf-8 */
+ len = utf_char2bytes((guint)uc, string);
+ }
} else {
- string[0] = uc;
- }
- } else {
- /* translate a normal key to utf-8 */
- len = utf_char2bytes((guint)uc, string);
- }
- } else {
- /* translate keys which are represented by ascii control codes */
- len = 1;
- switch (keyval) {
- case GDK_Tab:
- case GDK_KP_Tab:
- case GDK_ISO_Left_Tab:
- string[0] = KEY_TAB;
- break;
- case GDK_Linefeed:
- string[0] = KEY_NL;
- break;
- case GDK_Return:
- case GDK_ISO_Enter:
- case GDK_3270_Enter:
- string[0] = KEY_CR;
- break;
- case GDK_Escape:
- string[0] = KEY_ESC;
- break;
- case GDK_BackSpace:
- string[0] = KEY_BS;
- break;
- default:
len = 0;
- break;
- }
+ }
+ break;
}
return len;