Hi,
There is a possibility to search for lyric on the Internet and to save
it, but I miss a possibility to edit it, so I wrote it. Here it is.
Jitka Novotna
>From 7d8252ae22a1b1b660a49ca584459b45adc4335b Mon Sep 17 00:00:00 2001
From: Jitka Novotna <ji...@ucw.cz>
Date: Sun, 11 Dec 2011 12:50:02 +0100
Subject: [PATCH] new key to edit lyrics
---
src/command.c | 2 ++
src/command.h | 1 +
src/screen_help.c | 1 +
src/screen_lyrics.c | 32 ++++++++++++++++++++++++++++++++
4 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/command.c b/src/command.c
index 0e7e5a2..43741cf 100644
--- a/src/command.c
+++ b/src/command.c
@@ -241,6 +241,8 @@ static command_definition_t cmds[] = {
N_("Interrupt action") },
{ {'u', 0, 0 }, 0, CMD_LYRICS_UPDATE, "lyrics-update",
N_("Update Lyrics") },
+ { {'e', 0, 0 }, 0, CMD_LYRICS_EDIT, "lyrics-edit",
+ N_("Edit Lyrics") },
#endif
#ifdef ENABLE_OUTPUTS_SCREEN
diff --git a/src/command.h b/src/command.h
index d1e8122..a05ea55 100644
--- a/src/command.h
+++ b/src/command.h
@@ -96,6 +96,7 @@ typedef enum {
CMD_SCREEN_LYRICS,
CMD_SCREEN_OUTPUTS,
CMD_LYRICS_UPDATE,
+ CMD_LYRICS_EDIT,
CMD_INTERRUPT,
CMD_GO_ROOT_DIRECTORY,
CMD_GO_PARENT_DIRECTORY,
diff --git a/src/screen_help.c b/src/screen_help.c
index 038ab3b..e3b2f3d 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -162,6 +162,7 @@ static const struct help_text_row help_text[] = {
from the server */
{ 0, CMD_INTERRUPT, N_("Interrupt retrieval") },
{ 0, CMD_LYRICS_UPDATE, N_("Download lyrics for currently playing song") },
+ { 0, CMD_LYRICS_EDIT, N_("Add or edit lyrics") },
{ 0, CMD_SAVE_PLAYLIST, N_("Save lyrics") },
{ 0, CMD_DELETE, N_("Delete saved lyrics") },
#endif
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index 6de59d5..618623c 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -330,6 +330,35 @@ lyrics_paint(void)
screen_text_paint(&text);
}
+static void
+lyric_edit(struct mpdclient *c)
+{
+ /* save current lyric to a file and run editor on it */
+ pid_t cpid;
+ if ((cpid = fork()) != -1){
+ if (cpid == 0){
+ char * editor = getenv("EDITOR");
+ if (editor != NULL) {
+ ncu_deinit();
+ if (!store_lyr_hd()){
+ char path[1024];
+ path_lyr_file(path, 1024,
+ current.artist,
+ current.title);
+ execl(editor,editor,path,0);
+ }
+ }
+ } else {
+ wait(cpid);
+ ncu_init();
+ }
+ }
+
+ /* lyrics update */
+ screen_lyrics_load(c->song);
+ screen_text_repaint(&text);
+}
+
static bool
lyrics_cmd(struct mpdclient *c, command_t cmd)
{
@@ -368,6 +397,9 @@ lyrics_cmd(struct mpdclient *c, command_t cmd)
screen_text_repaint(&text);
}
return true;
+ case CMD_LYRICS_EDIT:
+ lyric_edit(c);
+ return true;
case CMD_SELECT:
if (current.loader == NULL && current.artist != NULL &&
current.title != NULL) {
--
1.7.2.5
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team