diff options
| author | Jari Vetoniemi <mailroxas@gmail.com> | 2014-11-02 04:08:40 +0200 | 
|---|---|---|
| committer | Jari Vetoniemi <mailroxas@gmail.com> | 2014-11-02 04:08:40 +0200 | 
| commit | ee3c41f162a9068505efdb5025c415b889cf414d (patch) | |
| tree | 472e4949c6e0f22377d4fd5db1d1d5a889a4ed7f /lib | |
| parent | a3e628f1c9f3e7ddfd447d599611729aefc736bb (diff) | |
| download | bemenu-ee3c41f162a9068505efdb5025c415b889cf414d.tar.gz bemenu-ee3c41f162a9068505efdb5025c415b889cf414d.tar.bz2 bemenu-ee3c41f162a9068505efdb5025c415b889cf414d.zip | |
Make shift + tab the current tab behavior, and normal tab to cycle.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bemenu.h | 1 | ||||
| -rw-r--r-- | lib/menu.c | 22 | ||||
| -rw-r--r-- | lib/renderers/curses/curses.c | 3 | ||||
| -rw-r--r-- | lib/renderers/wayland/registry.c | 2 | ||||
| -rw-r--r-- | lib/renderers/wayland/wayland.c | 5 | 
5 files changed, 23 insertions, 10 deletions
| diff --git a/lib/bemenu.h b/lib/bemenu.h index b4a6423..33ff20c 100644 --- a/lib/bemenu.h +++ b/lib/bemenu.h @@ -174,6 +174,7 @@ enum bm_key {      BM_KEY_LINE_DELETE_RIGHT,      BM_KEY_WORD_DELETE,      BM_KEY_TAB, +    BM_KEY_SHIFT_TAB,      BM_KEY_ESCAPE,      BM_KEY_RETURN,      BM_KEY_SHIFT_RETURN, @@ -485,21 +485,21 @@ bm_menu_poll_key(struct bm_menu *menu, uint32_t *out_unicode)  }  static void -menu_next(struct bm_menu *menu, uint32_t count) +menu_next(struct bm_menu *menu, uint32_t count, bool wrap)  {      if (menu->index < count - 1) {          menu->index++; -    } else if (menu->wrap) { +    } else if (wrap) {          menu->index = 0;      }  }  static void -menu_prev(struct bm_menu *menu, uint32_t count) +menu_prev(struct bm_menu *menu, uint32_t count, bool wrap)  {      if (menu->index > 0) {          menu->index--; -    } else if (menu->wrap) { +    } else if (wrap) {          menu->index = count - 1;      }  } @@ -526,7 +526,7 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode)                  menu->cursor -= bm_utf8_rune_prev(menu->filter, menu->cursor);                  menu->curses_cursor -= bm_utf8_rune_width(menu->filter + menu->cursor, oldCursor - menu->cursor);              } else if (menu->lines == 0) { -                menu_prev(menu, count); +                menu_prev(menu, count, menu->wrap);              }              break; @@ -536,7 +536,7 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode)                  menu->cursor += bm_utf8_rune_next(menu->filter, menu->cursor);                  menu->curses_cursor += bm_utf8_rune_width(menu->filter + oldCursor, menu->cursor - oldCursor);              } else if (menu->lines == 0) { -                menu_next(menu, count); +                menu_next(menu, count, menu->wrap);              }              break; @@ -550,11 +550,11 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode)              break;          case BM_KEY_UP: -            menu_prev(menu, count); +            menu_prev(menu, count, menu->wrap);              break;          case BM_KEY_DOWN: -            menu_next(menu, count); +            menu_next(menu, count, menu->wrap);              break;          case BM_KEY_PAGE_UP: @@ -631,6 +631,12 @@ bm_menu_run_with_key(struct bm_menu *menu, enum bm_key key, uint32_t unicode)          case BM_KEY_TAB:              { +                menu_next(menu, count, true); +            } +            break; + +        case BM_KEY_SHIFT_TAB: +            {                  const char *text;                  struct bm_item *highlighted = bm_menu_get_highlighted_item(menu);                  if (highlighted && (text = bm_item_get_text(highlighted))) { diff --git a/lib/renderers/curses/curses.c b/lib/renderers/curses/curses.c index 7923c93..6a7010d 100644 --- a/lib/renderers/curses/curses.c +++ b/lib/renderers/curses/curses.c @@ -297,6 +297,9 @@ poll_key(const struct bm_menu *menu, uint32_t *unicode)          case 9: /* Tab */              return BM_KEY_TAB; +        case 353: /* S-Tab */ +            return BM_KEY_SHIFT_TAB; +          case 18: /* C-r */              return BM_KEY_CONTROL_RETURN; diff --git a/lib/renderers/wayland/registry.c b/lib/renderers/wayland/registry.c index ab64a85..4e5e6dd 100644 --- a/lib/renderers/wayland/registry.c +++ b/lib/renderers/wayland/registry.c @@ -92,7 +92,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format      input->xkb.state = state;      for (uint32_t i = 0; i < MASK_LAST; ++i) -        input->xkb.masks[i] = xkb_keymap_mod_get_index(input->xkb.keymap, BM_XKB_MASK_NAMES[i]); +        input->xkb.masks[i] = 1 << xkb_keymap_mod_get_index(input->xkb.keymap, BM_XKB_MASK_NAMES[i]);  }  static void diff --git a/lib/renderers/wayland/wayland.c b/lib/renderers/wayland/wayland.c index 8967253..4325fa9 100644 --- a/lib/renderers/wayland/wayland.c +++ b/lib/renderers/wayland/wayland.c @@ -34,6 +34,9 @@ poll_key(const struct bm_menu *menu, unsigned int *unicode)      uint32_t mods = wayland->input.modifiers;      *unicode = xkb_state_key_get_utf32(wayland->input.xkb.state, wayland->input.code); +    if (!*unicode && wayland->input.code == 23 && (mods & MOD_SHIFT)) +        return BM_KEY_SHIFT_TAB; +      switch (wayland->input.sym) {          case XKB_KEY_Up:              return BM_KEY_UP; @@ -66,7 +69,7 @@ poll_key(const struct bm_menu *menu, unsigned int *unicode)              return (mods & MOD_SHIFT ? BM_KEY_LINE_DELETE_LEFT : BM_KEY_DELETE);          case XKB_KEY_Tab: -            return BM_KEY_TAB; +            return (mods & MOD_SHIFT ? BM_KEY_SHIFT_TAB : BM_KEY_TAB);          case XKB_KEY_Insert:              return BM_KEY_SHIFT_RETURN; | 
