sort out when we add modifiers to keys. Fix Alt+Tab. remove ta definition.
authorNalin Dahyabhai <nalin@src.gnome.org>
Mon, 25 Nov 2002 21:08:28 +0000 (21:08 +0000)
committerNalin Dahyabhai <nalin@src.gnome.org>
Mon, 25 Nov 2002 21:08:28 +0000 (21:08 +0000)
* src/keymap.c: sort out when we add modifiers to keys.  Fix Alt+Tab.
* termcaps/xterm: remove ta definition.

ChangeLog
src/keymap.c
src/keymap.h
src/vte.c
termcaps/xterm

index 9bee8f5..5290165 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-11-25  nalin
+       * src/keymap.c: sort out when we add modifiers to keys.  Fix Alt+Tab.
+       * termcaps/xterm: remove ta definition.
+
 2002-11-25  nalin
        * src/debug.c, src/debug.h: add keyboard debugging class.
        * src/dumpkeys.c: refresh on Ctrl-L, reset on 'r'.
index a797dcb..b2d2679 100644 (file)
@@ -89,11 +89,17 @@ static struct _vte_keymap_entry _vte_keymap_GDK_space[] = {
 };
 
 static struct _vte_keymap_entry _vte_keymap_GDK_Tab[] = {
-       /* Shift+Tab = BackTab */
-       {cursor_all, keypad_all, fkey_all, GDK_SHIFT_MASK, NULL, 0, "kB"},
+       /* Shift+Tab = Back-Tab */
+       {cursor_all, keypad_all, fkey_all,
+        GDK_SHIFT_MASK, NULL, 0, "kB"},
        {cursor_all, keypad_all, fkey_all,
         GDK_SHIFT_MASK, _VTE_CAP_CSI "Z", -1, NULL},
+       /* Alt+Tab = Esc+Tab */
+       {cursor_all, keypad_all, fkey_all,
+        VTE_META_MASK, _VTE_CAP_ESC "\t", -1, NULL},
        /* Regular tab. */
+       {cursor_all, keypad_all, fkey_all,
+        0, NULL, 0, "ta"},
        {cursor_all, keypad_all, fkey_all, 0, "\t", 1, NULL},
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, NULL},
 };
@@ -113,14 +119,9 @@ static struct _vte_keymap_entry _vte_keymap_GDK_Escape[] = {
 
 static struct _vte_keymap_entry _vte_keymap_GDK_Insert[] = {
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, "kI"},
-       {cursor_all, keypad_all, fkey_sun,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "2;5z", -1, NULL},
-       {cursor_all, keypad_all, fkey_notsunhp,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "2;5~", -1, NULL},
-       {cursor_all, keypad_all, fkey_hp,
-        GDK_CONTROL_MASK, _VTE_CAP_ESC "Q", -1, NULL},
+       {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "Q", -1, NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "2z", -1, NULL},
-       {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "2~", -1, NULL},
+       {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "2~", -1, NULL},
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, NULL},
 };
 
@@ -145,26 +146,16 @@ static struct _vte_keymap_entry _vte_keymap_GDK_End[] = {
 
 static struct _vte_keymap_entry _vte_keymap_GDK_Page_Up[] = {
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, "kP"},
-       {cursor_all, keypad_all, fkey_notsunhp,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "5;5~", -1, NULL},
-       {cursor_all, keypad_all, fkey_sun,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "5;5z", -1, NULL},
-       {cursor_all, keypad_all, fkey_hp,
-        GDK_CONTROL_MASK, _VTE_CAP_ESC "T", -1, NULL},
-       {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "5~", -1, NULL},
+       {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "T", -1, NULL},
+       {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "5~", -1, NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "5z", -1, NULL},
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, NULL},
 };
 
 static struct _vte_keymap_entry _vte_keymap_GDK_Page_Down[] = {
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, "kN"},
-       {cursor_all, keypad_all, fkey_notsunhp,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "6;5~", -1, NULL},
-       {cursor_all, keypad_all, fkey_sun,
-        GDK_CONTROL_MASK, _VTE_CAP_CSI "6;5z", -1, NULL},
-       {cursor_all, keypad_all, fkey_hp,
-        GDK_CONTROL_MASK, _VTE_CAP_ESC "S", -1, NULL},
-       {cursor_all, keypad_all, fkey_notsun, 0, _VTE_CAP_CSI "6~", -1, NULL},
+       {cursor_all, keypad_all, fkey_hp, 0, _VTE_CAP_ESC "S", -1, NULL},
+       {cursor_all, keypad_all, fkey_notsunhp, 0, _VTE_CAP_CSI "6~", -1, NULL},
        {cursor_all, keypad_all, fkey_sun, 0, _VTE_CAP_CSI "6z", -1, NULL},
        {cursor_all, keypad_all, fkey_all, 0, NULL, 0, NULL},
 };
