X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_utils.c;h=6c5ce43368c5310058534d9df608b613a1736ac6;hb=325049bb26fa97627800a3423a8462ab6ab8bfe9;hp=fee0e2a5c2d748380be37250b7d874371467cfad;hpb=386ea7f72f2e08d037111bdb6272d91e7bba6ef3;p=ncmpc.git diff --git a/src/screen_utils.c b/src/screen_utils.c index fee0e2a..6c5ce43 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -38,6 +38,17 @@ screen_bell(void) flash(); } +static bool +ignore_key(int key) +{ + return +#ifdef HAVE_GETMOUSE + /* ignore mouse events */ + key == KEY_MOUSE || +#endif + key == ERR; +} + int screen_getch(const char *prompt) { @@ -52,14 +63,7 @@ screen_getch(const char *prompt) curs_set(1); int key; - while ((key = wgetch(w)) == ERR) - ; - -#ifdef HAVE_GETMOUSE - /* ignore mouse events */ - if (key == KEY_MOUSE) - return screen_getch(prompt); -#endif + while (ignore_key(key = wgetch(w))) {} noecho(); curs_set(0); @@ -68,12 +72,15 @@ screen_getch(const char *prompt) } bool -screen_get_yesno(const char *prompt, bool def) +screen_get_yesno(const char *_prompt, bool def) { /* NOTE: if one day a translator decides to use a multi-byte character for one of the yes/no keys, we'll have to parse it properly */ + char *prompt = g_strdup_printf(_("%s [%s/%s] "), _prompt, YES, NO); int key = tolower(screen_getch(prompt)); + g_free(prompt); + if (key == YES[0]) return true; else if (key == NO[0]) @@ -153,28 +160,5 @@ screen_display_completion_list(GList *list) } wrefresh(w); - doupdate(); colors_use(w, COLOR_LIST); } - -#ifndef NCMPC_MINI -void -set_xterm_title(const char *format, ...) -{ - /* the current xterm title exists under the WM_NAME property */ - /* and can be retrieved with xprop -id $WINDOWID */ - - if (options.enable_xterm_title) { - if (g_getenv("WINDOWID")) { - va_list ap; - va_start(ap,format); - char *msg = g_strdup_vprintf(format,ap); - va_end(ap); - printf("\033]0;%s\033\\", msg); - fflush(stdout); - g_free(msg); - } else - options.enable_xterm_title = FALSE; - } -} -#endif