Code

keyboard: add keyboard_unread()
authorMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 11:14:54 +0000 (12:14 +0100)
committerMax Kellermann <max.kellermann@gmail.com>
Mon, 20 Mar 2017 11:14:54 +0000 (12:14 +0100)
src/keyboard.c
src/keyboard.h
src/screen_find.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);
+}
index ea888e5244a9983d7dce69ff558206b4c135b1b8..e34b9195d61172ed3dd77eac3846af22f9da3ee4 100644 (file)
 #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
index 2427801274c5cbdb2c32854474689e228ac18cd4..b838421f4f94eadae78b382a7f086ec656f44925 100644 (file)
@@ -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);
 }