diff --git a/src/command.c b/src/command.c
index af6afd15a01ee7e93ab01a31e72cfa6a4f301e2d..5621b165650b34fd2197b846755ee3c3967ef242 100644 (file)
--- a/src/command.c
+++ b/src/command.c
#include <signal.h>
#include <unistd.h>
-#undef DEBUG_KEYS
-
-#ifdef DEBUG_KEYS
-#define DK(x) x
-#else
-#define DK(x)
-#endif
-
#define KEY_CTL(x) ((x) & 0x1f) /* KEY_CTL(A) == ^A == \1 */
#define BS KEY_BACKSPACE
#define F6 KEY_F(6)
#define F7 KEY_F(7)
#define F8 KEY_F(8)
+#define F9 KEY_F(9)
#define C(x) KEY_CTL(x)
static command_definition_t cmds[] = {
{ { '1', F1, 'h' }, 0, CMD_SCREEN_HELP, "screen-help",
N_("Help screen") },
{ { '2', F2, 0 }, 0, CMD_SCREEN_PLAY, "screen-playlist",
- N_("Playlist screen") },
+ N_("Queue screen") },
{ { '3', F3, 0 }, 0, CMD_SCREEN_FILE, "screen-browse",
N_("Browse screen") },
{ { '-', LEFT, 0 }, 0, CMD_VOLUME_DOWN, "volume-down",
N_("Decrease volume") },
{ { ' ', 0, 0 }, 0, CMD_SELECT, "select",
- N_("Select/deselect song in playlist") },
+ N_("Select/deselect song in queue") },
{ { '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") },
+ N_("Delete song from queue") },
{ { 'Z', 0, 0 }, 0, CMD_SHUFFLE, "shuffle",
- N_("Shuffle playlist") },
+ N_("Shuffle queue") },
{ { 'c', 0, 0 }, 0, CMD_CLEAR, "clear",
- N_("Clear playlist") },
+ N_("Clear queue") },
{ { 'r', 0, 0 }, 0, CMD_REPEAT, "repeat",
N_("Toggle repeat mode") },
{ { 'z', 0, 0 }, 0, CMD_RANDOM, "random",
{ { C('U'), 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") },
+ N_("Save queue") },
{ { 'a', 0, 0 }, 0, CMD_ADD, "add",
- N_("Add url/file to playlist") },
+ N_("Add url/file to queue") },
{ { '!', 0, 0 }, 0, CMD_GO_ROOT_DIRECTORY, "go-root-directory",
N_("Go to root directory") },
N_("Interrupt action") },
{ {'u', 0, 0 }, 0, CMD_LYRICS_UPDATE, "lyrics-update",
N_("Update Lyrics") },
- { {'e', 0, 0 }, 0, CMD_LYRICS_EDIT, "lyrics-edit",
- N_("Edit Lyrics") },
+ /* this command may move out of #ifdef ENABLE_LYRICS_SCREEN
+ at some point */
+ { {'e', 0, 0 }, 0, CMD_EDIT, "edit",
+ N_("Edit the current item") },
#endif
#ifdef ENABLE_OUTPUTS_SCREEN
N_("Outputs screen") },
#endif
+#ifdef ENABLE_CHAT_SCREEN
+ { {'9', F9, 0}, 0, CMD_SCREEN_CHAT, "screen-chat",
+ N_("Chat screen") },
+#endif
{ { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL }
};
{
return cmds;
}
+
+size_t
+get_cmds_max_name_width(command_definition_t *c)
+{
+ static size_t max = 0;
+
+ if (max != 0)
+ return max;
+
+ size_t len;
+ command_definition_t *p;
+
+ for (p = c; p->name != NULL; p++) {
+ /*
+ * width and length are considered the same here, as command
+ * names are not translated.
+ */
+ len = (size_t) strlen(p->name);
+ if (len > max)
+ max = len;
+ }
+
+ return max;
+}
#endif
const char *
{
for (int i = 0; cmds[i].description; i++)
if (cmds[i].command != CMD_NONE)
- printf(" %20s : %s\n", get_key_names(cmds[i].command,1),cmds[i].name);
+ printf(" %20s : %s\n",
+ get_key_names(cmds[i].command, true),
+ cmds[i].name);
}
#ifndef NCMPC_MINI
-static int
+static void
set_key_flags(command_definition_t *cp, command_t command, int flags)
{
for (int i = 0; cp[i].name; i++) {
if (cp[i].command == command) {
cp[i].flags |= flags;
- return 0;
+ break;
}
}
-
- return 1;
}
#endif
const char *
-get_key_names(command_t command, int all)
+get_key_names(command_t command, bool all)
{
for (int i = 0; cmds[i].description; i++) {
if (cmds[i].command == command) {
}
command_t
-get_key_command_from_name(char *name)
+get_key_command_from_name(const char *name)
{
for (int i = 0; cmds[i].name; i++)
if (strcmp(name, cmds[i].name) == 0)
}
command_t
-find_key_command(int key, command_definition_t *c)
+find_key_command(int key, const command_definition_t *c)
{
assert(key != 0);
assert(c != NULL);
for (int i = 0; c[i].name; i++) {
- if (c[i].keys[0] == key ||
- c[i].keys[1] == key ||
- c[i].keys[2] == key)
- return c[i].command;
+ for (int j = 0; j < MAX_COMMAND_KEYS; j++)
+ if (c[i].keys[j] == key)
+ return c[i].command;
}
return CMD_NONE;
int key;
key = wgetch(stdscr);
- if (key == ERR)
+ if (key == ERR || key == '\0')
return CMD_NONE;
#ifdef HAVE_GETMOUSE
return ferror(f);
}
-#endif
+#endif /* NCMPC_MINI */