aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/conf.c75
-rw-r--r--src/ncmpc.h11
-rw-r--r--src/options.c10
-rw-r--r--src/options.h3
4 files changed, 83 insertions, 16 deletions
diff --git a/src/conf.c b/src/conf.c
index 0d6d96834..a40c90ad7 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -38,20 +38,26 @@
#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"
@@ -299,6 +305,19 @@ parse_color_definition(char *str)
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)
@@ -404,52 +423,70 @@ 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) )
@@ -461,6 +498,20 @@ read_rc_file(char *filename, options_t *options)
{
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 6bbb745fb..64160531f 100644
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
@@ -23,6 +23,9 @@
#define N_(x) x
#endif
+#define YES _("y")
+#define NO _("n")
+
/* welcome message time [s] */
#define SCREEN_WELCOME_TIME 10
@@ -33,12 +36,14 @@
#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 416727ad3..952f436d5 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1,5 +1,7 @@
/*
- * (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
@@ -25,6 +27,7 @@
#include <popt.h>
#include "config.h"
+#include "ncmpc.h"
#include "options.h"
#include "command.h"
#include "support.h"
@@ -170,9 +173,14 @@ options_init( void )
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 2a6681e2a..4ca1a4561 100644
--- a/src/options.h
+++ b/src/options.h
@@ -9,6 +9,8 @@ typedef struct
char *password;
char *config_file;
char *key_file;
+ char *list_format;
+ char *status_format;
int port;
int reconnect;
int debug;
@@ -16,6 +18,7 @@ typedef struct
int auto_center;
int wide_cursor;
int enable_colors;
+ int enable_beep;
} options_t;