Code

screen_lyrics: optionally ask before starting an editor
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Sat, 17 Dec 2011 20:58:01 +0000 (21:58 +0100)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Thu, 22 Dec 2011 12:01:22 +0000 (13:01 +0100)
doc/config.sample
doc/ncmpc.1
src/conf.c
src/options.c
src/options.h
src/screen_lyrics.c

index 6ad6809feeffb6d6f9bb9780754813d1d1b0c4ab..c833d5af0650051f569c4cc1af42d1c005d72236 100644 (file)
 ## 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
 
index f09defa4d1e58f699d1b4986f57ef4341abb6106..d3e3c03fa844f7872edf5322e45b90a8b957e217 100644 (file)
@@ -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
index 9754fbd4b31df78615ccc28c539e9e7d835fabc2..7f3ddd51814b4750c4052a9e0a70c481cc7f75ff 100644 (file)
@@ -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
index 9bc338ebf30d5aa15c68b8646d5669a114540db3..35de128e1e602a4b7aed0d5008120471d10ac1ca 100644 (file)
@@ -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,
index 6b1da8bfcc3f110b6925687056cd60369bc65704..c1a833d01066c3157e5badfd5421ac84f87d1213 100644 (file)
@@ -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;
index 676ea151e478e36e6f32b2edb78e30a0cb888f60..ee76e28b45134563715e378f7d9655a500a88d5c 100644 (file)
@@ -28,6 +28,7 @@
 #include "screen.h"
 #include "lyrics.h"
 #include "screen_text.h"
+#include "screen_utils.h"
 #include "ncu.h"
 
 #include <assert.h>
@@ -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;