X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_utils.c;h=39b11622aeba0a35848f4b17981200204a89d0aa;hb=7b4a9f27827f8cca56cff52ecc2144093ebadff9;hp=063893e15652ae928ffb0f4736acdc428e9dcc9d;hpb=cf98ad001d01ebce6cebf934027a636056302f7d;p=ncmpc.git diff --git a/src/screen_utils.c b/src/screen_utils.c index 063893e..39b1162 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -25,19 +25,9 @@ #include "options.h" #include "colors.h" #include "wreadln.h" -#ifndef NCMPC_H -#include "ncmpc.h" -#endif /* NCMPC_H */ #include -#include -#include - -#define FIND_PROMPT _("Find") -#define RFIND_PROMPT _("Find backward") -#define JUMP_PROMPT _("Jump") - void screen_bell(void) { @@ -113,121 +103,6 @@ screen_read_password(const char *prompt) return ret; } -/* query user for a string and find it in a list window */ -int -screen_find(list_window_t *lw, - int rows, - command_t findcmd, - list_window_callback_fn_t callback_fn, - void *callback_data) -{ - int reversed = 0; - bool found; - const char *prompt = FIND_PROMPT; - char *value = options.find_show_last_pattern ? (char *) -1 : NULL; - - if (findcmd == CMD_LIST_RFIND || findcmd == CMD_LIST_RFIND_NEXT) { - prompt = RFIND_PROMPT; - reversed = 1; - } - - switch (findcmd) { - case CMD_LIST_FIND: - case CMD_LIST_RFIND: - if (screen.findbuf) { - g_free(screen.findbuf); - screen.findbuf=NULL; - } - /* continue... */ - - case CMD_LIST_FIND_NEXT: - case CMD_LIST_RFIND_NEXT: - if (!screen.findbuf) - screen.findbuf=screen_readln(prompt, - value, - &screen.find_history, - NULL); - - if (screen.findbuf == NULL) - return 1; - - found = reversed - ? list_window_rfind(lw, - callback_fn, callback_data, - screen.findbuf, - options.find_wrap, - options.bell_on_wrap, - rows) - : list_window_find(lw, - callback_fn, callback_data, - screen.findbuf, - options.find_wrap, - options.bell_on_wrap); - if (!found) { - screen_status_printf(_("Unable to find \'%s\'"), - screen.findbuf); - screen_bell(); - } - return 1; - default: - break; - } - return 0; -} - -/* query user for a string and jump to the entry - * which begins with this string while the users types */ -void -screen_jump(struct list_window *lw, - list_window_callback_fn_t callback_fn, - void *callback_data) -{ - char *search_str, *iter; - const int WRLN_MAX_LINE_SIZE = 1024; - int key = 65; - command_t cmd; - - if (screen.findbuf) { - g_free(screen.findbuf); - screen.findbuf = NULL; - } - screen.findbuf = g_malloc0(WRLN_MAX_LINE_SIZE); - /* In screen.findbuf is the whole string which is displayed in the status_window - * and search_str is the string the user entered (without the prompt) */ - search_str = screen.findbuf + g_snprintf(screen.findbuf, WRLN_MAX_LINE_SIZE, "%s: ", JUMP_PROMPT); - iter = search_str; - - /* unfortunately wgetch returns "next/previous-page" not as an ascii-char */ - while(!g_ascii_iscntrl(key) && key != KEY_NPAGE && key != KEY_PPAGE) { - key = screen_getch(screen.findbuf); - /* if backspace or delete was pressed */ - if (key == KEY_BACKSPACE || key == 330) { - int i; - /* don't end the loop */ - key = 65; - if (search_str <= g_utf8_find_prev_char(screen.findbuf, iter)) - iter = g_utf8_find_prev_char(screen.findbuf, iter); - for (i = 0; *(iter + i) != '\0'; i++) - *(iter + i) = '\0'; - continue; - } - else { - *iter = key; - if (iter < screen.findbuf + WRLN_MAX_LINE_SIZE - 3) - ++iter; - } - list_window_jump(lw, callback_fn, callback_data, search_str); - /* repaint the list_window */ - list_window_paint(lw, callback_fn, callback_data); - wrefresh(lw->w); - } - - /* ncmpc should get the command */ - ungetch(key); - if ((cmd=get_keyboard_command()) != CMD_NONE) - do_input_event(cmd); -} - void screen_display_completion_list(GList *list) {