Code

fix function prototypes
[ncmpc.git] / src / command.c
index c256d0c5ce73cab035d1737b31aa93a4707dfa05..733bf6a314567d26a04b78a4c84e26848b1f5640 100644 (file)
@@ -30,6 +30,8 @@
 #include "config.h"
 #include "ncmpc.h"
 #include "command.h"
+#include "mpdclient.h"
+#include "screen.h"
 
 #undef DEBUG_KEYS
 
@@ -39,9 +41,6 @@
 #define DK(x)
 #endif
 
-extern void sigstop(void);
-extern void screen_resize(void);
-
 #define BS   KEY_BACKSPACE
 #define DEL  KEY_DC
 #define UP   KEY_UP
@@ -61,6 +60,7 @@ extern void screen_resize(void);
 #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[] =
@@ -117,6 +117,8 @@ static command_definition_t cmds[] =
     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",
@@ -136,6 +138,10 @@ static command_definition_t cmds[] =
   { { '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", 
@@ -172,10 +178,30 @@ static command_definition_t cmds[] =
 
 
   /* extra screens */
+#ifdef ENABLE_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") },
+#endif
+
 #ifdef ENABLE_CLOCK_SCREEN
-  { {'4',  F4,   0 }, 0, CMD_SCREEN_CLOCK,    "screen-clock",
+  { {'6',  F6,   0 }, 0, CMD_SCREEN_CLOCK,    "screen-clock",
     N_("Clock screen") },
 #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") },
+#endif
+
 
   { { -1,  -1,  -1 }, 0, CMD_NONE, NULL, NULL }
 };
@@ -186,7 +212,7 @@ get_command_definitions(void)
   return cmds;
 }
 
-char *
+const char *
 key2str(int key)
 {
   static char buf[32];
@@ -233,17 +259,17 @@ key2str(int key)
       for(i=0; i<=63; i++)
        if( key==KEY_F(i) )
          {
-           snprintf(buf, 32, "F%d", i );
+           g_snprintf(buf, 32, "F%d", i );
            return buf;
          }
       if( !(key & ~037) )
-       snprintf(buf, 32, "Ctrl-%c", 'A'+(key & 037)-1 );
+       g_snprintf(buf, 32, "Ctrl-%c", 'A'+(key & 037)-1 );
       else if( (key & ~037) == 224 )
-       snprintf(buf, 32, "Alt-%c", 'A'+(key & 037)-1 );
+       g_snprintf(buf, 32, "Alt-%c", 'A'+(key & 037)-1 );
       else if( key>32 &&  key<256 )
-       snprintf(buf, 32, "%c", key);
+       g_snprintf(buf, 32, "%c", key);
       else
-       snprintf(buf, 32, "0x%03X", key);
+       g_snprintf(buf, 32, "0x%03X", key);
     }
   return buf;
 }
@@ -262,7 +288,7 @@ command_dump_keys(void)
     }
 }
 
-int
+static int
 set_key_flags(command_definition_t *cp, command_t command, int flags)
 {
   int i;
@@ -280,7 +306,7 @@ set_key_flags(command_definition_t *cp, command_t command, int flags)
   return 1;
 }
 
-char *
+const char *
 get_key_names(command_t command, int all)
 {
   int i;
@@ -293,14 +319,14 @@ get_key_names(command_t command, int all)
          int j;
          static char keystr[80];
 
-         strncpy(keystr, key2str(cmds[i].keys[0]), 80);
+         g_strlcpy(keystr, key2str(cmds[i].keys[0]), sizeof(keystr));
          if( !all )
            return keystr;
          j=1;
          while( j<MAX_COMMAND_KEYS && cmds[i].keys[j]>0 )
            {
-             strcat(keystr, " ");
-             strcat(keystr, key2str(cmds[i].keys[j]));
+             g_strlcat(keystr, " ", sizeof(keystr));
+             g_strlcat(keystr, key2str(cmds[i].keys[j]), sizeof(keystr));
              j++;
            }
          return keystr;
@@ -310,7 +336,7 @@ get_key_names(command_t command, int all)
   return NULL;
 }
 
-char *
+const char *
 get_key_description(command_t command)
 {
   int i;
@@ -325,7 +351,7 @@ get_key_description(command_t command)
   return NULL;
 }
 
-char *
+const char *
 get_key_command_name(command_t command)
 {
   int i;
@@ -356,21 +382,21 @@ get_key_command_from_name(char *name)
 }
 
 
-command_t 
+command_t
 find_key_command(int key, command_definition_t *cmds)
 {
-  int i;
+       int i;
+
+       i=0;
+       while (key && cmds && cmds[i].name) {
+               if (cmds[i].keys[0] == key ||
+                   cmds[i].keys[1] == key ||
+                   cmds[i].keys[2] == key)
+                       return cmds[i].command;
+               i++;
+       }
 
-  i=0;
-  while( cmds && cmds[i].name )
-    {
-      if( cmds[i].keys[0] == key || 
-         cmds[i].keys[1] == key ||
-         cmds[i].keys[2] == key )
-       return cmds[i].command;
-      i++;
-    }
-  return CMD_NONE;
+       return CMD_NONE;
 }
 
 command_t 
@@ -477,14 +503,14 @@ check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
          {
            if( buf )
 #ifdef ENABLE_KEYDEF_SCREEN
-             snprintf(buf, bufsize,
-                      _("Key %s assigned to %s and %s (press %s for the key editor)"),
-                      key2str(cp[i].keys[j]),
-                      get_key_command_name(cp[i].command),
-                      get_key_command_name(cmd),
-                      get_key_names(CMD_SCREEN_KEYDEF,0));
+             g_snprintf(buf, bufsize,
+                        _("Key %s assigned to %s and %s (press %s for the key editor)"),
+                        key2str(cp[i].keys[j]),
+                        get_key_command_name(cp[i].command),
+                        get_key_command_name(cmd),
+                        get_key_names(CMD_SCREEN_KEYDEF,0));
 #else
-           snprintf(buf, bufsize,
+           g_snprintf(buf, bufsize,
                       _("Error: Key %s assigned to %s and %s !!!\n"),
                       key2str(cp[i].keys[j]),
                       get_key_command_name(cp[i].command),