From: Andreas Obergrusberger Date: Fri, 16 Feb 2007 15:42:08 +0000 (+0000) Subject: way too much stuff to describe here X-Git-Tag: v0.12_alpha1~344 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ebdf8ae4bf442b994ba5dedf3efe22ffe8fc9aec;p=ncmpc.git way too much stuff to describe here git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@5346 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/ChangeLog b/ChangeLog index fc0fbb7..715a4ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2007-02-01 Andreas Obergrusberger +2007-02-16 Andreas Obergrusberger + + 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 * fixed a bad bug in leoslyrics that made every second line an empty line * uploaded some updates for the lyrics system @@ -76,7 +82,7 @@ 2006-08-4 Anderas Obergrusberger * 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 diff --git a/TODO b/TODO index cdcdd2f..7a34370 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ - * Make status line scrolling optional - * Scroll long list entries, move left/right (#242) * Search screen (with a simple ui) @@ -13,5 +11,5 @@ * 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 3c80c2f..c3c532c 100644 --- a/doc/config.sample +++ b/doc/config.sample @@ -52,6 +52,12 @@ ## 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 11c3a55..afcd78b 100644 --- a/doc/ncmpc.1 +++ b/doc/ncmpc.1 @@ -93,6 +93,12 @@ Visible bell on alerts. .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 @@ -189,5 +195,5 @@ Report bugs on http://www.musicpd.org/mantis/ 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 3af986b..df0ac54 100644 --- a/src/conf.c +++ b/src/conf.c @@ -70,6 +70,8 @@ #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, @@ -584,6 +586,15 @@ read_rc_file(char *filename, options_t *options) { 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 7849f8c..5e97840 100644 --- a/src/main.c +++ b/src/main.c @@ -125,6 +125,7 @@ exit_and_cleanup(void) 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 b13146f..98743a3 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -30,6 +30,7 @@ #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 @@ -37,6 +38,8 @@ #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 */ @@ -66,6 +69,27 @@ compare_filelistentry_dir(gconstpointer filelist_entry1, gconstpointer filelist_ 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 3837b1e..44c266a 100644 --- a/src/mpdclient.h +++ b/src/mpdclient.h @@ -203,5 +203,7 @@ void mpdclient_remove_browse_callback(mpdclient_t *c, mpdc_list_cb_t cb); /* 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 7bc99a1..7d00095 100644 --- a/src/ncmpc.h +++ b/src/ncmpc.h @@ -79,4 +79,7 @@ void D(char *format, ...); #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 f9bfcdd..fbf079a 100644 --- a/src/options.c +++ b/src/options.c @@ -375,6 +375,8 @@ options_init( void ) 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 d858b70..5547ff8 100644 --- a/src/options.h +++ b/src/options.h @@ -12,6 +12,7 @@ typedef struct char *list_format; char *status_format; char *xterm_title_format; + char *scroll_sep; char **screen_list; char *timedisplay_type; int port; @@ -33,6 +34,7 @@ typedef struct 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 13e1975..93d305d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -356,26 +356,30 @@ paint_status_window(mpdclient_t *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 { @@ -404,10 +408,10 @@ paint_status_window(mpdclient_t *c) 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 6825e56..8be8463 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -246,6 +246,7 @@ static int 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 7fb559f..4dfc6d0 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -91,16 +91,19 @@ search_get_tag_id(char *name) #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 } }; @@ -186,6 +189,29 @@ search_clear(screen_t *screen, mpdclient_t *c, gboolean clear_pattern) } #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! @@ -335,10 +361,10 @@ search_new(screen_t *screen, mpdclient_t *c) 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); @@ -462,7 +488,8 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) /* 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++; @@ -475,10 +502,10 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) 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 287fcbd..df622a2 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -204,9 +204,21 @@ _strfsong(gchar *s, 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)