Code

keyboard: add keyboard_unread()
[ncmpc.git] / src / screen_find.c
index 88872df5097e0e3ea38073b0f2a4a02bb4a90152..b838421f4f94eadae78b382a7f086ec656f44925 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2010 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
 #include "screen_utils.h"
 #include "screen_status.h"
 #include "screen.h"
+#include "keyboard.h"
 #include "i18n.h"
 #include "options.h"
 #include "ncmpc.h"
@@ -49,8 +50,8 @@ screen_find(struct list_window *lw, command_t findcmd,
                if (screen.findbuf) {
                        g_free(screen.findbuf);
                        screen.findbuf=NULL;
-               }
-               /* continue... */
+       }
+               /* fall through */
 
        case CMD_LIST_FIND_NEXT:
        case CMD_LIST_RFIND_NEXT:
@@ -93,9 +94,8 @@ screen_find(struct list_window *lw, command_t findcmd,
  * which begins with this string while the users types */
 void
 screen_jump(struct list_window *lw,
-           list_window_callback_fn_t callback_fn,
-           list_window_paint_callback_t paint_callback,
-           void *callback_data)
+           list_window_callback_fn_t callback_fn, void *callback_data,
+           list_window_paint_callback_t paint_callback, void *paint_data)
 {
        const int WRLN_MAX_LINE_SIZE = 1024;
        int key = 65;
@@ -134,20 +134,16 @@ screen_jump(struct list_window *lw,
 
                /* repaint the list_window */
                if (paint_callback != NULL)
-                       list_window_paint2(lw, paint_callback, callback_data);
+                       list_window_paint2(lw, paint_callback, paint_data);
                else
                        list_window_paint(lw, callback_fn, callback_data);
                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);
 }