Code

keyboard: add keyboard_unread()
[ncmpc.git] / src / keyboard.c
index 80a1eeeae16f41e199fa11dab8cb73ba8216ecd9..c5d8c7814199781863188c7e892acfe3bca77ae6 100644 (file)
@@ -27,7 +27,7 @@
 
 #include <unistd.h>
 
-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);
+}