summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 35c6c16)
raw | patch | inline | side by side (parent: 35c6c16)
author | Andreas Obergrusberger <tradiaz@yahoo.de> | |
Fri, 16 Feb 2007 15:42:08 +0000 (15:42 +0000) | ||
committer | Andreas Obergrusberger <tradiaz@yahoo.de> | |
Fri, 16 Feb 2007 15:42:08 +0000 (15:42 +0000) |
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@5346 09075e82-0dd4-0310-85a5-a0d7c8717e4f
15 files changed:
ChangeLog | patch | blob | history | |
TODO | patch | blob | history | |
doc/config.sample | patch | blob | history | |
doc/ncmpc.1 | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/ncmpc.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen.c | patch | blob | history | |
src/screen_help.c | patch | blob | history | |
src/screen_search.c | patch | blob | history | |
src/strfsong.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index fc0fbb762649ba6baa115b58092996172cb0eb52..715a4ca822aa2fc49f9f835efc0622365d62c36f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
-2007-02-01 Andreas Obergrusberger <tradiazqyahoo.de>
+2007-02-16 Andreas Obergrusberger <tradiaz@yahoo.de>
+ + nj has posted a lot of patches on the bug tracker
+ * added the option to search for artist and title at the same time
+ * fixed a drawing problem with the help screen
+ * made scrolling of the song title when windows is too small optional
+
+2007-02-01 Andreas Obergrusberger <tradiaz@yahoo.de>
* fixed a bad bug in leoslyrics that made every
second line an empty line
* uploaded some updates for the lyrics system
2006-08-4 Anderas Obergrusberger <tradiaz@yahoo.de>
* tradiaz is temporary maintainer of a special branch of ncmpc now
- https://svn.musicpd.org/mpd/ncmpc/branches/tradiaz
+ (https://svn.musicpd.org/mpd/ncmpc/branches/tradiaz)
the development will go on there till kaw shows up again
contact him: tradiaz@yahoo.de
index cdcdd2f9bf3f13cb675a3d7fc62289c3042e4a9c..7a34370d913f97e240af443ce8937cf9f4f951cd 100644 (file)
--- a/TODO
+++ b/TODO
- * Make status line scrolling optional
-
* Scroll long list entries, move left/right (#242)
* Search screen (with a simple ui)
* LIRC support (without irpty) ?
- * In-program option editor
+ /* In-program option editor */ do not touch, already in develpoment ;)
diff --git a/doc/config.sample b/doc/config.sample
index 3c80c2f530668be2edcc75fc5a375f68f22a1a55..c3c532ca2970ed0d7c3cb38f5ce2128a1de98c2b 100644 (file)
--- a/doc/config.sample
+++ b/doc/config.sample
## mpd crossfade time
##crossfade-time = 10
+## scroll long titles
+#scroll = yes
+
+## separator to use when scrolling
+#scroll-sep = " *** "
+
##
## Color configuration
##
diff --git a/doc/ncmpc.1 b/doc/ncmpc.1
index 11c3a55192f31555dba2d3f2814ac397ed00ff37..afcd78b156f5b322af184976661fe652b46d4006 100644 (file)
--- a/doc/ncmpc.1
+++ b/doc/ncmpc.1
.B crossfade\-time = CROSSFADE TIME
Default crossfade time in Seconds
.TP
+.B scroll = yes|no
+Scroll the title if it is too long for the screen.
+.TP
+.B scroll\-sep = STRING
+The separator to show at the end of the scrolling title.
+.TP
.B seek\-time = NUM
Seek forward/backward by NUM seconds.
.TP
Since MPD uses UTF\-8, ncmpc needs to convert characters to the
charset used by the local system. If you get character conversion errors when your running ncmpc you probably need to set up your locale. This is done by setting any of the LC_CTYPE, LANG or LC_ALL enviroment variables (LC_CTYPE only affects character handling).
-.SH "SE ALSO"
+.SH "SEE ALSO"
mpc(1), mpd(1), locale(5), locale(7)
diff --git a/src/conf.c b/src/conf.c
index 3af986b95fe89df1c99a72021c2b2b03b2352ddb..df0ac546564e055f8b5ef5ca231f8111f0717415 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_PASSWORD "password"
#define CONF_LYRICS_TIMEOUT "lyrics-timeout"
#define CONF_SHOW_SPLASH "show-splash"
+#define CONF_SCROLL "scroll"
+#define CONF_SCROLL_SEP "scroll-sep"
typedef enum {
KEY_PARSER_UNKNOWN,
{
options->lyrics_timeout = atoi(get_format(value));
}
+ else if( !strcasecmp(CONF_SCROLL, name))
+ {
+ options->scroll = str2bool(value);
+ }
+ else if( !strcasecmp(CONF_SCROLL_SEP, name))
+ {
+ g_free(options->scroll_sep);
+ options->scroll_sep = get_format(value);
+ }
else
{
match_found = 0;
diff --git a/src/main.c b/src/main.c
index 7849f8c1305d6ec98832c1defc5e075c2a283d55..5e978409ff9c73cc3ba59afadf9f13ed69596884 100644 (file)
--- a/src/main.c
+++ b/src/main.c
g_free(options.password);
g_free(options.list_format);
g_free(options.status_format);
+ g_free(options.scroll_sep);
if( timer )
g_timer_destroy(timer);
}
diff --git a/src/mpdclient.c b/src/mpdclient.c
index b13146f385baaf30191ecd39e0d382d4ee544d50..98743a35d818a76c03cd4ebd9633bb28744ee743 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#include "support.h"
#include "mpdclient.h"
#include "options.h"
+#include "strfsong.h"
#undef ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_ADD /* broken with song id's */
#define ENABLE_FANCY_PLAYLIST_MANAGMENT_CMD_DELETE
#define ENABLE_SONG_ID
#define ENABLE_PLCHANGES
+#define BUFSIZE 1024
+
#define MPD_ERROR(c) (c==NULL || c->connection==NULL || c->connection->error)
/* from utils.c */
return n;
}
+/* sort by list-format */
+gint
+compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2)
+{
+ mpd_InfoEntity *e1, *e2;
+ char key1[BUFSIZE], key2[BUFSIZE];
+ int n = 0;
+
+ e1 = ((filelist_entry_t *)filelist_entry1)->entity;
+ e2 = ((filelist_entry_t *)filelist_entry2)->entity;
+ if (e1 && e2 &&
+ e1->type == MPD_INFO_ENTITY_TYPE_SONG &&
+ e2->type == MPD_INFO_ENTITY_TYPE_SONG)
+ {
+ strfsong(key1, BUFSIZE, LIST_FORMAT, e1->info.song);
+ strfsong(key2, BUFSIZE, LIST_FORMAT, e2->info.song);
+ n = strcmp(key1,key2);
+ }
+ return n;
+}
+
/* Error callbacks */
static gint
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 3837b1e7b7659e15846f43fcfb4248e28b4c377c..44c266afc51472b85628264e4796575de2dff529 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
/* issue a playlist callback */
void mpdclient_browse_callback(mpdclient_t *c, int event, gpointer data);
+/* sort by list-format */
+gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);
#endif
diff --git a/src/ncmpc.h b/src/ncmpc.h
index 7bc99a1d68ca07add65f08bb92506ca408e9f9e9..7d000958d358dd12cd8522a99acd5ac46074438a 100644 (file)
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
#define DEFAULT_LYRICS_TIMEOUT 100
+#define DEFAULT_SCROLL TRUE
+#define DEFAULT_SCROLL_SEP " *** "
+
#endif /* NCMPC_H */
diff --git a/src/options.c b/src/options.c
index f9bfcdd696cdf7b4b0f3ec82d7501b059bc092f1..fbf079af7198748ee1db8ff5dd25755ad31068fd 100644 (file)
--- a/src/options.c
+++ b/src/options.c
options.timedisplay_type = DEFAULT_TIMEDISPLAY_TYPE;
options.lyrics_timeout = DEFAULT_LYRICS_TIMEOUT;
options.show_splash = FALSE;
+ options.scroll = DEFAULT_SCROLL;
+ options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
return &options;
}
diff --git a/src/options.h b/src/options.h
index d858b709e0a4239a1ecccb8ccbd92f6576392108..5547ff8dd184087139b4f64f6fede52ef5286d2a 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *list_format;
char *status_format;
char *xterm_title_format;
+ char *scroll_sep;
char **screen_list;
char *timedisplay_type;
int port;
gboolean enable_xterm_title;
gboolean enable_mouse;
gboolean show_splash;
+ gboolean scroll;
} options_t;
diff --git a/src/screen.c b/src/screen.c
index 13e1975c1dc25a50431f1e09bb6bfb5b9d0a6ef0..93d305d78b448a473efac4e20daa2976c68920a6 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
if( IS_PLAYING(status->state) || IS_PAUSED(status->state) )
{
if( status->totalTime > 0 )
- {
-
- /*checks the conf to see whether to display elapsed or remaining time */
- if(!strcmp(options.timedisplay_type,"elapsed"))
- {
- timestr= " [%i:%02i/%i:%02i]";
- elapsedTime = c->status->elapsedTime;
- }
- else if(!strcmp(options.timedisplay_type,"remaining"))
- {
- timestr= " [-%i:%02i/%i:%02i]";
- elapsedTime = (c->status->totalTime - c->status->elapsedTime);
- }
- if( c->song && seek_id == c->song->id )
- elapsedTime = seek_target_time;
- /*write out the time*/
- g_snprintf(screen->buf, screen->buf_size,
- timestr,
- elapsedTime/60, elapsedTime%60,
- status->totalTime/60, status->totalTime%60 );
+ {
+ /*checks the conf to see whether to display elapsed or remaining time */
+ if(!strcmp(options.timedisplay_type,"elapsed"))
+ elapsedTime = c->status->elapsedTime;
+ else if(!strcmp(options.timedisplay_type,"remaining"))
+ elapsedTime = (c->status->totalTime - c->status->elapsedTime);
+
+ if( c->song && seek_id == c->song->id )
+ elapsedTime = seek_target_time;
+ /*write out the time, using hours if time over 60 minutes*/
+ if (c->status->totalTime > 3600)
+ {
+ g_snprintf(screen->buf, screen->buf_size,
+ " [%i:%02i:%02i/%i:%02i:%02i]",
+ elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60,
+ status->totalTime/3600, (status->totalTime%3600)/60, status->totalTime%60);
+ }
+ else
+ {
+ g_snprintf(screen->buf, screen->buf_size,
+ " [%i:%02i/%i:%02i]",
+ elapsedTime/60, elapsedTime%60,
+ status->totalTime/60, status->totalTime%60 );
+ }
}
else
{
colors_use(w, COLOR_STATUS);
/* scroll if the song name is to long */
- if( my_strlen(songname) > width )
+ if( options.scroll && my_strlen(songname) > width )
{
static scroll_state_t st = { 0, 0 };
- char *tmp = strscroll(songname, " *** ", width, &st);
+ char *tmp = strscroll(songname, options.scroll_sep, width, &st);
g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH);
g_free(tmp);
diff --git a/src/screen_help.c b/src/screen_help.c
index 6825e567b3f9ceee85a02eb77e6717f949874cb0..8be8463f3f3bf18f574874bcedcbe5514b548848 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
lw->repaint=1;
+ lw->clear=1;
switch(cmd)
{
case CMD_LIST_NEXT:
diff --git a/src/screen_search.c b/src/screen_search.c
index 7fb559fabc7eeaac01e33905630f51b7b41924f6..4dfc6d0add1551056975eb23d60d45edabc4bb9d 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
#define SEARCH_ALBUM 2
#define SEARCH_FILE 3
+#define SEARCH_ARTIST_TITLE 999
+
typedef struct {
int table;
char *label;
} search_type_t;
static search_type_t mode[] = {
- { MPD_TABLE_TITLE, N_("Title") },
- { MPD_TABLE_ARTIST, N_("Artist") },
- { MPD_TABLE_ALBUM, N_("Album") },
- { MPD_TABLE_FILENAME, N_("Filename") },
+ { MPD_TABLE_TITLE, N_("Title") },
+ { MPD_TABLE_ARTIST, N_("Artist") },
+ { MPD_TABLE_ALBUM, N_("Album") },
+ { MPD_TABLE_FILENAME, N_("Filename") },
+ { SEARCH_ARTIST_TITLE, N_("Artist + Title") },
{ 0, NULL }
};
}
#ifdef FUTURE
+mpdclient_filelist_t *
+filelist_search(mpdclient_t *c, int exact_match, int table, gchar *pattern)
+{
+ mpdclient_filelist_t *list, *list2;
+
+ if( table == SEARCH_ARTIST_TITLE )
+ {
+ list = mpdclient_filelist_search(c, FALSE, MPD_TABLE_ARTIST, pattern);
+ list2 = mpdclient_filelist_search(c, FALSE, MPD_TABLE_TITLE, pattern);
+
+ list->length += list2->length;
+ list->list = g_list_concat(list->list, list2->list);
+ list->list = g_list_sort(list->list, compare_filelistentry_format);
+ list->updated = TRUE;
+ }
+ else
+ {
+ list = mpdclient_filelist_search(c, FALSE, table, pattern);
+ }
+
+ return list;
+}
+
/*-----------------------------------------------------------------------
* NOTE: This code exists to test a new search ui,
* Its ugly and MUST be redesigned before the next release!
if( !MPD_VERSION_LT(c, 0, 12, 0) )
filelist = search_advanced_query(pattern, c);
if( !advanced_search_mode && filelist==NULL )
- filelist = mpdclient_filelist_search(c,
- FALSE,
- mode[options.search_mode].table,
- pattern);
+ filelist = filelist_search(c,
+ FALSE,
+ mode[options.search_mode].table,
+ pattern);
sync_highlights(c, filelist);
mpdclient_install_playlist_callback(c, playlist_changed_callback);
list_window_check_selected(lw, filelist->length);
/* continue and select next item... */
cmd = CMD_LIST_NEXT;
}
- return 1;
+ /* call list_window_cmd to go to the next item */
+ return list_window_cmd(lw, filelist->length, cmd);
case CMD_SEARCH_MODE:
options.search_mode++;
if( pattern )
{
search_clear(screen, c, FALSE);
- filelist = mpdclient_filelist_search(c,
- FALSE,
- mode[options.search_mode].table,
- pattern);
+ filelist = filelist_search(c,
+ FALSE,
+ mode[options.search_mode].table,
+ pattern);
sync_highlights(c, filelist);
}
return 1;
diff --git a/src/strfsong.c b/src/strfsong.c
index 287fcbdce63b68105a3357450ad5dbee2407f3a6..df622a2bba75bbaf9cefef6df21fdeea7d392eb9 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
else if (strncmp("%time%", p, n) == 0)
{
if (song->time != MPD_SONG_NO_TIME)
- temp = g_strdup_printf("%d:%02d",
- song->time / 60,
- song->time % 60 + 1);
+ {
+ if (song->time > 3600)
+ {
+ temp = g_strdup_printf("%d:%02d:%02d",
+ song->time / 3600,
+ (song->time % 3600) / 60,
+ song->time % 60);
+ }
+ else
+ {
+ temp = g_strdup_printf("%d:%02d",
+ song->time / 60,
+ song->time % 60);
+ }
+ }
}
if( temp == NULL)