diff --git a/src/command.c b/src/command.c
index e04817fa1e08625579ec3880962210bb3ecb0ac9..f323b12c457e189f5f6f99dad5ed85ab467a3a2f 100644 (file)
--- a/src/command.c
+++ b/src/command.c
-/*
- * (c) 2004 by Kalle Wallin <kaw@linux.se>
- *
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2010 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
#include "command.h"
#include "config.h"
#define F5 KEY_F(5)
#define F6 KEY_F(6)
#define F7 KEY_F(7)
+#define F8 KEY_F(8)
static command_definition_t cmds[] = {
{ { 'q', 'Q', 3 }, 0, CMD_QUIT, "quit",
N_("Quit") },
- /* movment */
+ /* movement */
{ { UP, 'k', 0 }, 0, CMD_LIST_PREVIOUS, "up",
N_("Move cursor up") },
{ { DWN, 'j', 0 }, 0, CMD_LIST_NEXT, "down",
N_("Move cursor down") },
+ { { 'H', 0, 0 }, 0, CMD_LIST_TOP, "top",
+ N_("Move cursor to the top of screen") },
+ { { 'M', 0, 0 }, 0, CMD_LIST_MIDDLE, "middle",
+ N_("Move cursor to the middle of screen") },
+ { { 'L', 0, 0 }, 0, CMD_LIST_BOTTOM, "bottom",
+ N_("Move cursor to the bottom of screen") },
{ { HOME, 0x01, 0 }, 0, CMD_LIST_FIRST, "home",
- N_("Home ") },
+ N_("Move cursor to the top of the list") },
{ { END, 0x05, 0 }, 0, CMD_LIST_LAST, "end",
- N_("End ") },
+ N_("Move cursor to the bottom of the list") },
{ { PGUP, 0, 0 }, 0, CMD_LIST_PREVIOUS_PAGE, "pgup",
N_("Page up") },
{ { PGDN, 0, 0 }, 0, CMD_LIST_NEXT_PAGE, "pgdn",
N_("Page down") },
+ { { 'v', 0, 0 }, 0, CMD_LIST_RANGE_SELECT, "range-select",
+ N_("Range selection") },
+ { { 14, 0, 0 }, 0, CMD_LIST_SCROLL_DOWN_LINE, "scroll-down-line",
+ N_("Scroll up one line") },
+ { { 2, 0, 0 }, 0, CMD_LIST_SCROLL_UP_LINE, "scroll-up-line",
+ N_("Scroll down one line") },
+ { { 'N', 0, 0 }, 0, CMD_LIST_SCROLL_DOWN_HALF, "scroll-down-half",
+ N_("Scroll up half a screen") },
+ { { 'B', 0, 0 }, 0, CMD_LIST_SCROLL_UP_HALF, "scroll-up-half",
+ N_("Scroll down half a screen") },
+ { { 'l', 0, 0 }, 0, CMD_SELECT_PLAYING, "select-playing",
+ N_("Select currently playing song") },
/* basic screens */
N_("Toggle repeat mode") },
{ { 'z', 0, 0 }, 0, CMD_RANDOM, "random",
N_("Toggle random mode") },
+ { { 'y', 0, 0 }, 0, CMD_SINGLE, "single",
+ N_("Toggle single mode") },
+ { { 'C', 0, 0 }, 0, CMD_CONSUME, "consume",
+ N_("Toggle consume mode") },
{ { 'x', 0, 0 }, 0, CMD_CROSSFADE, "crossfade",
N_("Toggle crossfade mode") },
{ { 21, 0, 0 }, 0, CMD_DB_UPDATE, "db-update",
{ { '"', 0, 0 }, 0, CMD_GO_PARENT_DIRECTORY, "go-parent-directory",
N_("Go to parent directory") },
-#ifdef ENABLE_SONG_SCREEN
- { { 'i', 0, 0 }, 0, CMD_VIEW, "view",
- N_("View the song") },
-#endif
-
{ { 'G', 0, 0 }, 0, CMD_LOCATE, "locate",
N_("Locate song in browser") },
{ { 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") },
+ N_("Refresh screen") },
/* ncmpc options */
{ { 'w', 0, 0 }, 0, CMD_TOGGLE_FIND_WRAP, "wrap-mode",
+ /* translators: toggle between wrapping and non-wrapping
+ search */
N_("Toggle find mode") },
{ { 'U', 0, 0 }, 0, CMD_TOGGLE_AUTOCENTER, "autocenter-mode",
+ /* translators: the auto center mode always centers the song
+ currently being played */
N_("Toggle auto center mode") },
N_("Next screen") },
{ { STAB, 0, 0 }, 0, CMD_SCREEN_PREVIOUS, "screen-prev",
N_("Previous screen") },
+ { { '`', 0, 0 }, 0, CMD_SCREEN_SWAP, "screen-swap",
+ N_("Swap to most recent screen") },
/* find */
N_("Backward find") },
{ { 'p', 0, 0 }, 0, CMD_LIST_RFIND_NEXT, "rfind-next",
N_("Backward find previous") },
+ { { '.', 0, 0 }, 0, CMD_LIST_JUMP, "jump",
+ /* translators: this queries the user for a string
+ * and jumps directly (while the user is typing)
+ * to the entry which begins with this string */
+ N_("Jump to") },
/* extra screens */
{ {'m', 0, 0 }, 0, CMD_SEARCH_MODE, "search-mode",
N_("Change search mode") },
#endif
-
+#ifdef ENABLE_SONG_SCREEN
+ { { 'i', 0, 0 }, 0, CMD_SCREEN_SONG, "view",
+ N_("View the selected and the currently playing song") },
+#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",
+ /* translators: interrupt the current background action,
+ e.g. stop loading lyrics from the internet */
N_("Interrupt action") },
{ {'u', 0, 0 }, 0, CMD_LYRICS_UPDATE, "lyrics-update",
N_("Update Lyrics") },
#endif
+#ifdef ENABLE_OUTPUTS_SCREEN
+ { {'8', F8, 0 }, 0, CMD_SCREEN_OUTPUTS, "screen-outputs",
+ N_("Outputs screen") },
+#endif
+
+
{ { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL }
};
void
command_dump_keys(void)
{
- int i;
+ int i = 0;
- i = 0;
while (cmds[i].description) {
if (cmds[i].command != CMD_NONE)
printf(" %20s : %s\n", get_key_names(cmds[i].command,1),cmds[i].name);
}
}
+#ifndef NCMPC_MINI
+
static int
set_key_flags(command_definition_t *cp, command_t command, int flags)
{
- int i;
+ int i = 0;
- i = 0;
while (cp[i].name) {
if (cp[i].command == command) {
cp[i].flags |= flags;
return 1;
}
+#endif
+
const char *
get_key_names(command_t command, int all)
{
- int i;
-
- i=0;
- while (cmds[i].description) {
- if (cmds[i].command == command) {
- int j;
- static char keystr[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) {
- g_strlcat(keystr, " ", sizeof(keystr));
- g_strlcat(keystr, key2str(cmds[i].keys[j]), sizeof(keystr));
- j++;
- }
- return keystr;
- }
- i++;
- }
- return NULL;
+ int i = 0;
+
+ while (cmds[i].description) {
+ if (cmds[i].command == command) {
+ int j;
+ static char keystr[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) {
+ g_strlcat(keystr, " ", sizeof(keystr));
+ g_strlcat(keystr, key2str(cmds[i].keys[j]), sizeof(keystr));
+ j++;
+ }
+ return keystr;
+ }
+ i++;
+ }
+ return NULL;
}
const char *
get_key_description(command_t command)
{
- int i;
+ int i = 0;
- i=0;
while (cmds[i].description) {
if (cmds[i].command == command)
return _(cmds[i].description);
const char *
get_key_command_name(command_t command)
{
- int i;
+ int i = 0;
- i=0;
while (cmds[i].name) {
if (cmds[i].command == command)
return cmds[i].name;
command_t
get_key_command_from_name(char *name)
{
- int i;
+ int i = 0;
- i=0;
while (cmds[i].name) {
if (strcmp(name, cmds[i].name) == 0)
return cmds[i].command;
command_t
find_key_command(int key, command_definition_t *c)
{
- int i;
+ int i = 0;
- i=0;
while (key && c && c[i].name) {
if (c[i].keys[0] == key ||
c[i].keys[1] == key ||
int
assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
{
- int i;
+ int i = 0;
- i=0;
while (cmds[i].name) {
if (cmds[i].command == command) {
memcpy(cmds[i].keys, keys, sizeof(int)*MAX_COMMAND_KEYS);
+#ifndef NCMPC_MINI
cmds[i].flags |= COMMAND_KEY_MODIFIED;
+#endif
return 0;
}
i++;
return -1;
}
+#ifndef NCMPC_MINI
+
int
check_key_bindings(command_definition_t *cp, char *buf, size_t bufsize)
{
- int i;
+ int i = 0;
int retval = 0;
if (cp == NULL)
cp = cmds;
- i=0;
while (cp[i].name) {
cp[i].flags &= ~COMMAND_KEY_CONFLICT;
i++;
}
- i=0;
+ i = 0;
while (cp[i].name) {
int j;
command_t cmd;
if (cp[i].keys[j] &&
(cmd = find_key_command(cp[i].keys[j],cp)) != cp[i].command) {
if (buf) {
-#ifdef ENABLE_KEYDEF_SCREEN
- 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
g_snprintf(buf, bufsize,
- _("Error: Key %s assigned to %s and %s\n"),
+ _("Key %s assigned to %s and %s"),
key2str(cp[i].keys[j]),
get_key_command_name(cp[i].command),
get_key_command_name(cmd));
-#endif
- } else
+ } else {
fprintf(stderr,
- _("Error: Key %s assigned to %s and %s\n"),
+ _("Key %s assigned to %s and %s"),
key2str(cp[i].keys[j]),
get_key_command_name(cp[i].command),
get_key_command_name(cmd));
+ fputc('\n', stderr);
+ }
cp[i].flags |= COMMAND_KEY_CONFLICT;
set_key_flags(cp, cmd, COMMAND_KEY_CONFLICT);
retval = -1;
int
write_key_bindings(FILE *f, int flags)
{
- int i,j;
+ int i = 0, j;
if (flags & KEYDEF_WRITE_HEADER)
fprintf(f, "## Key bindings for ncmpc (generated by ncmpc)\n\n");
- i = 0;
while (cmds[i].name && !ferror(f)) {
if (cmds[i].flags & COMMAND_KEY_MODIFIED ||
flags & KEYDEF_WRITE_ALL) {
return ferror(f);
}
+
+#endif