Code

code style, indent with tabs XI
authorMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 10:57:30 +0000 (12:57 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 3 Oct 2008 10:57:30 +0000 (12:57 +0200)
Follow the same code style als MPD itself.

19 files changed:
src/colors.c
src/colors.h
src/command.c
src/command.h
src/conf.c
src/list_window.c
src/main.c
src/options.c
src/playlist.c
src/playlist.h
src/screen.c
src/screen_browser.h
src/screen_help.c
src/strfsong.c
src/support.c
src/support.h
src/utils.c
src/wreadln.c
src/wreadln.h

index 67f3319ca32a1d0ad3d970d8758532b45573248d..507be48cac88d547dce892a499c50874ccbd68c1 100644 (file)
@@ -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
 #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;
+}
index a913021a180fd59ffd7bb113c3cfb4d92617687e..f8a22d2f4c1f380a718bab6f2bd055789c6bf182 100644 (file)
@@ -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 */
-
-
-
index 71ae50e7df970e0985806e6d6d03872d223388b6..af188d19ab0521670702b0c86694eb050b59fc3d 100644 (file)
@@ -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
 #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) {
index f4b6859e84cf93757cee869b4d8a8758ddef4d2e..4529da824e66b580faacf0427dd869210cb3d257 100644 (file)
@@ -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);
index a39c49317a2397ec80cd92a04d603b823fa042bf..5dff1ccdfd798e8555aca5abc672086ccef29307 100644 (file)
@@ -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
 #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;
 }
index 55b621b4a7fffa7ce9e8b855f03737387b956ba4..efb610117231d92812c8654b7234ebcb54ad0484 100644 (file)
@@ -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
index 668d5aa3350a197feccaeb7ea488e08d4f9db9eb..e701712fd871974057e43ee5d8842a580df4e019 100644 (file)
@@ -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
index 9cb1b1685b2bb9188903ba466ee7ee7b4d065feb..ca3e983b3493a315530f878b15b5876ba01b2fda 100644 (file)
@@ -306,7 +306,7 @@ options_parse(int argc, const char *argv[])
 }
 
 options_t *
-options_init( void )
+options_init(void)
 {
        const char *value;
        char *tmp;
index 108c4f51a343039b624c8ddf2476f4566784546e..19a1b419cc08f8ac8f08cce603d647c73bae9606 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * (c) 2004 by Kalle Wallin <kaw@linux.se>
  * (c) 2008 Max Kellermann <max@duempel.org>
  *
index 0d524adbee9f98473c541bce2d52a4b017175ece..6597357d3ef438f546686efee6558e21762cc9aa 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * (c) 2004 by Kalle Wallin <kaw@linux.se>
  * (c) 2008 Max Kellermann <max@duempel.org>
  *
index 87d7388254c8ddb8daa1463002749e325aee3e8f..231d84adad1aab40a86884c312aaf3924de4cbf9 100644 (file)
@@ -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
index cd218bc48dc23e51e1633fe291cf6d9be67af66f..17e41f6ec06094bce455693c90ce88cf5af179c6 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * (c) 2004 by Kalle Wallin <kaw@linux.se>
  * Copyright (C) 2008 Max Kellermann <max@duempel.org>
  *
index 700bc8b65a25cbff90b9edd63c14ec1aec7d3e63..adf9a03102fe805c194b2cc1e418f399b444aa57 100644 (file)
 #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)
index cef2056c8b89b9d5e6bb49d85921f0d677ae6b7e..ed3e20f9807ad56fa1c91621a1f551dfd96f879f 100644 (file)
@@ -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);
 }
-     
+
index bfcd070258cafd5aadf45fff8caa889b4f331a1a..8d9d0d01079fa61b8069d14f9f074911f1ebccc3 100644 (file)
@@ -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
index 9edc20f351b4b85061b322103b0e02bc8a75be7f..16dd7ae13c96d5b782ec87b1abc5b7097e5203ec 100644 (file)
@@ -16,4 +16,4 @@ typedef struct {
 
 char *strscroll(char *str, char *separator, int width, scroll_state_t *st);
 
-#endif 
+#endif
index fd7a0645b249b61865ee0e3b764e03fd1af5ab64..cbb6963366573f6d0f51aeedbf9bd5ef9d588d17 100644 (file)
@@ -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
index d01cfcb87c8517544c930cc5a86b9b8ba1440af2..e52d1fd04c83290f9a631127f18b0a95965db8ca 100644 (file)
@@ -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
index 2dd2191f050dedd164d554a8d83047a7c28c2519..9ce6ae4043390aeec2c7a5c71ba2b3c32cea5c09 100644 (file)
@@ -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 */
               );