Code

main: use mpdclient_is_connected in assert
[ncmpc.git] / src / screen_find.c
index 0d9d51f0d2ce959f4e5d53dac032ac8811694be7..4113c39a522a1aef207c03540a60dac708ec25a1 100644 (file)
@@ -30,7 +30,7 @@
 #define JUMP_PROMPT _("Jump")
 
 /* query user for a string and find it in a list window */
-int
+bool
 screen_find(struct list_window *lw, command_t findcmd,
            list_window_callback_fn_t callback_fn,
            void *callback_data)
@@ -96,7 +96,7 @@ screen_jump(struct list_window *lw,
            list_window_paint_callback_t paint_callback,
                void *callback_data)
 {
-       char *search_str, *iter;
+       char *search_str, *iter, *temp;
        const int WRLN_MAX_LINE_SIZE = 1024;
        int key = 65;
        command_t cmd;
@@ -114,7 +114,7 @@ screen_jump(struct list_window *lw,
        while(1) {
                key = screen_getch(screen.findbuf);
                /* if backspace or delete was pressed, process instead of ending loop */
-               if (key == 127 || key == 330) {
+               if (key == KEY_BACKSPACE || key == KEY_DC) {
                        int i;
                        if (search_str <= g_utf8_find_prev_char(screen.findbuf, iter))
                                iter = g_utf8_find_prev_char(screen.findbuf, iter);
@@ -145,4 +145,8 @@ screen_jump(struct list_window *lw,
        ungetch(key);
        if ((cmd=get_keyboard_command()) != CMD_NONE)
                do_input_event(cmd);
+
+       temp = g_strdup(search_str);
+       g_free(screen.findbuf);
+       screen.findbuf = temp;
 }