diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-03-23 17:44:29 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-03-23 17:44:29 +0100 |
| commit | 72458b53a52566689d7094c69ffa2f9d6cfd4519 (patch) | |
| tree | 9d32036ef87e16ae874a1f1a5529e8d8a17ee033 | |
| parent | 77a3b5b42ababc65ef77f7bd843eec9bf3a7936b (diff) | |
add vim keys
| -rw-r--r-- | dmenu-wl.c | 101 |
1 files changed, 61 insertions, 40 deletions
@@ -429,52 +429,73 @@ void handle_keyboard_event() { char buf[8]; - int genmatch = 0; if (client.keys.state == WL_KEYBOARD_KEY_STATE_PRESSED) { - switch (client.keys.sym) { - case XKB_KEY_Down: - if (options.selection->next_match) - options.selection = options.selection->next_match; - calculate_scroll(); + if (client.keys.alt) { + switch (client.keys.sym) { + case XKB_KEY_j: + if (options.selection->next_match) + options.selection = options.selection->next_match; + calculate_scroll(); break; - case XKB_KEY_Up: - if (options.selection->previous_match) - options.selection = options.selection->previous_match; - calculate_scroll(); - break; - case XKB_KEY_Left: - break; - case XKB_KEY_Right: - break; - case XKB_KEY_KP_Enter: /* fallthrough */ - case XKB_KEY_Return: - fputs(options.selection ? options.selection->name: input_field, stdout); - running = 0; - break; - case XKB_KEY_Escape: - running = 0; - break; - case XKB_KEY_Tab: - if (options.selection) - strncpy(input_field, options.selection->name, MAX_LINE_LENGTH); - break; - case XKB_KEY_BackSpace: - if (strlen(input_field)) - input_field[strlen(input_field) - 1] = 0; - genmatch = 1; - break; - default: - if (xkb_keysym_to_utf8(client.keys.sym, buf, sizeof(buf))) { - strncpy(input_field + strlen(input_field), buf, MAX_LINE_LENGTH - strlen(input_field)); - } - genmatch = 1; + case XKB_KEY_k: + if (options.selection->previous_match) + options.selection = options.selection->previous_match; + calculate_scroll(); break; + case XKB_KEY_g: + options.selection = options.first_match; + calculate_scroll(); + break; + case XKB_KEY_G: + options.selection = options.last_match; + calculate_scroll(); + break; + default: break; + } + } else { + switch (client.keys.sym) { + case XKB_KEY_Down: + if (options.selection->next_match) + options.selection = options.selection->next_match; + calculate_scroll(); + break; + case XKB_KEY_Up: + if (options.selection->previous_match) + options.selection = options.selection->previous_match; + calculate_scroll(); + break; + case XKB_KEY_Left: + break; + case XKB_KEY_Right: + break; + case XKB_KEY_KP_Enter: /* fallthrough */ + case XKB_KEY_Return: + fputs(options.selection ? options.selection->name: input_field, stdout); + running = 0; + break; + case XKB_KEY_Escape: + running = 0; + break; + case XKB_KEY_Tab: + if (options.selection) + strncpy(input_field, options.selection->name, MAX_LINE_LENGTH); + break; + case XKB_KEY_BackSpace: + if (strlen(input_field)) + input_field[strlen(input_field) - 1] = 0; + generate_matches(); + break; + default: + if (xkb_keysym_to_utf8(client.keys.sym, buf, sizeof(buf))) { + strncpy(input_field + strlen(input_field), buf, MAX_LINE_LENGTH - strlen(input_field)); + generate_matches(); + } + break; + } } - + if (running) { - if (genmatch) - generate_matches(); draw_dmenu(active_monitor); } } |