From: Max Kellermann Date: Mon, 20 Mar 2017 11:14:54 +0000 (+0100) Subject: keyboard: add keyboard_unread() X-Git-Tag: v0.26~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e29f38360a298fe5c374f7b34a1ac9762702657c;p=ncmpc.git keyboard: add keyboard_unread() --- diff --git a/src/keyboard.c b/src/keyboard.c index 80a1eee..c5d8c78 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -27,7 +27,7 @@ #include -command_t +static command_t get_keyboard_command(void) { int key = wgetch(stdscr); @@ -65,3 +65,13 @@ keyboard_init(void) g_io_add_watch(channel, G_IO_IN, keyboard_event, NULL); g_io_channel_unref(channel); } + +void +keyboard_unread(int key) +{ + ungetch(key); + + command_t cmd = get_keyboard_command(); + if (cmd != CMD_NONE) + do_input_event(cmd); +} diff --git a/src/keyboard.h b/src/keyboard.h index ea888e5..e34b919 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -20,12 +20,10 @@ #ifndef KEYBOARD_H #define KEYBOARD_H -#include "command.h" - void keyboard_init(void); -command_t -get_keyboard_command(void); +void +keyboard_unread(int key); #endif diff --git a/src/screen_find.c b/src/screen_find.c index 2427801..b838421 100644 --- a/src/screen_find.c +++ b/src/screen_find.c @@ -140,14 +140,10 @@ screen_jump(struct list_window *lw, wrefresh(lw->w); } - /* ncmpc should get the command */ - ungetch(key); - - command_t cmd; - if ((cmd=get_keyboard_command()) != CMD_NONE) - do_input_event(cmd); - char *temp = g_strdup(search_str); g_free(screen.findbuf); screen.findbuf = temp; + + /* ncmpc should get the command */ + keyboard_unread(key); }