From: Max Kellermann Date: Mon, 20 Mar 2017 20:09:39 +0000 (+0100) Subject: screen_utils: automatically append "[y/n]" X-Git-Tag: v0.27~19 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=642bdd04cb9c093689ddacdb6b2784b017382c3a;p=ncmpc.git screen_utils: automatically append "[y/n]" --- diff --git a/src/screen_file.c b/src/screen_file.c index 06cb5ea..2af1655 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -210,7 +210,7 @@ handle_delete(struct mpdclient *c) const struct mpd_playlist *playlist = mpd_entity_get_playlist(entity); char *str = utf8_to_locale(g_basename(mpd_playlist_get_path(playlist))); - char *buf = g_strdup_printf(_("Delete playlist %s [%s/%s] ? "), str, YES, NO); + char *buf = g_strdup_printf(_("Delete playlist %s?"), str); g_free(str); bool delete = screen_get_yesno(buf, false); g_free(buf); diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 0bce7c4..11786c1 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -363,11 +363,9 @@ lyrics_edit(void) } if (options.text_editor_ask) { - char *buf = g_strdup_printf( - _("Do you really want to start an editor and edit these lyrics [%s/%s]? "), - YES, NO); - bool really = screen_get_yesno(buf, false); - g_free(buf); + const char *prompt = + _("Do you really want to start an editor and edit these lyrics?"); + bool really = screen_get_yesno(prompt, false); if (!really) { screen_status_message(_("Aborted")); return; diff --git a/src/screen_queue.c b/src/screen_queue.c index d364c91..45505ee 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -279,8 +279,7 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname) if (mpd_connection_get_error(connection) == MPD_ERROR_SERVER && mpd_connection_get_server_error(connection) == MPD_SERVER_ERROR_EXIST && mpd_connection_clear_error(connection)) { - char *buf = g_strdup_printf(_("Replace %s [%s/%s] ? "), - filename, YES, NO); + char *buf = g_strdup_printf(_("Replace %s?"), filename); bool replace = screen_get_yesno(buf, false); g_free(buf); diff --git a/src/screen_utils.c b/src/screen_utils.c index 8f69930..6c5ce43 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -72,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])