aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-03 12:57:30 +0200
committerMax Kellermann <max@duempel.org>2008-10-03 12:57:30 +0200
commitf81333daa0bb652a5c1296941057eef82a12e12f (patch)
treeb616f9bfc73941e0c570cbebab9949ae5b483621 /src
parent547b0c5f28be1e830c00ac167806ffba641855c6 (diff)
downloadmpd-f81333daa0bb652a5c1296941057eef82a12e12f.tar.gz
mpd-f81333daa0bb652a5c1296941057eef82a12e12f.tar.xz
mpd-f81333daa0bb652a5c1296941057eef82a12e12f.zip
code style, indent with tabs XI
Follow the same code style als MPD itself.
Diffstat (limited to 'src')
-rw-r--r--src/colors.c397
-rw-r--r--src/colors.h26
-rw-r--r--src/command.c292
-rw-r--r--src/command.h113
-rw-r--r--src/conf.c643
-rw-r--r--src/list_window.c4
-rw-r--r--src/main.c4
-rw-r--r--src/options.c2
-rw-r--r--src/playlist.c2
-rw-r--r--src/playlist.h2
-rw-r--r--src/screen.c2
-rw-r--r--src/screen_browser.h2
-rw-r--r--src/screen_help.c185
-rw-r--r--src/strfsong.c17
-rw-r--r--src/support.c4
-rw-r--r--src/support.h2
-rw-r--r--src/utils.c4
-rw-r--r--src/wreadln.c4
-rw-r--r--src/wreadln.h6
19 files changed, 790 insertions, 921 deletions
diff --git a/src/colors.c b/src/colors.c
index 67f3319ca..507be48ca 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
@@ -27,32 +25,32 @@
#include <string.h>
#include <glib.h>
-#define COLOR_BRIGHT_MASK (1<<7)
+#define COLOR_BRIGHT_MASK (1<<7)
-#define COLOR_BRIGHT_BLACK (COLOR_BLACK | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_RED (COLOR_RED | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_GREEN (COLOR_GREEN | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_YELLOW (COLOR_YELLOW | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_BLUE (COLOR_BLUE | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_MAGENTA (COLOR_MAGENTA | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_CYAN (COLOR_CYAN | COLOR_BRIGHT_MASK)
-#define COLOR_BRIGHT_WHITE (COLOR_WHITE | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_BLACK (COLOR_BLACK | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_RED (COLOR_RED | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_GREEN (COLOR_GREEN | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_YELLOW (COLOR_YELLOW | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_BLUE (COLOR_BLUE | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_MAGENTA (COLOR_MAGENTA | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_CYAN (COLOR_CYAN | COLOR_BRIGHT_MASK)
+#define COLOR_BRIGHT_WHITE (COLOR_WHITE | COLOR_BRIGHT_MASK)
#define IS_BRIGHT(color) (color & COLOR_BRIGHT_MASK)
/* name of the color fields */
-#define NAME_TITLE "title"
-#define NAME_TITLE_BOLD "title-bold"
-#define NAME_LINE "line"
-#define NAME_LINE_BOLD "line-flags"
-#define NAME_LIST "list"
-#define NAME_LIST_BOLD "list-bold"
-#define NAME_PROGRESS "progressbar"
-#define NAME_STATUS "status-song"
-#define NAME_STATUS_BOLD "status-state"
-#define NAME_STATUS_TIME "status-time"
-#define NAME_ALERT "alert"
-#define NAME_BGCOLOR "background"
+#define NAME_TITLE "title"
+#define NAME_TITLE_BOLD "title-bold"
+#define NAME_LINE "line"
+#define NAME_LINE_BOLD "line-flags"
+#define NAME_LIST "list"
+#define NAME_LIST_BOLD "list-bold"
+#define NAME_PROGRESS "progressbar"
+#define NAME_STATUS "status-song"
+#define NAME_STATUS_BOLD "status-state"
+#define NAME_STATUS_TIME "status-time"
+#define NAME_ALERT "alert"
+#define NAME_BGCOLOR "background"
typedef struct {
short color;
@@ -67,8 +65,7 @@ typedef struct {
} color_entry_t;
static color_entry_t colors[] = {
- /* color pair, field name, color, mono attribute */
- /*-------------------------------------------------------------------------*/
+ /* color pair, field name, color, mono attribute */
{ COLOR_TITLE, NAME_TITLE, COLOR_YELLOW, A_NORMAL },
{ COLOR_TITLE_BOLD, NAME_TITLE_BOLD, COLOR_BRIGHT_YELLOW, A_BOLD },
{ COLOR_LINE, NAME_LINE, COLOR_WHITE, A_NORMAL },
@@ -91,239 +88,217 @@ static GList *color_definition_list = NULL;
static color_entry_t *
colors_lookup(int id)
{
- int i;
-
- i=0;
- while( colors[i].name != NULL )
- {
- if( colors[i].id == id )
- return &colors[i];
- i++;
- }
- return NULL;
+ int i = 0;
+
+ while (colors[i].name != NULL) {
+ if (colors[i].id == id)
+ return &colors[i];
+ i++;
+ }
+
+ return NULL;
}
static color_entry_t *
colors_lookup_by_name(const char *name)
{
- int i;
-
- i=0;
- while( colors[i].name != NULL )
- {
- if( !strcasecmp(colors[i].name, name) )
- return &colors[i];
- i++;
- }
- return NULL;
+ int i = 0;
+
+ while (colors[i].name != NULL) {
+ if (!strcasecmp(colors[i].name, name))
+ return &colors[i];
+ i++;
+ }
+
+ return NULL;
}
static int
colors_update_pair(int id)
{
- color_entry_t *entry = colors_lookup(id);
- short fg = -1;
-
- if( !entry )
- return -1;
-
- if( IS_BRIGHT(entry->fg) )
- {
- entry->attrs = A_BOLD;
- fg = entry->fg & ~COLOR_BRIGHT_MASK;
- }
- else
- {
- entry->attrs = A_NORMAL;
- fg = entry->fg;
- }
-
- init_pair(entry->id, fg, bg);
-
- return 0;
+ color_entry_t *entry = colors_lookup(id);
+ short fg = -1;
+
+ if (!entry)
+ return -1;
+
+ if (IS_BRIGHT(entry->fg)) {
+ entry->attrs = A_BOLD;
+ fg = entry->fg & ~COLOR_BRIGHT_MASK;
+ } else {
+ entry->attrs = A_NORMAL;
+ fg = entry->fg;
+ }
+
+ init_pair(entry->id, fg, bg);
+ return 0;
}
short
colors_str2color(const char *str)
{
- if( !strcasecmp(str,"black") )
- return COLOR_BLACK;
- else if( !strcasecmp(str,"red") )
- return COLOR_RED;
- else if( !strcasecmp(str,"green") )
- return COLOR_GREEN;
- else if( !strcasecmp(str,"yellow") )
- return COLOR_YELLOW;
- else if( !strcasecmp(str,"blue") )
- return COLOR_BLUE;
- else if( !strcasecmp(str,"magenta") )
- return COLOR_MAGENTA;
- else if( !strcasecmp(str,"cyan") )
- return COLOR_CYAN;
- else if( !strcasecmp(str,"white") )
- return COLOR_WHITE;
- else if( !strcasecmp(str,"brightred") )
- return COLOR_BRIGHT_RED;
- else if( !strcasecmp(str,"brightgreen") )
- return COLOR_BRIGHT_GREEN;
- else if( !strcasecmp(str,"brightyellow") )
- return COLOR_BRIGHT_YELLOW;
- else if( !strcasecmp(str,"brightblue") )
- return COLOR_BRIGHT_BLUE;
- else if( !strcasecmp(str,"brightmagenta") )
- return COLOR_BRIGHT_MAGENTA;
- else if( !strcasecmp(str,"brightcyan") )
- return COLOR_BRIGHT_CYAN;
- else if( !strcasecmp(str,"brightwhite") )
- return COLOR_BRIGHT_WHITE;
- else if( !strcasecmp(str,"grey") || !strcasecmp(str,"gray") )
- return COLOR_BRIGHT_BLACK;
- else if( !strcasecmp(str,"none") )
- return -1;
- fprintf(stderr,_("Warning: Unknown color - %s\n"), str);
- return -2;
+ if (!strcasecmp(str, "black"))
+ return COLOR_BLACK;
+ else if (!strcasecmp(str, "red"))
+ return COLOR_RED;
+ else if (!strcasecmp(str, "green"))
+ return COLOR_GREEN;
+ else if (!strcasecmp(str, "yellow"))
+ return COLOR_YELLOW;
+ else if (!strcasecmp(str, "blue"))
+ return COLOR_BLUE;
+ else if (!strcasecmp(str, "magenta"))
+ return COLOR_MAGENTA;
+ else if (!strcasecmp(str, "cyan"))
+ return COLOR_CYAN;
+ else if (!strcasecmp(str, "white"))
+ return COLOR_WHITE;
+ else if (!strcasecmp(str, "brightred"))
+ return COLOR_BRIGHT_RED;
+ else if (!strcasecmp(str, "brightgreen"))
+ return COLOR_BRIGHT_GREEN;
+ else if (!strcasecmp(str, "brightyellow"))
+ return COLOR_BRIGHT_YELLOW;
+ else if (!strcasecmp(str, "brightblue"))
+ return COLOR_BRIGHT_BLUE;
+ else if (!strcasecmp(str, "brightmagenta"))
+ return COLOR_BRIGHT_MAGENTA;
+ else if (!strcasecmp(str, "brightcyan"))
+ return COLOR_BRIGHT_CYAN;
+ else if (!strcasecmp(str, "brightwhite"))
+ return COLOR_BRIGHT_WHITE;
+ else if (!strcasecmp(str, "grey") || !strcasecmp(str, "gray"))
+ return COLOR_BRIGHT_BLACK;
+ else if (!strcasecmp(str, "none"))
+ return -1;
+
+ fprintf(stderr,_("Warning: Unknown color - %s\n"), str);
+ return -2;
}
/* This function is called from conf.c before curses have been started,
- * it adds the definition to the color_definition_list and init_color() is
+ * it adds the definition to the color_definition_list and init_color() is
* done in colors_start() */
int
colors_define(const char *name, short r, short g, short b)
{
- color_definition_entry_t *entry;
- short color = colors_str2color(name);
+ color_definition_entry_t *entry;
+ short color = colors_str2color(name);
- if( color<0 )
- return -1;
+ if (color < 0)
+ return -1;
- entry = g_malloc(sizeof(color_definition_entry_t));
- entry->color = color;
- entry->r = r;
- entry->g = g;
- entry->b = b;
+ entry = g_malloc(sizeof(color_definition_entry_t));
+ entry->color = color;
+ entry->r = r;
+ entry->g = g;
+ entry->b = b;
- color_definition_list = g_list_append(color_definition_list, entry);
+ color_definition_list = g_list_append(color_definition_list, entry);
- return 0;
+ return 0;
}
-
int
colors_assign(const char *name, const char *value)
{
- color_entry_t *entry = colors_lookup_by_name(name);
- short color;
-
- if( !entry )
- {
- if( !strcasecmp(NAME_BGCOLOR, name) )
- {
- if( (color=colors_str2color(value)) < -1 )
- return -1;
- if( color > COLORS )
- color = color & ~COLOR_BRIGHT_MASK;
- bg = color;
- return 0;
+ color_entry_t *entry = colors_lookup_by_name(name);
+ short color;
+
+ if (!entry) {
+ if (!strcasecmp(NAME_BGCOLOR, name)) {
+ if ((color = colors_str2color(value)) < -1)
+ return -1;
+ if (color > COLORS)
+ color = color & ~COLOR_BRIGHT_MASK;
+ bg = color;
+ return 0;
+ }
+
+ fprintf(stderr,_("Warning: Unknown color field - %s\n"), name);
+ return -1;
}
- fprintf(stderr,_("Warning: Unknown color field - %s\n"), name);
- return -1;
- }
- if( (color=colors_str2color(value)) < -1 )
- return -1;
- entry->fg = color;
+ if ((color = colors_str2color(value)) < -1)
+ return -1;
- return 0;
+ entry->fg = color;
+ return 0;
}
-
int
colors_start(void)
{
- if( has_colors() )
- {
- /* initialize color support */
- start_color();
- use_default_colors();
- /* define any custom colors defined in the configuration file */
- if( color_definition_list && can_change_color() )
- {
- GList *list = color_definition_list;
-
- while( list )
- {
- color_definition_entry_t *entry = list->data;
-
- if( entry->color <= COLORS )
- init_color(entry->color, entry->r, entry->g, entry->b);
- list=list->next;
- }
+ if (has_colors()) {
+ /* initialize color support */
+ start_color();
+ use_default_colors();
+ /* define any custom colors defined in the configuration file */
+ if (color_definition_list && can_change_color()) {
+ GList *list = color_definition_list;
+
+ while (list) {
+ color_definition_entry_t *entry = list->data;
+
+ if (entry->color <= COLORS)
+ init_color(entry->color, entry->r,
+ entry->g, entry->b);
+ list = list->next;
+ }
+ } else if (color_definition_list && !can_change_color())
+ fprintf(stderr, _("Terminal lacks support for changing colors!\n"));
+
+ if (options.enable_colors) {
+ int i = 0;
+
+ while (colors[i].name) {
+ /* update the color pairs */
+ colors_update_pair(colors[i].id);
+ i++;
+ }
+ }
+ } else if (options.enable_colors) {
+ fprintf(stderr, _("Terminal lacks color capabilities!\n"));
+ options.enable_colors = 0;
}
- else if( color_definition_list && !can_change_color() )
- fprintf(stderr, _("Terminal lacks support for changing colors!\n"));
- if( options.enable_colors )
- {
- int i = 0;
+ /* free the color_definition_list */
+ if (color_definition_list) {
+ GList *list = color_definition_list;
- while(colors[i].name)
- {
- /* update the color pairs */
- colors_update_pair(colors[i].id);
- i++;
- }
+ while (list) {
+ g_free(list->data);
+ list=list->next;
+ }
+ g_list_free(color_definition_list);
+ color_definition_list = NULL;
}
- }
- else if( options.enable_colors )
- {
- fprintf(stderr, _("Terminal lacks color capabilities!\n"));
- options.enable_colors = 0;
- }
-
- /* free the color_definition_list */
- if( color_definition_list )
- {
- GList *list = color_definition_list;
-
- while( list )
- {
- g_free(list->data);
- list=list->next;
- }
- g_list_free(color_definition_list);
- color_definition_list = NULL;
- }
- return 0;
+ return 0;
}
-
int
colors_use(WINDOW *w, int id)
{
- color_entry_t *entry = colors_lookup(id);
- short pair;
- attr_t attrs;
-
- if( !entry )
- return -1;
-
- wattr_get(w, &attrs, &pair, NULL);
-
- if( options.enable_colors )
- {
- /* color mode */
- if( attrs != entry->attrs || id!=pair )
- wattr_set(w, entry->attrs, id, NULL);
- }
- else
- {
- /* mono mode */
- if( attrs != entry->attrs )
- wattrset(w, entry->attrs);
- }
-
- return 0;
-}
+ color_entry_t *entry = colors_lookup(id);
+ short pair;
+ attr_t attrs;
+ if (!entry)
+ return -1;
+
+ wattr_get(w, &attrs, &pair, NULL);
+
+ if (options.enable_colors) {
+ /* color mode */
+ if (attrs != entry->attrs || id != pair)
+ wattr_set(w, entry->attrs, id, NULL);
+ } else {
+ /* mono mode */
+ if (attrs != entry->attrs)
+ wattrset(w, entry->attrs);
+ }
+
+ return 0;
+}
diff --git a/src/colors.h b/src/colors.h
index a913021a1..f8a22d2f4 100644
--- a/src/colors.h
+++ b/src/colors.h
@@ -3,17 +3,17 @@
#include <ncurses.h>
-#define COLOR_TITLE 1
-#define COLOR_TITLE_BOLD 2
-#define COLOR_LINE 3
-#define COLOR_LINE_BOLD 4
-#define COLOR_LIST 5
-#define COLOR_LIST_BOLD 6
-#define COLOR_PROGRESSBAR 7
-#define COLOR_STATUS 8
-#define COLOR_STATUS_BOLD 9
-#define COLOR_STATUS_TIME 10
-#define COLOR_STATUS_ALERT 11
+#define COLOR_TITLE 1
+#define COLOR_TITLE_BOLD 2
+#define COLOR_LINE 3
+#define COLOR_LINE_BOLD 4
+#define COLOR_LIST 5
+#define COLOR_LIST_BOLD 6
+#define COLOR_PROGRESSBAR 7
+#define COLOR_STATUS 8
+#define COLOR_STATUS_BOLD 9
+#define COLOR_STATUS_TIME 10
+#define COLOR_STATUS_ALERT 11
short colors_str2color(const char *str);
@@ -22,8 +22,4 @@ int colors_define(const char *name, short r, short g, short b);
int colors_start(void);
int colors_use(WINDOW *w, int id);
-
#endif /* COLORS_H */
-
-
-
diff --git a/src/command.c b/src/command.c
index 71ae50e7d..af188d19a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
@@ -41,167 +39,165 @@
#define DK(x)
#endif
-#define BS KEY_BACKSPACE
-#define DEL KEY_DC
-#define UP KEY_UP
-#define DWN KEY_DOWN
+#define BS KEY_BACKSPACE
+#define DEL KEY_DC
+#define UP KEY_UP
+#define DWN KEY_DOWN
#define LEFT KEY_LEFT
#define RGHT KEY_RIGHT
#define HOME KEY_HOME
-#define END KEY_END
+#define END KEY_END
#define PGDN KEY_NPAGE
#define PGUP KEY_PPAGE
-#define TAB 0x09
+#define TAB 0x09
#define STAB 0x161
-#define ESC 0x1B
-#define F1 KEY_F(1)
-#define F2 KEY_F(2)
-#define F3 KEY_F(3)
-#define F4 KEY_F(4)
-#define F5 KEY_F(5)
-#define F6 KEY_F(6)
-#define F7 KEY_F(7)
+#define ESC 0x1B
+#define F1 KEY_F(1)
+#define F2 KEY_F(2)
+#define F3 KEY_F(3)
+#define F4 KEY_F(4)
+#define F5 KEY_F(5)
+#define F6 KEY_F(6)
+#define F7 KEY_F(7)
-static command_definition_t cmds[] =
-{
+static command_definition_t cmds[] = {
#ifdef ENABLE_KEYDEF_SCREEN
- { {'K', 0, 0 }, 0, CMD_SCREEN_KEYDEF, "screen-keyedit",
- N_("Key configuration screen") },
+ { {'K', 0, 0 }, 0, CMD_SCREEN_KEYDEF, "screen-keyedit",
+ N_("Key configuration screen") },
#endif
- { { 'q', 'Q', 3 }, 0, CMD_QUIT, "quit",
- N_("Quit") },
-
- /* movment */
- { { UP, 'k', 0 }, 0, CMD_LIST_PREVIOUS, "up",
- N_("Move cursor up") },
- { { DWN, 'j', 0 }, 0, CMD_LIST_NEXT, "down",
- N_("Move cursor down") },
- { { HOME, 0x01, 0 }, 0, CMD_LIST_FIRST, "home",
- N_("Home ") },
- { { END, 0x05, 0 }, 0, CMD_LIST_LAST, "end",
- N_("End ") },
- { { PGUP, 0, 0 }, 0, CMD_LIST_PREVIOUS_PAGE, "pgup",
- N_("Page up") },
- { { PGDN, 0, 0 }, 0, CMD_LIST_NEXT_PAGE, "pgdn",
- N_("Page down") },
-
-
- /* basic screens */
- { { '1', F1, 'h' }, 0, CMD_SCREEN_HELP, "screen-help",
- N_("Help screen") },
- { { '2', F2, 0 }, 0, CMD_SCREEN_PLAY, "screen-playlist",
- N_("Playlist screen") },
- { { '3', F3, 0 }, 0, CMD_SCREEN_FILE, "screen-browse",
- N_("Browse screen") },
-
-
- /* player commands */
- { { 13, 0, 0 }, 0, CMD_PLAY, "play",
- N_("Play/Enter directory") },
- { { 'P', 0, 0 }, 0, CMD_PAUSE,"pause",
- N_("Pause") },
- { { 's', BS, 0 }, 0, CMD_STOP, "stop",
- N_("Stop") },
- { { 'o', 0, 0 }, 0, CMD_CROP, "crop",
- N_("Crop") },
- { { '>', 0, 0 }, 0, CMD_TRACK_NEXT, "next",
- N_("Next track") },
- { { '<', 0, 0 }, 0, CMD_TRACK_PREVIOUS, "prev",
- N_("Previous track") },
- { { 'f', 0, 0 }, 0, CMD_SEEK_FORWARD, "seek-forward",
- N_("Seek forward") },
- { { 'b', 0, 0 }, 0, CMD_SEEK_BACKWARD, "seek-backward",
- N_("Seek backward") },
- { { '+', RGHT, 0 }, 0, CMD_VOLUME_UP, "volume-up",
- N_("Increase volume") },
- { { '-', LEFT, 0 }, 0, CMD_VOLUME_DOWN, "volume-down",
- N_("Decrease volume") },
- { { ' ', 0, 0 }, 0, CMD_SELECT, "select",
- N_("Select/deselect song in playlist") },
- { { 't', 0, 0 }, 0, CMD_SELECT_ALL, "select_all",
- N_("Select all listed items") },
- { { DEL, 'd', 0 }, 0, CMD_DELETE, "delete",
- N_("Delete song from playlist") },
- { { 'Z', 0, 0 }, 0, CMD_SHUFFLE, "shuffle",
- N_("Shuffle playlist") },
- { { 'c', 0, 0 }, 0, CMD_CLEAR, "clear",
- N_("Clear playlist") },
- { { 'r', 0, 0 }, 0, CMD_REPEAT, "repeat",
- N_("Toggle repeat mode") },
- { { 'z', 0, 0 }, 0, CMD_RANDOM, "random",
- N_("Toggle random mode") },
- { { 'x', 0, 0 }, 0, CMD_CROSSFADE, "crossfade",
- N_("Toggle crossfade mode") },
- { { 21, 0, 0 }, 0, CMD_DB_UPDATE, "db-update",
- N_("Start a music database update") },
- { { 'S', 0, 0 }, 0, CMD_SAVE_PLAYLIST, "save",
- N_("Save playlist") },
- { { 'a', 0, 0 }, 0, CMD_ADD, "add",
- N_("Add url/file to playlist") },
-
- { { '!', 0, 0 }, 0, CMD_GO_ROOT_DIRECTORY, "go-root-directory",
- N_("Go to root directory") },
- { { '"', 0, 0 }, 0, CMD_GO_PARENT_DIRECTORY, "go-parent-directory",
- N_("Go to parent directory") },
-
- /* lists */
- { { 11, 0, 0 }, 0, CMD_LIST_MOVE_UP, "move-up",
- N_("Move item up") },
- { { 10, 0, 0 }, 0, CMD_LIST_MOVE_DOWN, "move-down",
- N_("Move item down") },
- { { 12, 0, 0 }, 0, CMD_SCREEN_UPDATE, "update",
- N_("Update screen") },
-
-
- /* ncmpc options */
- { { 'w', 0, 0 }, 0, CMD_TOGGLE_FIND_WRAP, "wrap-mode",
- N_("Toggle find mode") },
- { { 'U', 0, 0 }, 0, CMD_TOGGLE_AUTOCENTER, "autocenter-mode",
- N_("Toggle auto center mode") },
-
-
- /* change screen */
- { { TAB, 0, 0 }, 0, CMD_SCREEN_NEXT, "screen-next",
- N_("Next screen") },
- { { STAB, 0, 0 }, 0, CMD_SCREEN_PREVIOUS, "screen-prev",
- N_("Previous screen") },
-
-
- /* find */
- { { '/', 0, 0 }, 0, CMD_LIST_FIND, "find",
- N_("Forward find") },
- { { 'n', 0, 0 }, 0, CMD_LIST_FIND_NEXT, "find-next",
- N_("Forward find next") },
- { { '?', 0, 0 }, 0, CMD_LIST_RFIND, "rfind",
- N_("Backward find") },
- { { 'p', 0, 0 }, 0, CMD_LIST_RFIND_NEXT, "rfind-next",
- N_("Backward find previous") },
-
-
- /* extra screens */
+ { { 'q', 'Q', 3 }, 0, CMD_QUIT, "quit",
+ N_("Quit") },
+
+ /* movment */
+ { { UP, 'k', 0 }, 0, CMD_LIST_PREVIOUS, "up",
+ N_("Move cursor up") },
+ { { DWN, 'j', 0 }, 0, CMD_LIST_NEXT, "down",
+ N_("Move cursor down") },
+ { { HOME, 0x01, 0 }, 0, CMD_LIST_FIRST, "home",
+ N_("Home ") },
+ { { END, 0x05, 0 }, 0, CMD_LIST_LAST, "end",
+ N_("End ") },
+ { { PGUP, 0, 0 }, 0, CMD_LIST_PREVIOUS_PAGE, "pgup",
+ N_("Page up") },
+ { { PGDN, 0, 0 }, 0, CMD_LIST_NEXT_PAGE, "pgdn",
+ N_("Page down") },
+
+
+ /* basic screens */
+ { { '1', F1, 'h' }, 0, CMD_SCREEN_HELP, "screen-help",
+ N_("Help screen") },
+ { { '2', F2, 0 }, 0, CMD_SCREEN_PLAY, "screen-playlist",
+ N_("Playlist screen") },
+ { { '3', F3, 0 }, 0, CMD_SCREEN_FILE, "screen-browse",
+ N_("Browse screen") },
+
+
+ /* player commands */
+ { { 13, 0, 0 }, 0, CMD_PLAY, "play",
+ N_("Play/Enter directory") },
+ { { 'P', 0, 0 }, 0, CMD_PAUSE,"pause",
+ N_("Pause") },
+ { { 's', BS, 0 }, 0, CMD_STOP, "stop",
+ N_("Stop") },
+ { { 'o', 0, 0 }, 0, CMD_CROP, "crop",
+ N_("Crop") },
+ { { '>', 0, 0 }, 0, CMD_TRACK_NEXT, "next",
+ N_("Next track") },
+ { { '<', 0, 0 }, 0, CMD_TRACK_PREVIOUS, "prev",
+ N_("Previous track") },
+ { { 'f', 0, 0 }, 0, CMD_SEEK_FORWARD, "seek-forward",
+ N_("Seek forward") },
+ { { 'b', 0, 0 }, 0, CMD_SEEK_BACKWARD, "seek-backward",
+ N_("Seek backward") },
+ { { '+', RGHT, 0 }, 0, CMD_VOLUME_UP, "volume-up",
+ N_("Increase volume") },
+ { { '-', LEFT, 0 }, 0, CMD_VOLUME_DOWN, "volume-down",
+ N_("Decrease volume") },
+ { { ' ', 0, 0 }, 0, CMD_SELECT, "select",
+ N_("Select/deselect song in playlist") },
+ { { 't', 0, 0 }, 0, CMD_SELECT_ALL, "select_all",
+ N_("Select all listed items") },
+ { { DEL, 'd', 0 }, 0, CMD_DELETE, "delete",
+ N_("Delete song from playlist") },
+ { { 'Z', 0, 0 }, 0, CMD_SHUFFLE, "shuffle",
+ N_("Shuffle playlist") },
+ { { 'c', 0, 0 }, 0, CMD_CLEAR, "clear",
+ N_("Clear playlist") },
+ { { 'r', 0, 0 }, 0, CMD_REPEAT, "repeat",
+ N_("Toggle repeat mode") },
+ { { 'z', 0, 0 }, 0, CMD_RANDOM, "random",
+ N_("Toggle random mode") },
+ { { 'x', 0, 0 }, 0, CMD_CROSSFADE, "crossfade",
+ N_("Toggle crossfade mode") },
+ { { 21, 0, 0 }, 0, CMD_DB_UPDATE, "db-update",
+ N_("Start a music database update") },
+ { { 'S', 0, 0 }, 0, CMD_SAVE_PLAYLIST, "save",
+ N_("Save playlist") },
+ { { 'a', 0, 0 }, 0, CMD_ADD, "add",
+ N_("Add url/file to playlist") },
+
+ { { '!', 0, 0 }, 0, CMD_GO_ROOT_DIRECTORY, "go-root-directory",
+ N_("Go to root directory") },
+ { { '"', 0, 0 }, 0, CMD_GO_PARENT_DIRECTORY, "go-parent-directory",
+ N_("Go to parent directory") },
+
+ /* lists */
+ { { 11, 0, 0 }, 0, CMD_LIST_MOVE_UP, "move-up",
+ N_("Move item up") },
+ { { 10, 0, 0 }, 0, CMD_LIST_MOVE_DOWN, "move-down",
+ N_("Move item down") },
+ { { 12, 0, 0 }, 0, CMD_SCREEN_UPDATE, "update",
+ N_("Update screen") },
+
+
+ /* ncmpc options */
+ { { 'w', 0, 0 }, 0, CMD_TOGGLE_FIND_WRAP, "wrap-mode",
+ N_("Toggle find mode") },
+ { { 'U', 0, 0 }, 0, CMD_TOGGLE_AUTOCENTER, "autocenter-mode",
+ N_("Toggle auto center mode") },
+
+
+ /* change screen */
+ { { TAB, 0, 0 }, 0, CMD_SCREEN_NEXT, "screen-next",
+ N_("Next screen") },
+ { { STAB, 0, 0 }, 0, CMD_SCREEN_PREVIOUS, "screen-prev",
+ N_("Previous screen") },
+
+
+ /* find */
+ { { '/', 0, 0 }, 0, CMD_LIST_FIND, "find",
+ N_("Forward find") },
+ { { 'n', 0, 0 }, 0, CMD_LIST_FIND_NEXT, "find-next",
+ N_("Forward find next") },
+ { { '?', 0, 0 }, 0, CMD_LIST_RFIND, "rfind",
+ N_("Backward find") },
+ { { 'p', 0, 0 }, 0, CMD_LIST_RFIND_NEXT, "rfind-next",
+ N_("Backward find previous") },
+
+
+ /* extra screens */
#ifdef ENABLE_ARTIST_SCREEN
- { {'4', F4, 0 }, 0, CMD_SCREEN_ARTIST, "screen-artist",
- N_("Artist screen") },
+ { {'4', F4, 0 }, 0, CMD_SCREEN_ARTIST, "screen-artist",
+ N_("Artist screen") },
#endif
#ifdef ENABLE_SEARCH_SCREEN
- { {'5', F5, 0 }, 0, CMD_SCREEN_SEARCH, "screen-search",
- N_("Search screen") },
- { {'m', 0, 0 }, 0, CMD_SEARCH_MODE, "search-mode",
- N_("Change search mode") },
+ { {'5', F5, 0 }, 0, CMD_SCREEN_SEARCH, "screen-search",
+ N_("Search screen") },
+ { {'m', 0, 0 }, 0, CMD_SEARCH_MODE, "search-mode",
+ N_("Change search mode") },
#endif
#ifdef ENABLE_LYRICS_SCREEN
- { {'7', F7, 0 }, 0, CMD_SCREEN_LYRICS, "screen-lyrics",
- N_("Lyrics screen") },
- { {ESC, 0, 0 }, 0, CMD_INTERRUPT, "lyrics-interrupt",
- N_("Interrupt action") },
- { {'u', 0, 0 }, 0, CMD_LYRICS_UPDATE, "lyrics-update",
- N_("Update Lyrics") },
+ { {'7', F7, 0 }, 0, CMD_SCREEN_LYRICS, "screen-lyrics",
+ N_("Lyrics screen") },
+ { {ESC, 0, 0 }, 0, CMD_INTERRUPT, "lyrics-interrupt",
+ N_("Interrupt action") },
+ { {'u', 0, 0 }, 0, CMD_LYRICS_UPDATE, "lyrics-update",
+ N_("Update Lyrics") },
#endif
-
- { { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL }
+ { { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL }
};
command_definition_t *
@@ -510,10 +506,10 @@ write_key_bindings(FILE *f, int flags)
{
int i,j;
- if( flags & KEYDEF_WRITE_HEADER )
+ if (flags & KEYDEF_WRITE_HEADER)
fprintf(f, "## Key bindings for ncmpc (generated by ncmpc)\n\n");
- i=0;
+ i = 0;
while (cmds[i].name && !ferror(f)) {
if (cmds[i].flags & COMMAND_KEY_MODIFIED ||
flags & KEYDEF_WRITE_ALL) {
diff --git a/src/command.h b/src/command.h
index f4b6859e8..4529da824 100644
--- a/src/command.h
+++ b/src/command.h
@@ -8,61 +8,60 @@
#define MAX_COMMAND_KEYS 3
/* commands */
-typedef enum
-{
- CMD_NONE = 0,
- CMD_PLAY,
- CMD_SELECT,
- CMD_SELECT_ALL,
- CMD_PAUSE,
- CMD_STOP,
- CMD_CROP,
- CMD_TRACK_NEXT,
- CMD_TRACK_PREVIOUS,
- CMD_SEEK_FORWARD,
- CMD_SEEK_BACKWARD,
- CMD_SHUFFLE,
- CMD_RANDOM,
- CMD_CLEAR,
- CMD_DELETE,
- CMD_REPEAT,
- CMD_CROSSFADE,
- CMD_DB_UPDATE,
- CMD_VOLUME_UP,
- CMD_VOLUME_DOWN,
- CMD_ADD,
- CMD_SAVE_PLAYLIST,
- CMD_TOGGLE_FIND_WRAP,
- CMD_TOGGLE_AUTOCENTER,
- CMD_SEARCH_MODE,
- CMD_LIST_PREVIOUS,
- CMD_LIST_NEXT,
- CMD_LIST_FIRST,
- CMD_LIST_LAST,
- CMD_LIST_NEXT_PAGE,
- CMD_LIST_PREVIOUS_PAGE,
- CMD_LIST_FIND,
- CMD_LIST_FIND_NEXT,
- CMD_LIST_RFIND,
- CMD_LIST_RFIND_NEXT,
- CMD_LIST_MOVE_UP,
- CMD_LIST_MOVE_DOWN,
- CMD_MOUSE_EVENT,
- CMD_SCREEN_UPDATE,
- CMD_SCREEN_PREVIOUS,
- CMD_SCREEN_NEXT,
- CMD_SCREEN_PLAY,
- CMD_SCREEN_FILE,
- CMD_SCREEN_ARTIST,
- CMD_SCREEN_SEARCH,
- CMD_SCREEN_KEYDEF,
- CMD_SCREEN_HELP,
- CMD_SCREEN_LYRICS,
- CMD_LYRICS_UPDATE,
- CMD_INTERRUPT,
- CMD_GO_ROOT_DIRECTORY,
- CMD_GO_PARENT_DIRECTORY,
- CMD_QUIT
+typedef enum {
+ CMD_NONE = 0,
+ CMD_PLAY,
+ CMD_SELECT,
+ CMD_SELECT_ALL,
+ CMD_PAUSE,
+ CMD_STOP,
+ CMD_CROP,
+ CMD_TRACK_NEXT,
+ CMD_TRACK_PREVIOUS,
+ CMD_SEEK_FORWARD,
+ CMD_SEEK_BACKWARD,
+ CMD_SHUFFLE,
+ CMD_RANDOM,
+ CMD_CLEAR,
+ CMD_DELETE,
+ CMD_REPEAT,
+ CMD_CROSSFADE,
+ CMD_DB_UPDATE,
+ CMD_VOLUME_UP,
+ CMD_VOLUME_DOWN,
+ CMD_ADD,
+ CMD_SAVE_PLAYLIST,
+ CMD_TOGGLE_FIND_WRAP,
+ CMD_TOGGLE_AUTOCENTER,
+ CMD_SEARCH_MODE,
+ CMD_LIST_PREVIOUS,
+ CMD_LIST_NEXT,
+ CMD_LIST_FIRST,
+ CMD_LIST_LAST,
+ CMD_LIST_NEXT_PAGE,
+ CMD_LIST_PREVIOUS_PAGE,
+ CMD_LIST_FIND,
+ CMD_LIST_FIND_NEXT,
+ CMD_LIST_RFIND,
+ CMD_LIST_RFIND_NEXT,
+ CMD_LIST_MOVE_UP,
+ CMD_LIST_MOVE_DOWN,
+ CMD_MOUSE_EVENT,
+ CMD_SCREEN_UPDATE,
+ CMD_SCREEN_PREVIOUS,
+ CMD_SCREEN_NEXT,
+ CMD_SCREEN_PLAY,
+ CMD_SCREEN_FILE,
+ CMD_SCREEN_ARTIST,
+ CMD_SCREEN_SEARCH,
+ CMD_SCREEN_KEYDEF,
+ CMD_SCREEN_HELP,
+ CMD_SCREEN_LYRICS,
+ CMD_LYRICS_UPDATE,
+ CMD_INTERRUPT,
+ CMD_GO_ROOT_DIRECTORY,
+ CMD_GO_PARENT_DIRECTORY,
+ CMD_QUIT
} command_t;
@@ -87,8 +86,8 @@ command_definition_t *get_command_definitions(void);
command_t find_key_command(int key, command_definition_t *cmds);
void command_dump_keys(void);
-int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
-int write_key_bindings(FILE *f, int all);
+int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
+int write_key_bindings(FILE *f, int all);
const char *key2str(int key);
const char *get_key_description(command_t command);
diff --git a/src/conf.c b/src/conf.c
index a39c49317..5dff1ccdf 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
@@ -39,48 +37,48 @@
#include <glib.h>
#define MAX_LINE_LENGTH 1024
-#define COMMENT_TOKEN '#'
+#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_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"
-#define CONF_XTERM_TITLE_FORMAT "xterm-title-format"
-#define CONF_LIST_WRAP "wrap-around"
-#define CONF_FIND_WRAP "find-wrap"
-#define CONF_FIND_SHOW_LAST "find-show-last"
-#define CONF_AUDIBLE_BELL "audible-bell"
-#define CONF_VISIBLE_BELL "visible-bell"
-#define CONF_XTERM_TITLE "set-xterm-title"
-#define CONF_ENABLE_MOUSE "enable-mouse"
-#define CONF_CROSSFADE_TIME "crossfade-time"
-#define CONF_SEARCH_MODE "search-mode"
-#define CONF_HIDE_CURSOR "hide-cursor"
-#define CONF_SEEK_TIME "seek-time"
-#define CONF_SCREEN_LIST "screen-list"
-#define CONF_TIMEDISPLAY_TYPE "timedisplay-type"
-#define CONF_HOST "host"
-#define CONF_PORT "port"
-#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"
-#define CONF_VISIBLE_BITRATE "visible-bitrate"
-#define CONF_WELCOME_SCREEN_LIST "welcome-screen-list"
+#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"
+#define CONF_XTERM_TITLE_FORMAT "xterm-title-format"
+#define CONF_LIST_WRAP "wrap-around"
+#define CONF_FIND_WRAP "find-wrap"
+#define CONF_FIND_SHOW_LAST "find-show-last"
+#define CONF_AUDIBLE_BELL "audible-bell"
+#define CONF_VISIBLE_BELL "visible-bell"
+#define CONF_XTERM_TITLE "set-xterm-title"
+#define CONF_ENABLE_MOUSE "enable-mouse"
+#define CONF_CROSSFADE_TIME "crossfade-time"
+#define CONF_SEARCH_MODE "search-mode"
+#define CONF_HIDE_CURSOR "hide-cursor"
+#define CONF_SEEK_TIME "seek-time"
+#define CONF_SCREEN_LIST "screen-list"
+#define CONF_TIMEDISPLAY_TYPE "timedisplay-type"
+#define CONF_HOST "host"
+#define CONF_PORT "port"
+#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"
+#define CONF_VISIBLE_BITRATE "visible-bitrate"
+#define CONF_WELCOME_SCREEN_LIST "welcome-screen-list"
typedef enum {
- KEY_PARSER_UNKNOWN,
- KEY_PARSER_CHAR,
- KEY_PARSER_DEC,
- KEY_PARSER_HEX,
- KEY_PARSER_DONE
+ KEY_PARSER_UNKNOWN,
+ KEY_PARSER_CHAR,
+ KEY_PARSER_DEC,
+ KEY_PARSER_HEX,
+ KEY_PARSER_DONE
} key_parser_state_t;
static bool
@@ -188,7 +186,7 @@ parse_key_definition(char *str)
memset(buf, 0, MAX_LINE_LENGTH);
g_strlcpy(buf, str+i, MAX_LINE_LENGTH);
len = strlen(buf);
- if( len==0 ) {
+ if (len == 0) {
fprintf(stderr,_("Error: Incomplete key definition - %s\n"), str);
return -1;
}
@@ -200,14 +198,15 @@ parse_key_definition(char *str)
p = buf;
end = buf+len;
memset(keys, 0, sizeof(int)*MAX_COMMAND_KEYS);
- while( i<MAX_COMMAND_KEYS && p<end &&
- (key=parse_key_value(p,len+1,&p))>=0 ) {
+ while (i < MAX_COMMAND_KEYS && p < end &&
+ (key = parse_key_value(p, len + 1, &p)) >= 0) {
keys[i++] = key;
- while( p<end && (*p==',' || *p==' ' || *p=='\t') )
+ while (p < end && (*p==',' || *p==' ' || *p=='\t'))
p++;
len = strlen(p);
}
- if( key<0 ) {
+
+ if (key < 0) {
fprintf(stderr,_("Error: Bad key definition - %s\n"), str);
return -1;
}
@@ -218,9 +217,9 @@ parse_key_definition(char *str)
static const char *
parse_timedisplay_type(const char *str)
{
- if((!strcmp(str,"elapsed")) || (!strcmp(str,"remaining"))){
+ if (!strcmp(str,"elapsed") || !strcmp(str,"remaining"))
return str;
- } else {
+ else {
fprintf(stderr,_("Error: Bad time display type - %s\n"), str);
return DEFAULT_TIMEDISPLAY_TYPE;
}
@@ -245,7 +244,7 @@ parse_color(char *str)
i++;
}
- if( i<len )
+ if (i < len)
value = str+i;
return colors_assign(name, value);
@@ -266,8 +265,8 @@ parse_color_definition(char *str)
memset(buf, 0, MAX_LINE_LENGTH);
while (i < len && str[i] != '=' && !g_ascii_isspace(str[i]))
buf[j++] = str[i++];
- color=colors_str2color(buf);
- if( color<0 ) {
+ color = colors_str2color(buf);
+ if (color < 0) {
fprintf(stderr,_("Error: Bad color %s [%d]\n"), buf, color);
return -1;
}
@@ -281,8 +280,9 @@ parse_color_definition(char *str)
memset(buf, 0, MAX_LINE_LENGTH);
g_strlcpy(buf, str+i, MAX_LINE_LENGTH);
len = strlen(buf);
- if( len==0 ) {
- fprintf(stderr,_("Error: Incomplete color definition - %s\n"), str);
+ if (len == 0) {
+ fprintf(stderr, _("Error: Incomplete color definition - %s\n"),
+ str);
g_free(name);
return -1;
}
@@ -292,19 +292,22 @@ parse_color_definition(char *str)
value = 0;
len = strlen(buf);
p = buf;
- end = buf+len;
+ end = buf + len;
memset(rgb, 0, sizeof(short)*3);
- while( i<3 && p<end && (value=parse_key_value(p,len+1,&p))>=0 ) {
+ while (i < 3 && p < end &&
+ (value = parse_key_value(p,len+1,&p)) >= 0) {
rgb[i++] = value;
while( p<end && (*p==',' || *p==' ' || *p=='\t') )
p++;
len = strlen(p);
}
- if( value<0 || i!=3) {
- fprintf(stderr,_("Error: Bad color definition - %s\n"), str);
+
+ if (value < 0 || i != 3) {
+ fprintf(stderr, _("Error: Bad color definition - %s\n"), str);
g_free(name);
return -1;
}
+
value = colors_define(name, rgb[0], rgb[1], rgb[2]);
g_free(name);
return value;
@@ -315,10 +318,11 @@ get_format(char *str)
{
gsize len = strlen(str);
- if( str && str[0]=='\"' && str[len-1] == '\"' ) {
- str[len-1] = '\0';
+ if (str && str[0]=='\"' && str[len-1] == '\"') {
+ str[len - 1] = '\0';
str++;
}
+
return g_strdup(str);
}
@@ -355,243 +359,175 @@ check_screen_list(char *value)
static int
read_rc_file(char *filename, options_t *options)
{
- int fd;
- int quit = 0;
- int free_filename = 0;
-
- if( filename==NULL )
- return -1;
-
- if( (fd=open(filename,O_RDONLY)) <0 )
- {
- perror(filename);
- if( free_filename )
- g_free(filename);
- return -1;
- }
-
- while( !quit )
- {
- int i,j;
- int len;
- int match_found;
- char line[MAX_LINE_LENGTH];
- char name[MAX_LINE_LENGTH];
- char value[MAX_LINE_LENGTH];
-
- line[0] = '\0';
- value[0] = '\0';
-
- i = 0;
- /* read a line ending with '\n' */
- do {
- len = read( fd, &line[i], 1 );
- if( len == 1 )
- i++;
- else
- quit = 1;
- } while( !quit && i<MAX_LINE_LENGTH && line[i-1]!='\n' );
-
-
- /* remove trailing whitespace */
- line[i] = '\0';
- i--;
- while (i >= 0 && g_ascii_isspace(line[i]))
- {
- line[i] = '\0';
- i--;
- }
- len = i+1;
-
- if( len>0 )
- {
- i = 0;
- /* skip whitespace */
- while (i < len && g_ascii_isspace(line[i]))
- i++;
-
- /* continue if this line is not a comment */
- if( line[i] != COMMENT_TOKEN )
- {
- /* get the name part */
- j=0;
- while (i < len && line[i] != '=' && !g_ascii_isspace(line[i]))
- {
- name[j++] = line[i++];
- }
- name[j] = '\0';
-
- /* skip '=' and whitespace */
- while (i < len && (line[i] == '=' || g_ascii_isspace(line[i])))
- i++;
-
- /* get the value part */
- j=0;
- while( i<len )
- {
- value[j++] = line[i++];
- }
- value[j] = '\0';
-
- match_found = 1;
-
- /* key definition */
- if( !strcasecmp(CONF_KEY_DEFINITION, name) )
- {
- parse_key_definition(value);
- }
- /* enable colors */
- else if( !strcasecmp(CONF_ENABLE_COLORS, name) )
- {
- options->enable_colors = str2bool(value);
- }
- /* auto center */
- else if( !strcasecmp(CONF_AUTO_CENTER, name) )
- {
- options->auto_center = str2bool(value);
- }
- /* color assignment */
- else if( !strcasecmp(CONF_COLOR, name) )
- {
- parse_color(value);
- }
- /* wide cursor */
- else if( !strcasecmp(CONF_WIDE_CURSOR, name) )
- {
- options->wide_cursor = str2bool(value);
- }
- /* welcome screen list */
- else if (!strcasecmp(CONF_WELCOME_SCREEN_LIST, name)) {
- options->welcome_screen_list = str2bool(value);
- }
- /* visible bitrate */
- else if (!strcasecmp(CONF_VISIBLE_BITRATE, name)) {
- options->visible_bitrate = str2bool(value);
- }
- /* timer display type */
- else if( !strcasecmp(CONF_TIMEDISPLAY_TYPE, name) )
- {
- g_free(options->timedisplay_type);
- options->timedisplay_type=g_strdup(parse_timedisplay_type(value));
- }
- /* color definition */
- else if( !strcasecmp(CONF_COLOR_DEFINITION, 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);
- }
- /* status format string */
- else if( !strcasecmp(CONF_STATUS_FORMAT, name) )
- {
- g_free(options->status_format);
- options->status_format = get_format(value);
- }
- /* xterm title format string */
- else if( !strcasecmp(CONF_XTERM_TITLE_FORMAT, name) )
- {
- g_free(options->xterm_title_format);
- options->xterm_title_format = get_format(value);
- }
- else if( !strcasecmp(CONF_LIST_WRAP, name) )
- {
- options->list_wrap = str2bool(value);
- }
- else if( !strcasecmp(CONF_FIND_WRAP, name) )
- {
- options->find_wrap = str2bool(value);
- }
- else if( !strcasecmp(CONF_FIND_SHOW_LAST,name) )
- {
- options->find_show_last_pattern = str2bool(value);
- }
- else if( !strcasecmp(CONF_AUDIBLE_BELL, name) )
- {
- options->audible_bell = str2bool(value);
- }
- else if( !strcasecmp(CONF_VISIBLE_BELL, name) )
- {
- options->visible_bell = str2bool(value);
- }
- else if( !strcasecmp(CONF_XTERM_TITLE, name) )
- {
- options->enable_xterm_title = str2bool(value);
- }
- else if( !strcasecmp(CONF_ENABLE_MOUSE, name) )
- {
- options->enable_mouse = str2bool(value);
- }
- else if( !strcasecmp(CONF_CROSSFADE_TIME, name) )
- {
- options->crossfade_time = atoi(value);
- }
- else if( !strcasecmp(CONF_SEARCH_MODE, name) )
- {
- options->search_mode = atoi(value);
- }
- else if( !strcasecmp(CONF_HIDE_CURSOR, name) )
- {
- options->hide_cursor = atoi(value);
- }
- else if( !strcasecmp(CONF_SEEK_TIME, name) )
- {
- options->seek_time = atoi(value);
- }
- else if( !strcasecmp(CONF_SCREEN_LIST, name) )
- {
- g_strfreev(options->screen_list);
- options->screen_list = check_screen_list(value);
+ int fd;
+ int quit = 0;
+ int free_filename = 0;
+
+ if (filename == NULL)
+ return -1;
+
+ if ((fd = open(filename,O_RDONLY)) < 0) {
+ perror(filename);
+ if (free_filename)
+ g_free(filename);
+ return -1;
}
- else if( !strcasecmp(CONF_SHOW_SPLASH, name) )
- {
- /* the splash screen was removed */
+
+ while (!quit) {
+ int i,j;
+ int len;
+ int match_found;
+ char line[MAX_LINE_LENGTH];
+ char name[MAX_LINE_LENGTH];
+ char value[MAX_LINE_LENGTH];
+
+ line[0] = '\0';
+ value[0] = '\0';
+
+ i = 0;
+ /* read a line ending with '\n' */
+ do {
+ len = read(fd, &line[i], 1);
+ if (len == 1)
+ i++;
+ else
+ quit = 1;
+ } while (!quit && i < MAX_LINE_LENGTH && line[i-1] != '\n');
+
+
+ /* remove trailing whitespace */
+ line[i] = '\0';
+ i--;
+ while (i >= 0 && g_ascii_isspace(line[i])) {
+ line[i] = '\0';
+ i--;
}
- else if( !strcasecmp(CONF_HOST, name))
- {
- options->host = get_format(value);
- }
- else if( !strcasecmp(CONF_PORT, name))
- {
- options->port = atoi(get_format(value));
- }
- else if( !strcasecmp(CONF_PASSWORD, name))
- {
- options->password = get_format(value);
- }
- else if( !strcasecmp(CONF_LYRICS_TIMEOUT, name))
- {
- 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;
+
+ len = i + 1;
+ if (len > 0) {
+ i = 0;
+ /* skip whitespace */
+ while (i < len && g_ascii_isspace(line[i]))
+ i++;
+
+ /* continue if this line is not a comment */
+ if (line[i] != COMMENT_TOKEN) {
+ /* get the name part */
+ j = 0;
+ while (i < len && line[i] != '=' &&
+ !g_ascii_isspace(line[i])) {
+ name[j++] = line[i++];
+ }
+
+ name[j] = '\0';
+
+ /* skip '=' and whitespace */
+ while (i < len && (line[i] == '=' || g_ascii_isspace(line[i])))
+ i++;
+
+ /* get the value part */
+ j = 0;
+ while (i < len)
+ value[j++] = line[i++];
+ value[j] = '\0';
+
+ match_found = 1;
+
+ /* key definition */
+ if (!strcasecmp(CONF_KEY_DEFINITION, name))
+ parse_key_definition(value);
+ /* enable colors */
+ else if(!strcasecmp(CONF_ENABLE_COLORS, name))
+ options->enable_colors = str2bool(value);
+ /* auto center */
+ else if (!strcasecmp(CONF_AUTO_CENTER, name))
+ options->auto_center = str2bool(value);
+ /* color assignment */
+ else if (!strcasecmp(CONF_COLOR, name))
+ parse_color(value);
+ /* wide cursor */
+ else if (!strcasecmp(CONF_WIDE_CURSOR, name))
+ options->wide_cursor = str2bool(value);
+ /* welcome screen list */
+ else if (!strcasecmp(CONF_WELCOME_SCREEN_LIST, name))
+ options->welcome_screen_list = str2bool(value);
+ /* visible bitrate */
+ else if (!strcasecmp(CONF_VISIBLE_BITRATE, name))
+ options->visible_bitrate = str2bool(value);
+ /* timer display type */
+ else if (!strcasecmp(CONF_TIMEDISPLAY_TYPE, name)) {
+ g_free(options->timedisplay_type);
+ options->timedisplay_type=g_strdup(parse_timedisplay_type(value));
+ /* color definition */
+ } else if (!strcasecmp(CONF_COLOR_DEFINITION, 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);
+ /* status format string */
+ } else if (!strcasecmp(CONF_STATUS_FORMAT, name)) {
+ g_free(options->status_format);
+ options->status_format = get_format(value);
+ /* xterm title format string */
+ } else if (!strcasecmp(CONF_XTERM_TITLE_FORMAT, name)) {
+ g_free(options->xterm_title_format);
+ options->xterm_title_format = get_format(value);
+ } else if (!strcasecmp(CONF_LIST_WRAP, name))
+ options->list_wrap = str2bool(value);
+ else if (!strcasecmp(CONF_FIND_WRAP, name))
+ options->find_wrap = str2bool(value);
+ else if (!strcasecmp(CONF_FIND_SHOW_LAST,name))
+ options->find_show_last_pattern = str2bool(value);
+ else if (!strcasecmp(CONF_AUDIBLE_BELL, name))
+ options->audible_bell = str2bool(value);
+ else if (!strcasecmp(CONF_VISIBLE_BELL, name))
+ options->visible_bell = str2bool(value);
+ else if (!strcasecmp(CONF_XTERM_TITLE, name))
+ options->enable_xterm_title = str2bool(value);
+ else if (!strcasecmp(CONF_ENABLE_MOUSE, name))
+ options->enable_mouse = str2bool(value);
+ else if (!strcasecmp(CONF_CROSSFADE_TIME, name))
+ options->crossfade_time = atoi(value);
+ else if (!strcasecmp(CONF_SEARCH_MODE, name))
+ options->search_mode = atoi(value);
+ else if (!strcasecmp(CONF_HIDE_CURSOR, name))
+ options->hide_cursor = atoi(value);
+ else if (!strcasecmp(CONF_SEEK_TIME, name))
+ options->seek_time = atoi(value);
+ else if (!strcasecmp(CONF_SCREEN_LIST, name)) {
+ g_strfreev(options->screen_list);
+ options->screen_list = check_screen_list(value);
+ } else if (!strcasecmp(CONF_SHOW_SPLASH, name)) {
+ /* the splash screen was removed */
+ } else if (!strcasecmp(CONF_HOST, name))
+ options->host = get_format(value);
+ else if (!strcasecmp(CONF_PORT, name))
+ options->port = atoi(get_format(value));
+ else if (!strcasecmp(CONF_PASSWORD, name))
+ options->password = get_format(value);
+ else if (!strcasecmp(CONF_LYRICS_TIMEOUT, name))
+ 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;
+
+ if (!match_found)
+ fprintf(stderr,
+ _("Unknown configuration parameter: %s\n"),
+ name);
+ }
}
+ }
+
+ if (free_filename)
+ g_free(filename);
- if( !match_found )
- fprintf(stderr,
- _("Unknown configuration parameter: %s\n"),
- name);
- }
- }
- }
-
- if( free_filename )
- g_free(filename);
-
- return 0;
+ return 0;
}
int
@@ -616,80 +552,69 @@ get_user_key_binding_filename(void)
return g_build_filename(g_get_home_dir(), "." PACKAGE, "keys", NULL);
}
-
int
read_configuration(options_t *options)
{
- char *filename = NULL;
-
- /* check for command line configuration file */
- if( options->config_file )
- filename = g_strdup(options->config_file);
-
- /* check for user configuration ~/.ncmpc/config */
- if( filename == NULL )
- {
- filename = g_build_filename(g_get_home_dir(),
- "." PACKAGE, "config", NULL);
- if( !g_file_test(filename, G_FILE_TEST_IS_REGULAR) )
- {
- g_free(filename);
- filename = NULL;
+ char *filename = NULL;
+
+ /* check for command line configuration file */
+ if (options->config_file)
+ filename = g_strdup(options->config_file);
+
+ /* check for user configuration ~/.ncmpc/config */
+ if (filename == NULL) {
+ filename = g_build_filename(g_get_home_dir(),
+ "." PACKAGE, "config", NULL);
+ if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free(filename);
+ filename = NULL;
+ }
+ }
+
+ /* check for global configuration SYSCONFDIR/ncmpc/config */
+ if (filename == NULL) {
+ filename = g_build_filename(SYSCONFDIR, PACKAGE, "config", NULL);
+ if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free(filename);
+ filename = NULL;
+ }
}
- }
-
- /* check for global configuration SYSCONFDIR/ncmpc/config */
- if( filename == NULL )
- {
- filename = g_build_filename(SYSCONFDIR, PACKAGE, "config", NULL);
- if( !g_file_test(filename, G_FILE_TEST_IS_REGULAR) )
- {
- g_free(filename);
- filename = NULL;
+
+ /* load configuration */
+ if (filename) {
+ read_rc_file(filename, options);
+ g_free(filename);
+ filename = NULL;
}
- }
-
- /* load configuration */
- if( filename )
- {
- read_rc_file(filename, options);
- g_free(filename);
- filename = NULL;
- }
-
- /* check for command line key binding file */
- if( options->key_file )
- filename = g_strdup(options->key_file);
-
- /* check for user key bindings ~/.ncmpc/keys */
- if( filename == NULL )
- {
- filename = get_user_key_binding_filename();
- if( !g_file_test(filename, G_FILE_TEST_IS_REGULAR) )
- {
- g_free(filename);
- filename = NULL;
+
+ /* check for command line key binding file */
+ if (options->key_file)
+ filename = g_strdup(options->key_file);
+
+ /* check for user key bindings ~/.ncmpc/keys */
+ if (filename == NULL) {
+ filename = get_user_key_binding_filename();
+ if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free(filename);
+ filename = NULL;
+ }
}
- }
-
- /* check for global key bindings SYSCONFDIR/ncmpc/keys */
- if( filename == NULL )
- {
- filename = g_build_filename(SYSCONFDIR, PACKAGE, "keys", NULL);
- if( !g_file_test(filename, G_FILE_TEST_IS_REGULAR) )
- {
- g_free(filename);
- filename = NULL;
+
+ /* check for global key bindings SYSCONFDIR/ncmpc/keys */
+ if (filename == NULL) {
+ filename = g_build_filename(SYSCONFDIR, PACKAGE, "keys", NULL);
+ if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ g_free(filename);
+ filename = NULL;
+ }
}
- }
- /* load key bindings */
- if( filename )
- {
- read_rc_file(filename, options);
- g_free(filename);
- filename = NULL;
- }
+ /* load key bindings */
+ if (filename) {
+ read_rc_file(filename, options);
+ g_free(filename);
+ filename = NULL;
+ }
- return 0;
+ return 0;
}
diff --git a/src/list_window.c b/src/list_window.c
index 55b621b4a..efb610117 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/main.c b/src/main.c
index 668d5aa33..e701712fd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/options.c b/src/options.c
index 9cb1b1685..ca3e983b3 100644
--- a/src/options.c
+++ b/src/options.c
@@ -306,7 +306,7 @@ options_parse(int argc, const char *argv[])
}
options_t *
-options_init( void )
+options_init(void)
{
const char *value;
char *tmp;
diff --git a/src/playlist.c b/src/playlist.c
index 108c4f51a..19a1b419c 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* (c) 2004 by Kalle Wallin <kaw@linux.se>
* (c) 2008 Max Kellermann <max@duempel.org>
*
diff --git a/src/playlist.h b/src/playlist.h
index 0d524adbe..6597357d3 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* (c) 2004 by Kalle Wallin <kaw@linux.se>
* (c) 2008 Max Kellermann <max@duempel.org>
*
diff --git a/src/screen.c b/src/screen.c
index 87d738825..231d84ada 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/screen_browser.h b/src/screen_browser.h
index cd218bc48..17e41f6ec 100644
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* (c) 2004 by Kalle Wallin <kaw@linux.se>
* Copyright (C) 2008 Max Kellermann <max@duempel.org>
*
diff --git a/src/screen_help.c b/src/screen_help.c
index 700bc8b65..adf9a0310 100644
--- a/src/screen_help.c
+++ b/src/screen_help.c
@@ -29,120 +29,117 @@
#include <glib.h>
#include <ncurses.h>
-
typedef struct {
signed char highlight;
command_t command;
const char *text;
} help_text_row_t;
-static help_text_row_t help_text[] =
-{
- { 1, CMD_NONE, N_("Keys - Movement") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_LIST_PREVIOUS, NULL },
- { 0, CMD_LIST_NEXT, NULL },
- { 0, CMD_LIST_PREVIOUS_PAGE, NULL },
- { 0, CMD_LIST_NEXT_PAGE, NULL },
- { 0, CMD_LIST_FIRST, NULL },
- { 0, CMD_LIST_LAST, NULL },
- { 0, CMD_NONE, NULL },
- { 0, CMD_SCREEN_PREVIOUS,NULL },
- { 0, CMD_SCREEN_NEXT, NULL },
- { 0, CMD_SCREEN_HELP, NULL },
- { 0, CMD_SCREEN_PLAY, NULL },
- { 0, CMD_SCREEN_FILE, NULL },
+static help_text_row_t help_text[] = {
+ { 1, CMD_NONE, N_("Keys - Movement") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_LIST_PREVIOUS, NULL },
+ { 0, CMD_LIST_NEXT, NULL },
+ { 0, CMD_LIST_PREVIOUS_PAGE, NULL },
+ { 0, CMD_LIST_NEXT_PAGE, NULL },
+ { 0, CMD_LIST_FIRST, NULL },
+ { 0, CMD_LIST_LAST, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_SCREEN_PREVIOUS,NULL },
+ { 0, CMD_SCREEN_NEXT, NULL },
+ { 0, CMD_SCREEN_HELP, NULL },
+ { 0, CMD_SCREEN_PLAY, NULL },
+ { 0, CMD_SCREEN_FILE, NULL },
#ifdef ENABLE_SEARCH_SCREEN
- { 0, CMD_SCREEN_SEARCH, NULL },
+ { 0, CMD_SCREEN_SEARCH, NULL },
#endif
#ifdef ENABLE_KEYDEF_SCREEN
- { 0, CMD_SCREEN_KEYDEF, NULL },
+ { 0, CMD_SCREEN_KEYDEF, NULL },
#endif
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, N_("Keys - Global") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_STOP, NULL },
- { 0, CMD_PAUSE, NULL },
- { 0, CMD_CROP, NULL },
- { 0, CMD_TRACK_NEXT, NULL },
- { 0, CMD_TRACK_PREVIOUS, NULL },
- { 0, CMD_SEEK_FORWARD, NULL },
- { 0, CMD_SEEK_BACKWARD, NULL },
- { 0, CMD_VOLUME_DOWN, NULL },
- { 0, CMD_VOLUME_UP, NULL },
- { 0, CMD_NONE, NULL },
- { 0, CMD_REPEAT, NULL },
- { 0, CMD_RANDOM, NULL },
- { 0, CMD_CROSSFADE, NULL },
- { 0, CMD_SHUFFLE, NULL },
- { 0, CMD_DB_UPDATE, NULL },
- { 0, CMD_NONE, NULL },
- { 0, CMD_LIST_FIND, NULL },
- { 0, CMD_LIST_RFIND, NULL },
- { 0, CMD_LIST_FIND_NEXT, NULL },
- { 0, CMD_LIST_RFIND_NEXT, NULL },
- { 0, CMD_TOGGLE_FIND_WRAP, NULL },
- { 0, CMD_NONE, NULL },
- { 0, CMD_QUIT, NULL },
-
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, N_("Keys - Playlist screen") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_PLAY, N_("Play") },
- { 0, CMD_DELETE, NULL },
- { 0, CMD_CLEAR, NULL },
- { 1, CMD_LIST_MOVE_UP, N_("Move song up") },
- { 0, CMD_LIST_MOVE_DOWN, N_("Move song down") },
- { 0, CMD_ADD, NULL },
- { 0, CMD_SAVE_PLAYLIST, NULL },
- { 0, CMD_SCREEN_UPDATE, N_("Center") },
- { 0, CMD_TOGGLE_AUTOCENTER, NULL },
-
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, N_("Keys - Browse screen") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_PLAY, N_("Enter directory/Select and play song") },
- { 0, CMD_SELECT, NULL },
- { 0, CMD_ADD, N_("Append song to playlist") },
- { 0, CMD_SAVE_PLAYLIST, NULL },
- { 0, CMD_DELETE, N_("Delete playlist") },
- { 0, CMD_GO_PARENT_DIRECTORY, NULL },
- { 0, CMD_GO_ROOT_DIRECTORY, NULL },
- { 0, CMD_SCREEN_UPDATE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 1, CMD_NONE, N_("Keys - Global") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_STOP, NULL },
+ { 0, CMD_PAUSE, NULL },
+ { 0, CMD_CROP, NULL },
+ { 0, CMD_TRACK_NEXT, NULL },
+ { 0, CMD_TRACK_PREVIOUS, NULL },
+ { 0, CMD_SEEK_FORWARD, NULL },
+ { 0, CMD_SEEK_BACKWARD, NULL },
+ { 0, CMD_VOLUME_DOWN, NULL },
+ { 0, CMD_VOLUME_UP, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_REPEAT, NULL },
+ { 0, CMD_RANDOM, NULL },
+ { 0, CMD_CROSSFADE, NULL },
+ { 0, CMD_SHUFFLE, NULL },
+ { 0, CMD_DB_UPDATE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_LIST_FIND, NULL },
+ { 0, CMD_LIST_RFIND, NULL },
+ { 0, CMD_LIST_FIND_NEXT, NULL },
+ { 0, CMD_LIST_RFIND_NEXT, NULL },
+ { 0, CMD_TOGGLE_FIND_WRAP, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_QUIT, NULL },
+
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 1, CMD_NONE, N_("Keys - Playlist screen") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_PLAY, N_("Play") },
+ { 0, CMD_DELETE, NULL },
+ { 0, CMD_CLEAR, NULL },
+ { 1, CMD_LIST_MOVE_UP, N_("Move song up") },
+ { 0, CMD_LIST_MOVE_DOWN, N_("Move song down") },
+ { 0, CMD_ADD, NULL },
+ { 0, CMD_SAVE_PLAYLIST, NULL },
+ { 0, CMD_SCREEN_UPDATE, N_("Center") },
+ { 0, CMD_TOGGLE_AUTOCENTER, NULL },
+
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 1, CMD_NONE, N_("Keys - Browse screen") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_PLAY, N_("Enter directory/Select and play song") },
+ { 0, CMD_SELECT, NULL },
+ { 0, CMD_ADD, N_("Append song to playlist") },
+ { 0, CMD_SAVE_PLAYLIST, NULL },
+ { 0, CMD_DELETE, N_("Delete playlist") },
+ { 0, CMD_GO_PARENT_DIRECTORY, NULL },
+ { 0, CMD_GO_ROOT_DIRECTORY, NULL },
+ { 0, CMD_SCREEN_UPDATE, NULL },
#ifdef ENABLE_SEARCH_SCREEN
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, N_("Keys - Search screen") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_SCREEN_SEARCH, N_("Search") },
- { 0, CMD_PLAY, N_("Select and play") },
- { 0, CMD_SELECT, NULL },
- { 0, CMD_ADD, N_("Append song to playlist") },
- { 0, CMD_SELECT_ALL, NULL },
- { 0, CMD_SEARCH_MODE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 1, CMD_NONE, N_("Keys - Search screen") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_SCREEN_SEARCH, N_("Search") },
+ { 0, CMD_PLAY, N_("Select and play") },
+ { 0, CMD_SELECT, NULL },
+ { 0, CMD_ADD, N_("Append song to playlist") },
+ { 0, CMD_SELECT_ALL, NULL },
+ { 0, CMD_SEARCH_MODE, NULL },
#endif
#ifdef ENABLE_LYRICS_SCREEN
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, N_("Keys - Lyrics screen") },
- { 2, CMD_NONE, NULL },
- { 0, CMD_SCREEN_LYRICS, N_("View Lyrics") },
- { 0, CMD_SELECT, N_("(Re)load lyrics") },
- { 0, CMD_INTERRUPT, N_("Interrupt retrieval") },
- { 0, CMD_LYRICS_UPDATE, N_("Explicitly download lyrics") },
- { 0, CMD_ADD, N_("Save lyrics") },
+ { 0, CMD_NONE, NULL },
+ { 0, CMD_NONE, NULL },
+ { 1, CMD_NONE, N_("Keys - Lyrics screen") },
+ { 2, CMD_NONE, NULL },
+ { 0, CMD_SCREEN_LYRICS, N_("View Lyrics") },
+ { 0, CMD_SELECT, N_("(Re)load lyrics") },
+ { 0, CMD_INTERRUPT, N_("Interrupt retrieval") },
+ { 0, CMD_LYRICS_UPDATE, N_("Explicitly download lyrics") },
+ { 0, CMD_ADD, N_("Save lyrics") },
#endif
};
#define help_text_rows (sizeof(help_text) / sizeof(help_text[0]))
-static list_window_t *lw = NULL;
-
+static list_window_t *lw;
static const char *
list_callback(unsigned idx, int *highlight, mpd_unused void *data)
diff --git a/src/strfsong.c b/src/strfsong.c
index cef2056c8..ed3e20f98 100644
--- a/src/strfsong.c
+++ b/src/strfsong.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* Based on mpc's songToFormatedString modified for glib and ncmpc
*
*
@@ -33,11 +31,12 @@ skip(const gchar * p)
gint stack = 0;
while (*p != '\0') {
- if(*p == '[') stack++;
- if(*p == '#' && p[1] != '\0') {
+ if (*p == '[')
+ stack++;
+ if (*p == '#' && p[1] != '\0') {
/* skip escaped stuff */
++p;
- } else if(stack) {
+ } else if (stack) {
if(*p == ']') stack--;
} else {
if(*p == '&' || *p == '|' || *p == ']') {
@@ -63,7 +62,7 @@ _strfsong(gchar *s,
gboolean found = FALSE;
memset(s, 0, max);
- if( song==NULL )
+ if (song == NULL)
return 0;
for (p = format; *p != '\0' && length<max;) {
@@ -219,6 +218,6 @@ gsize
strfsong(gchar *s, gsize max, const gchar *format,
const struct mpd_song *song)
{
- return _strfsong(s, max, format, song, NULL);
+ return _strfsong(s, max, format, song, NULL);
}
-
+
diff --git a/src/support.c b/src/support.c
index bfcd07025..8d9d0d010 100644
--- a/src/support.c
+++ b/src/support.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/support.h b/src/support.h
index 9edc20f35..16dd7ae13 100644
--- a/src/support.h
+++ b/src/support.h
@@ -16,4 +16,4 @@ typedef struct {
char *strscroll(char *str, char *separator, int width, scroll_state_t *st);
-#endif
+#endif
diff --git a/src/utils.c b/src/utils.c
index fd7a0645b..cbb696336 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/wreadln.c b/src/wreadln.c
index d01cfcb87..e52d1fd04 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -1,6 +1,4 @@
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/wreadln.h b/src/wreadln.h
index 2dd2191f0..9ce6ae404 100644
--- a/src/wreadln.h
+++ b/src/wreadln.h
@@ -26,14 +26,14 @@ typedef void (*wrln_gcmp_post_cb_t) (GCompletion *gcmp, gchar *s, GList *l,
void *data);
extern wrln_gcmp_post_cb_t wrln_post_completion_callback;
-/* Note, wreadln calls curs_set() and noecho(), to enable cursor and
+/* Note, wreadln calls curs_set() and noecho(), to enable cursor and
* disable echo. wreadln will not restore these settings when exiting! */
gchar *wreadln(WINDOW *w, /* the curses window to use */
const gchar *prompt, /* the prompt string or NULL */
const gchar *initial_value, /* initial value or NULL for a empty line
- * (char *) -1 = get value from history */
+ * (char *) -1 = get value from history */
gint x1, /* the maximum x position or 0 */
- GList **history, /* a pointer to a history list or NULL */
+ GList **history, /* a pointer to a history list or NULL */
GCompletion *gcmp /* a GCompletion structure or NULL */
);