@@ -848,7 +839,6 @@ _vte_keymap_map(guint keyval,
                const char **special)
 {
        int i;
-       gboolean fkey;
        struct _vte_keymap_entry *entries;
        enum _vte_cursor_mode cursor_mode;
        enum _vte_keypad_mode keypad_mode;
@@ -915,7 +905,6 @@ _vte_keymap_map(guint keyval,
 
        /* Search for the list for this key. */
        entries = NULL;
-       fkey = FALSE;
        for (i = 0; i < G_N_ELEMENTS(_vte_keymap); i++) {
 #ifdef VTE_DEBUG
                int j;
@@ -945,10 +934,6 @@ _vte_keymap_map(guint keyval,
                g_assert(mods == 0);
                entries = NULL;
 #endif
-               if (_vte_keymap[i].keyval == GDK_F1) {
-                       /* Every entry after this point is a function key. */
-                       fkey = TRUE;
-               }
                if (_vte_keymap[i].keyval == keyval) {
                        /* Found it! */
                        entries = _vte_keymap[i].entries;
@@ -1002,6 +987,14 @@ _vte_keymap_map(guint keyval,
                                *normal_length = strlen(entries[i].normal);
                                *normal = g_strdup(entries[i].normal);
                        }
+                       _vte_keymap_key_add_key_modifiers(keyval,
+                                                         modifiers,
+                                                         sun_mode,
+                                                         hp_mode,
+                                                         legacy_mode,
+                                                         vt220_mode,
+                                                         normal,
+                                                         normal_length);
 #ifdef VTE_DEBUG
                        if (_vte_debug_on(VTE_DEBUG_KEYBOARD)) {
                                int j;
@@ -1101,11 +1094,27 @@ _vte_keymap_key_is_modifier(guint keyval)
 }
 
 static gboolean
-_vte_keymap_key_is_fkey(guint keyval)
+_vte_keymap_key_gets_modifiers(guint keyval)
 {
        gboolean fkey = FALSE;
        /* Determine if this is just a modifier key. */
        switch (keyval) {
+       case GDK_Up:
+       case GDK_Down:
+       case GDK_Left:
+       case GDK_Right:
+       case GDK_Insert:
+       case GDK_Delete:
+       case GDK_Page_Up:
+       case GDK_Page_Down:
+       case GDK_KP_Up:
+       case GDK_KP_Down:
+       case GDK_KP_Left:
+       case GDK_KP_Right:
+       case GDK_KP_Insert:
+       case GDK_KP_Delete:
+       case GDK_KP_Page_Up:
+       case GDK_KP_Page_Down:
        case GDK_F1:
        case GDK_F2:
        case GDK_F3:
@@ -1151,14 +1160,14 @@ _vte_keymap_key_is_fkey(guint keyval)
 }
 
 void
-_vte_keymap_key_add_fkey_modifiers(guint keyval,
-                                  GdkModifierType modifiers,
-                                  gboolean sun_mode,
-                                  gboolean hp_mode,
-                                  gboolean legacy_mode,
-                                  gboolean vt220_mode,
-                                  char **normal,
-                                  gssize *normal_length)
+_vte_keymap_key_add_key_modifiers(guint keyval,
+                                 GdkModifierType modifiers,
+                                 gboolean sun_mode,
+                                 gboolean hp_mode,
+                                 gboolean legacy_mode,
+                                 gboolean vt220_mode,
+                                 char **normal,
+                                 gssize *normal_length)
 {
        int modifier, offset;
        char *nnormal;
@@ -1168,7 +1177,7 @@ _vte_keymap_key_add_fkey_modifiers(guint keyval,
                                GDK_CONTROL_MASK |
                                VTE_META_MASK;
 
-       if (!_vte_keymap_key_is_fkey(keyval)) {
+       if (!_vte_keymap_key_gets_modifiers(keyval)) {
                return;
        }
        if (sun_mode || hp_mode || vt220_mode) {
@@ -1212,12 +1221,18 @@ _vte_keymap_key_add_fkey_modifiers(guint keyval,
 
        nnormal = g_malloc0(*normal_length + 3);
        memcpy(nnormal, *normal, *normal_length);
-       if (strlen(nnormal) > 0) {
+       if (strlen(nnormal) > 1) {
                offset = strlen(nnormal) - 1;
-               nnormal[offset + 2] = nnormal[offset];
-               nnormal[offset + 1] = modifier + '0';
-               nnormal[offset + 0] = ';';
-               *normal_length += 2;
+               if (g_ascii_isdigit(nnormal[offset - 1])) {
+                       nnormal[offset + 2] = nnormal[offset];
+                       nnormal[offset + 1] = modifier + '0';
+                       nnormal[offset + 0] = ';';
+                       *normal_length += 2;
+               } else {
+                       nnormal[offset + 1] = nnormal[offset];
+                       nnormal[offset + 0] = modifier + '0';
+                       *normal_length += 1;
+               }
                g_free(*normal);
                *normal = nnormal;
        } else {
index 8ed11a5..52b8296 100644 (file)
@@ -52,14 +52,14 @@ void _vte_keymap_map(guint keyval,
 gboolean _vte_keymap_key_is_modifier(guint keyval);
 
 /* Add modifiers to the sequence if they're needed. */
-void _vte_keymap_key_add_fkey_modifiers(guint keyval,
-                                       GdkModifierType modifiers,
-                                       gboolean sun_mode,
-                                       gboolean hp_mode,
-                                       gboolean legacy_mode,
-                                       gboolean vt220_mode,
-                                       char **normal,
-                                       gssize *normal_length);
+void _vte_keymap_key_add_key_modifiers(guint keyval,
+                                      GdkModifierType modifiers,
+                                      gboolean sun_mode,
+                                      gboolean hp_mode,
+                                      gboolean legacy_mode,
+                                      gboolean vt220_mode,
+                                      char **normal,
+                                      gssize *normal_length);
 
 G_END_DECLS
 
index 7fcd537..423df12 100644 (file)
--- a/src/vte.c
+++ b/src/vte.c
@@ -7514,14 +7514,6 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                                vte_terminal_feed_child(terminal, "\e", 1);
                        }
                        if (normal_length > 0) {
-                               _vte_keymap_key_add_fkey_modifiers(keyval,
-                                                                  modifiers,
-                                                                  terminal->pvt->sun_fkey_mode,
-                                                                  terminal->pvt->hp_fkey_mode,
-                                                                  terminal->pvt->legacy_fkey_mode,
-                                                                  terminal->pvt->vt220_fkey_mode,
-                                                                  &normal,
-                                                                  &normal_length);
                                vte_terminal_feed_child(terminal,
                                                        normal, normal_length);
                        }
@@ -7535,14 +7527,14 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
                                                                 tterm,
                                                                 special,
                                                                 &normal_length);
-                       _vte_keymap_key_add_fkey_modifiers(keyval,
-                                                          modifiers,
-                                                          terminal->pvt->sun_fkey_mode,
-                                                          terminal->pvt->hp_fkey_mode,
-                                                          terminal->pvt->legacy_fkey_mode,
-                                                          terminal->pvt->vt220_fkey_mode,
-                                                          &normal,
-                                                          &normal_length);
+                       _vte_keymap_key_add_key_modifiers(keyval,
+                                                         modifiers,
+                                                         terminal->pvt->sun_fkey_mode,
+                                                         terminal->pvt->hp_fkey_mode,
+                                                         terminal->pvt->legacy_fkey_mode,
+                                                         terminal->pvt->vt220_fkey_mode,
+                                                         &normal,
+                                                         &normal_length);
                        output = g_strdup_printf(normal, 1);
                        vte_terminal_feed_child(terminal, output, -1);
                        g_free(output);
index 3cafbcf..4e70960 100644 (file)
@@ -18,7 +18,7 @@ xterm-xfree86|xterm-new|xterm terminal emulator (XFree86):\
        :kb=^H:ke=\E[?1l\E>:kh=\E[1~:\
        :ks=\E[?1h\E=:le=^H:mb=\E[5m:md=\E[1m:\
        :me=\E[m\017:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:se=\E[27m:\
-       :sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:te=\E[?1047l\E[?1048l:\
+       :sf=^J:so=\E[7m:sr=\EM:st=\EH:te=\E[?1047l\E[?1048l:\
        :ti=\E[?1048h\E[?1047h:ue=\E[24m:up=\E[A:us=\E[4m:\
        :vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h:
 # xterm-redhat is identical to xterm-xfree86 with the addition of a small