summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 369b13a)
raw | patch | inline | side by side (parent: 369b13a)
author | Simon Arlott <sa.me.uk> | |
Mon, 19 May 2014 23:52:28 +0000 (00:52 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 28 May 2014 16:13:40 +0000 (18:13 +0200) |
This configures the song format for the search window,
and defaults to the value of list-format if not specified.
and defaults to the value of list-format if not specified.
20 files changed:
NEWS | patch | blob | history | |
doc/config.sample | patch | blob | history | |
doc/ncmpc.1 | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/list_window.h | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen_artist.c | patch | blob | history | |
src/screen_browser.c | patch | blob | history | |
src/screen_browser.h | patch | blob | history | |
src/screen_file.c | patch | blob | history | |
src/screen_help.c | patch | blob | history | |
src/screen_outputs.c | patch | blob | history | |
src/screen_queue.c | patch | blob | history | |
src/screen_search.c | patch | blob | history | |
src/song_paint.c | patch | blob | history | |
src/song_paint.h | patch | blob | history |
index a9b594449689ade614296504c43ff760482f6c0b..d6ebaba8b66f20532de703dfe7ce8b85ecc540f3 100644 (file)
--- a/NEWS
+++ b/NEWS
* remove useless "Connected to ..." message
* require libmpdclient 2.3, MPD 0.16
* patched color line-flags
+* configuration option "search-format"
ncmpc 0.21 - (2013-04-11)
diff --git a/doc/config.sample b/doc/config.sample
index 986452f2df5580e5089166a266bf3c3302cebf99..1b40092e01e4461fcad9b219c81c8430ff08f0bc 100644 (file)
--- a/doc/config.sample
+++ b/doc/config.sample
## The format used to display songs in the main window.
#list-format = "%name%|[%artist% - ]%title%|%file%"
+## The format used to display songs in the search window.
+#search-format = "%name%|[%artist% - ]%title%|%file%"
+
## The format used to display songs on the status line.
#status-format = "[%artist% - ]%title%|%shortfile%"
diff --git a/doc/ncmpc.1 b/doc/ncmpc.1
index b7fd7ce9be4d46805e013a1853396dc7dcab2d6c..69e591945f23b03c9ecb698781eeb9d5df3b9e0a 100644 (file)
--- a/doc/ncmpc.1
+++ b/doc/ncmpc.1
.B list\-format = SONG FORMAT
The format used to display songs in the main window.
.TP
+.B search\-format = SONG FORMAT
+The format used to display songs in the search window. Default is to use list\-format.
+.TP
.B status\-format = SONG FORMAT
The format used to display songs on the status line.
.TP
diff --git a/src/conf.c b/src/conf.c
index 83c11c5f194b6359ffdd16a202355b64e98914e8..5d8ec5e8bcbd9937ee64067948c08be6de20c65c 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_COLOR "color"
#define CONF_COLOR_DEFINITION "colordef"
#define CONF_LIST_FORMAT "list-format"
+#define CONF_SEARCH_FORMAT "search-format"
#define CONF_STATUS_FORMAT "status-format"
#define CONF_XTERM_TITLE_FORMAT "xterm-title-format"
#define CONF_LIST_WRAP "wrap-around"
else if (!strcasecmp(CONF_LIST_FORMAT, name)) {
g_free(options.list_format);
options.list_format = get_format(value);
+ /* search format string */
+ } else if (!strcasecmp(CONF_SEARCH_FORMAT, name)) {
+ g_free(options.search_format);
+ options.search_format = get_format(value);
/* status format string */
} else if (!strcasecmp(CONF_STATUS_FORMAT, name)) {
g_free(options.status_format);
diff --git a/src/list_window.c b/src/list_window.c
index 387b7766b4f2d1fdfa3ad6855b049a5cd3ae6a06..c2a4b012f51a76d12ae18fdec3a095b221bfbc8b 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
void
list_window_paint2(const struct list_window *lw,
list_window_paint_callback_t paint_callback,
- void *callback_data)
+ const void *callback_data)
{
bool show_cursor = !lw->hide_cursor &&
(!options.hardware_cursor || lw->range_selection);
diff --git a/src/list_window.h b/src/list_window.h
index 495657b3cb93f9fcd4972bcae61e6dff83021116..2e1f76956ff1f24dfcebd0b7a94578248f806f9d 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
(*list_window_paint_callback_t)(WINDOW *w, unsigned i,
unsigned y, unsigned width,
bool selected,
- void *data);
+ const void *data);
struct list_window {
WINDOW *w;
void
list_window_paint2(const struct list_window *lw,
list_window_paint_callback_t paint_callback,
- void *callback_data);
+ const void *callback_data);
/* perform basic list window commands (movement) */
bool
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 9baf70bc7134fa8d2125f4ff463660052eb3ff82..1e01486a27c8c65bffcfaead13f95a08612a7eaa 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#define BUFSIZE 1024
-/* sort by list-format */
+/* sort by song format */
gint
compare_filelistentry_format(gconstpointer filelist_entry1,
- gconstpointer filelist_entry2)
+ gconstpointer filelist_entry2,
+ const char *song_format)
{
const struct mpd_entity *e1 =
((const struct filelist_entry *)filelist_entry1)->entity;
mpd_entity_get_type(e1) == MPD_ENTITY_TYPE_SONG &&
mpd_entity_get_type(e2) == MPD_ENTITY_TYPE_SONG) {
char key1[BUFSIZE], key2[BUFSIZE];
- strfsong(key1, BUFSIZE, options.list_format, mpd_entity_get_song(e1));
- strfsong(key2, BUFSIZE, options.list_format, mpd_entity_get_song(e2));
+ strfsong(key1, BUFSIZE, song_format, mpd_entity_get_song(e1));
+ strfsong(key2, BUFSIZE, song_format, mpd_entity_get_song(e2));
n = strcmp(key1,key2);
}
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 8dab0936856b06d448e9d363558c01b9e91f5ef1..01294dbb48a1b8b3887a4e95a48f3506b46deaf0 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
bool
mpdclient_filelist_add_all(struct mpdclient *c, struct filelist *fl);
-/* sort by list-format */
+/* sort by song format */
gcc_pure
-gint compare_filelistentry_format(gconstpointer filelist_entry1, gconstpointer filelist_entry2);
+gint compare_filelistentry_format(gconstpointer filelist_entry1,
+ gconstpointer filelist_entry2,
+ const char *song_format);
#endif
diff --git a/src/options.c b/src/options.c
index 0a453e23a51ea403885a878782208ddac6b70506..370215ef7cb0f8dd9bbc83c97a08c2b706768467 100644 (file)
--- a/src/options.c
+++ b/src/options.c
{
/* default option values */
options.list_format = g_strdup(DEFAULT_LIST_FORMAT);
+ options.search_format = NULL;
options.status_format = g_strdup(DEFAULT_STATUS_FORMAT);
options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
#ifndef NCMPC_MINI
g_free(options.config_file);
g_free(options.key_file);
g_free(options.list_format);
+ g_free(options.search_format);
g_free(options.status_format);
g_strfreev(options.screen_list);
#ifndef NCMPC_MINI
diff --git a/src/options.h b/src/options.h
index 74dfd4284657a31d3066742ea040c69b6b17d823..8b42b6d42f9eee306c97b848c207dead4bb7fd74 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *config_file;
char *key_file;
char *list_format;
+ char *search_format;
char *status_format;
#ifndef NCMPC_MINI
char *xterm_title_format;
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 077fca52bd61ccf442e88d1cafba8229feb347ad..3ffc931137719459e8c9f4fe75031ce18993f5ff 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
#include "mpdclient.h"
#include "screen_browser.h"
#include "filelist.h"
+#include "options.h"
#include <assert.h>
#include <string.h>
screen_artist_init(WINDOW *w, int cols, int rows)
{
browser.lw = list_window_init(w, cols, rows);
+ browser.song_format = options.list_format;
artist = NULL;
album = NULL;
}
static void
paint_artist_callback(WINDOW *w, unsigned i,
gcc_unused unsigned y, unsigned width,
- bool selected, void *data)
+ bool selected, const void *data)
{
- GPtrArray *list = data;
+ const GPtrArray *list = data;
char *p = utf8_to_locale(g_ptr_array_index(list, i));
screen_browser_paint_directory(w, width, selected, p);
static void
paint_album_callback(WINDOW *w, unsigned i,
gcc_unused unsigned y, unsigned width,
- bool selected, void *data)
+ bool selected, const void *data)
{
- GPtrArray *list = data;
+ const GPtrArray *list = data;
const char *p;
char *q = NULL;
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 0835241ed2c9f46852c257620f70d1baa51bd14d..ff209db2bfb46146dca776b051235053a2349304 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
static void
screen_browser_paint_callback(WINDOW *w, unsigned i, unsigned y,
- unsigned width, bool selected, void *data);
+ unsigned width, bool selected, const void *data);
bool
browser_cmd(struct screen_browser *browser,
static void
screen_browser_paint_callback(WINDOW *w, unsigned i,
unsigned y, unsigned width,
- bool selected, void *data)
+ bool selected, const void *data)
{
- const struct filelist *fl = (const struct filelist *) data;
+ const struct screen_browser *browser = (const struct screen_browser *) data;
- assert(fl != NULL);
- assert(i < filelist_length(fl));
+ assert(browser != NULL);
+ assert(browser->filelist != NULL);
+ assert(i < filelist_length(browser->filelist));
- const struct filelist_entry *entry = filelist_get(fl, i);
+ const struct filelist_entry *entry = filelist_get(browser->filelist, i);
assert(entry != NULL);
const struct mpd_entity *entity = entry->entity;
case MPD_ENTITY_TYPE_SONG:
paint_song_row(w, y, width, selected, highlight,
- mpd_entity_get_song(entity), NULL);
+ mpd_entity_get_song(entity), NULL, browser->song_format);
break;
case MPD_ENTITY_TYPE_PLAYLIST:
screen_browser_paint(const struct screen_browser *browser)
{
list_window_paint2(browser->lw, screen_browser_paint_callback,
- browser->filelist);
+ browser);
}
diff --git a/src/screen_browser.h b/src/screen_browser.h
index ad840dd1bad7cfbf74593ed485523f177a1bde9a..8346084f3148d7a660e77643d1c2b3c51075d3c4 100644 (file)
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
struct list_window *lw;
struct filelist *filelist;
+ const char *song_format;
};
#ifndef NCMPC_MINI
diff --git a/src/screen_file.c b/src/screen_file.c
index 175e7866ab2ea1e0285d62c762a7e58a81c504dd..124108bb770a55f482764ba59d860f302b7063f5 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
#include "filelist.h"
#include "screen_utils.h"
#include "screen_client.h"
+#include "options.h"
#include <mpd/client.h>
current_path = g_strdup("");
browser.lw = list_window_init(w, cols, rows);
+ browser.song_format = options.list_format;
}
static void
diff --git a/src/screen_help.c b/src/screen_help.c
index da2d3e9773465ecc820429a5056cac5fc73b9951..d2d96d1ffbaae92369fed69babe4ff4f2a08f870 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
screen_help_paint_callback(WINDOW *w, unsigned i,
unsigned y, unsigned width,
gcc_unused bool selected,
- gcc_unused void *data)
+ gcc_unused const void *data)
{
const struct help_text_row *row = &help_text[i];
diff --git a/src/screen_outputs.c b/src/screen_outputs.c
index e80d7bae50962af4320fcc6dc8182b4fdd342933..2aa60e1ab44c4fddabf2bb3d13dd0cc67f94e843 100644 (file)
--- a/src/screen_outputs.c
+++ b/src/screen_outputs.c
static void
screen_outputs_paint_callback(WINDOW *w, unsigned i,
gcc_unused unsigned y, unsigned width,
- bool selected, gcc_unused void *data)
+ bool selected, gcc_unused const void *data)
{
const struct mpd_output *output;
diff --git a/src/screen_queue.c b/src/screen_queue.c
index 0d08bbcb63ce67f3eb8a5dec83681fbc1b74a77a..7fd73aa7080c2e1531507b0debe3a2d86217d11e 100644 (file)
--- a/src/screen_queue.c
+++ b/src/screen_queue.c
static void
screen_queue_paint_callback(WINDOW *w, unsigned i,
unsigned y, unsigned width,
- bool selected, gcc_unused void *data)
+ bool selected, gcc_unused const void *data)
{
assert(playlist != NULL);
assert(i < playlist_length(playlist));
paint_song_row(w, y, width, selected,
(int)mpd_song_get_id(song) == current_song_id,
- song, row_hscroll);
+ song, row_hscroll, options.list_format);
}
static void
diff --git a/src/screen_search.c b/src/screen_search.c
index 0d39ddb151e76c6b7b7a32fd8b520d8bef778ac7..deab64ab05ba96bc5ea35e181834724f646fd2a9 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
screen_search_init(WINDOW *w, int cols, int rows)
{
browser.lw = list_window_init(w, cols, rows);
+ if (options.search_format != NULL) {
+ browser.song_format = options.search_format;
+ } else {
+ browser.song_format = options.list_format;
+ }
list_window_set_length(browser.lw, G_N_ELEMENTS(help_text));
}
diff --git a/src/song_paint.c b/src/song_paint.c
index f3f3918c02a7909e1f584ae5a40e77a6599486aa..c3ae757bda89a7bad7ac57e457cd5e274cd0b43b 100644 (file)
--- a/src/song_paint.c
+++ b/src/song_paint.c
void
paint_song_row(WINDOW *w, gcc_unused unsigned y, unsigned width,
bool selected, bool highlight, const struct mpd_song *song,
- gcc_unused struct hscroll *hscroll)
+ gcc_unused struct hscroll *hscroll, const char *format)
{
char buffer[width * 4];
- strfsong(buffer, sizeof(buffer), options.list_format, song);
+ strfsong(buffer, sizeof(buffer), format, song);
row_paint_text(w, width, highlight ? COLOR_LIST_BOLD : COLOR_LIST,
selected, buffer);
diff --git a/src/song_paint.h b/src/song_paint.h
index 808109517530240f32a8d5c512dd3429a5e95a19..41080a1c3f9298e1dbe8dddd3a380211de85ecef 100644 (file)
--- a/src/song_paint.h
+++ b/src/song_paint.h
* @param highlight true if the row is highlighted
* @param song the song object
* @param hscroll an optional hscroll object
+ * @param format the song format
*/
void
paint_song_row(WINDOW *w, unsigned y, unsigned width,
bool selected, bool highlight, const struct mpd_song *song,
- struct hscroll *hscroll);
+ struct hscroll *hscroll, const char *format);
#endif