From 07749b7365764dd7a43d476936cb18bf6366e9f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Sat, 17 Dec 2011 21:58:01 +0100 Subject: [PATCH] screen_lyrics: optionally ask before starting an editor --- doc/config.sample | 3 +++ doc/ncmpc.1 | 3 +++ src/conf.c | 7 +++++++ src/options.c | 1 + src/options.h | 1 + src/screen_lyrics.c | 13 +++++++++++++ 6 files changed, 28 insertions(+) diff --git a/doc/config.sample b/doc/config.sample index 6ad6809..c833d5a 100644 --- a/doc/config.sample +++ b/doc/config.sample @@ -104,6 +104,9 @@ ## The text editor used for editing lyrics. #text-editor = emacs +## Ask before starting an editor. +#text-editor-ask = yes + ## Display song length in second column #second-column = yes diff --git a/doc/ncmpc.1 b/doc/ncmpc.1 index f09defa..d3e3c03 100644 --- a/doc/ncmpc.1 +++ b/doc/ncmpc.1 @@ -136,6 +136,9 @@ Show the name of the plugin used to receive lyrics on the lyrics screen. .B text\-editor = EDITOR The text editor used for editing lyrics. .TP +.B text\-editor\-ask = yes|no +Ask before starting an editor. +.TP .B second-column = yes|no Display song length in a second column. .SS Display diff --git a/src/conf.c b/src/conf.c index 9754fbd..7f3ddd5 100644 --- a/src/conf.c +++ b/src/conf.c @@ -79,6 +79,7 @@ #define CONF_LYRICS_AUTOSAVE "lyrics-autosave" #define CONF_LYRICS_SHOW_PLUGIN "lyrics-show-plugin" #define CONF_TEXT_EDITOR "text-editor" +#define CONF_TEXT_EDITOR_ASK "text-editor-ask" #define CONF_SECOND_COLUMN "second-column" static bool @@ -536,6 +537,12 @@ parse_line(char *line) } #else {} +#endif + else if (!strcasecmp(name, CONF_TEXT_EDITOR_ASK)) +#ifdef ENABLE_LYRICS_SCREEN + options.text_editor_ask = str2bool(value); +#else + {} #endif else if (!strcasecmp(CONF_SECOND_COLUMN, name)) #ifdef NCMPC_MINI diff --git a/src/options.c b/src/options.c index 9bc338e..35de128 100644 --- a/src/options.c +++ b/src/options.c @@ -53,6 +53,7 @@ options_t options = { .lyrics_timeout = DEFAULT_LYRICS_TIMEOUT, .lyrics_autosave = false, .lyrics_show_plugin = false, + .text_editor_ask = true, #endif .find_wrap = true, .scroll_offset = 0, diff --git a/src/options.h b/src/options.h index 6b1da8b..c1a833d 100644 --- a/src/options.h +++ b/src/options.h @@ -50,6 +50,7 @@ typedef struct { bool lyrics_autosave; bool lyrics_show_plugin; char *text_editor; + bool text_editor_ask; #endif bool find_wrap; bool find_show_last_pattern; diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 676ea15..ee76e28 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -28,6 +28,7 @@ #include "screen.h" #include "lyrics.h" #include "screen_text.h" +#include "screen_utils.h" #include "ncu.h" #include @@ -356,6 +357,18 @@ lyrics_edit(void) return; } + 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); + if (!really) { + screen_status_message(_("Aborted")); + return; + } + } + if (store_lyr_hd() < 0) return; -- 2.30.2