summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4800010)
raw | patch | inline | side by side (parent: 4800010)
author | Kalle Wallin <kaw@linux.se> | |
Tue, 15 Jun 2004 13:10:54 +0000 (13:10 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Tue, 15 Jun 2004 13:10:54 +0000 (13:10 +0000) |
doc/config.sample | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/ncmpc.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history |
diff --git a/doc/config.sample b/doc/config.sample
index f8d2ad4d3a62b68a4d404d60ff35f169b0fcc7c9..ecbc8cc41b2d415a01c7ab330e43b4cf338086f4 100644 (file)
--- a/doc/config.sample
+++ b/doc/config.sample
##
## auto center (center the playing track in the playlist)
-#auto_center = no
+#auto-center = no
## wide_cursor - make the cursor as wide as the screen
-#wide_cursor = yes
+#wide-cursor = yes
+
+## list-format
+#list-format = "%name%|[%artist% - ]%title%|%file%"
+
+## status-format
+#status-format = "[%artist% - ]%title%|%basename%"
+
##
## Color configuration
##
## enable/disable colors
-#enable_colors = no
+#enable-colors = no
## background colors: black,red,green,yellow,blue,magenta,cyan,white, none
#color background = black
diff --git a/src/conf.c b/src/conf.c
index 0d6d96834d517743783798a1ce87e653b8eca560..a40c90ad7a4354b5a4ad46dc4d4d4e1a45a804ee 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#include "colors.h"
#include "conf.h"
-#define ENABLE_OLD_COLOR_SYNTAX
+#define ENABLE_OLD_SYNTAX
#define MAX_LINE_LENGTH 1024
#define COMMENT_TOKEN '#'
/* configuration field names */
-#define CONF_ENABLE_COLORS "enable_colors"
-#define CONF_AUTO_CENTER "auto_center"
-#define CONF_WIDE_CURSOR "wide_cursor"
+#define CONF_ENABLE_COLORS "enable-colors"
+#define CONF_AUTO_CENTER "auto-center"
+#define CONF_WIDE_CURSOR "wide-cursor"
+#define CONF_ENABLE_BELL "enable-bell"
#define CONF_KEY_DEFINITION "key"
#define CONF_COLOR "color"
#define CONF_COLOR_DEFINITION "colordef"
+#define CONF_LIST_FORMAT "list-format"
+#define CONF_STATUS_FORMAT "status-format"
/* Deprecated - configuration field names */
+#define OLD_CONF_ENABLE_COLORS "enable_colors"
+#define OLD_CONF_AUTO_CENTER "auto_center"
+#define OLD_CONF_WIDE_CURSOR "wide_cursor"
#define CONF_COLOR_BACKGROUND "background_color"
#define CONF_COLOR_TITLE "title_color"
#define CONF_COLOR_LINE "line_color"
return value;
}
+static char *
+get_format(char *str)
+{
+ gsize len = strlen(str);
+
+ if( str && str[0]=='\"' && str[len-1] == '\"' )
+ {
+ str[len-1] = '\0';
+ str++;
+ }
+ return g_strdup(str);
+}
+
static int
read_rc_file(char *filename, options_t *options)
{
parse_color(value);
}
-#ifdef ENABLE_OLD_COLOR_SYNTAX
+#ifdef ENABLE_OLD_SYNTAX
/* background color */
else if( !strcasecmp(CONF_COLOR_BACKGROUND, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("background", value);
}
/* color - top (title) window */
else if( !strcasecmp(CONF_COLOR_TITLE, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("title", value);
colors_assign("title2", value);
}
/* color - line (title) window */
else if( !strcasecmp(CONF_COLOR_LINE, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("line", value);
colors_assign("line2", value);
}
/* color - list window */
else if( !strcasecmp(CONF_COLOR_LIST, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("list", value);
}
/* color - progress bar */
else if( !strcasecmp(CONF_COLOR_PROGRESS, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("progressbar", value);
}
/* color - status window */
else if( !strcasecmp(CONF_COLOR_STATUS, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("status", value);
colors_assign("status2", value);
}
/* color - alerts */
else if( !strcasecmp(CONF_COLOR_ALERT, name) )
{
- fprintf(stderr,"%s: %s - deprecated!\n", filename,name);
+ fprintf(stderr,"%s: %s deprecated!\n", filename,name);
colors_assign("alert", value);
}
+ /* enable colors */
+ else if( !strcasecmp(OLD_CONF_ENABLE_COLORS, name) )
+ {
+ fprintf(stderr,"%s: %s deprecated - use %s!\n", filename, name, CONF_ENABLE_COLORS);
+ options->enable_colors = str2bool(value);
+ }
+ /* auto center */
+ else if( !strcasecmp(OLD_CONF_AUTO_CENTER, name) )
+ {
+ fprintf(stderr,"%s: %s deprecated - use %s!\n", filename, name, CONF_AUTO_CENTER);
+ options->auto_center = str2bool(value);
+ }
+ /* wide cursor */
+ else if( !strcasecmp(OLD_CONF_WIDE_CURSOR, name) )
+ {
+ fprintf(stderr,"%s: %s deprecated - use %s!\n", filename, name, CONF_WIDE_CURSOR);
+ options->wide_cursor = str2bool(value);
+ }
#endif
/* wide cursor */
else if( !strcasecmp(CONF_WIDE_CURSOR, name) )
{
parse_color_definition(value);
}
+ /* list format string */
+ else if( !strcasecmp(CONF_LIST_FORMAT, name) )
+ {
+ g_free(options->list_format);
+ options->list_format = get_format(value);
+ fprintf(stderr, "list-format = \'%s\'\n", options->list_format);
+ }
+ /* status format string */
+ else if( !strcasecmp(CONF_STATUS_FORMAT, name) )
+ {
+ g_free(options->status_format);
+ options->status_format = get_format(value);
+ fprintf(stderr, "status-format = \'%s\'\n", options->status_format);
+ }
else
{
match_found = 0;
diff --git a/src/ncmpc.h b/src/ncmpc.h
index 6bbb745fbbcee19bb081d67a8c3a6dca464b3b20..64160531f2f310aa9f75c7448162d52476ea2ca9 100644 (file)
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
#define N_(x) x
#endif
+#define YES _("y")
+#define NO _("n")
+
/* welcome message time [s] */
#define SCREEN_WELCOME_TIME 10
#define MPD_UPDATE_TIME 0.5
/* time in milliseconds before trying to reconnect (int) */
-#define MPD_RECONNECT_TIME 1000
+#define MPD_RECONNECT_TIME 1500
/* song format - list window */
-#define LIST_FORMAT "%name%|[%artist% - ]%title%|%file%"
+#define DEFAULT_LIST_FORMAT "%name%|[%artist% - ]%title%|%file%"
+#define LIST_FORMAT (options.list_format ? options.list_format : DEFAULT_LIST_FORMAT)
/* song format - status window */
-#define STATUS_FORMAT "[%artist% - ]%title%|%basename%"
+#define DEFAULT_STATUS_FORMAT "[%artist% - ]%title%|%basename%"
+#define STATUS_FORMAT (options.status_format ? options.status_format : DEFAULT_STATUS_FORMAT)
#endif /* NCMPC_H */
diff --git a/src/options.c b/src/options.c
index 416727ad3e8b51bfd23621cddcc7ef1545a66078..952f436d541c07d5d5a6befd39207ae3cba9ae89 100644 (file)
--- a/src/options.c
+++ b/src/options.c
/*
- * (c) 2004 by Kalle Wallin (kaw@linux.se)
+ * $Id$
+ *
+ * (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <popt.h>
#include "config.h"
+#include "ncmpc.h"
#include "options.h"
#include "command.h"
#include "support.h"
else
options.port = DEFAULT_PORT;
+ options.list_format = NULL;
+ options.status_format = NULL;
+
options.reconnect = 1;
options.find_wrap = 1;
options.wide_cursor = 1;
+ options.enable_beep = 1;
+
return &options;
}
diff --git a/src/options.h b/src/options.h
index 2a6681e2a3ac9f437e71caed7f842285845ac0ee..4ca1a4561bbb37b06575bc38f63bf6b9df4ba492 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *password;
char *config_file;
char *key_file;
+ char *list_format;
+ char *status_format;
int port;
int reconnect;
int debug;
int auto_center;
int wide_cursor;
int enable_colors;
+ int enable_beep;
} options_t;