aboutsummaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-04-19 22:10:13 +0000
committerKalle Wallin <kaw@linux.se>2004-04-19 22:10:13 +0000
commit230b0fe73ac3a07293d495e895207b43cdfb3369 (patch)
treed24f5d8f3155948e13800ee3369808279b23a92b /command.c
parentbf28b56f26bb5753c706e2e249265f95b500fd78 (diff)
downloadmpd-230b0fe73ac3a07293d495e895207b43cdfb3369.tar.gz
mpd-230b0fe73ac3a07293d495e895207b43cdfb3369.tar.xz
mpd-230b0fe73ac3a07293d495e895207b43cdfb3369.zip
Added copyright notice and license notice
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@833 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--command.c68
1 files changed, 50 insertions, 18 deletions
diff --git a/command.c b/command.c
index 15ebd502a..75dd75ee9 100644
--- a/command.c
+++ b/command.c
@@ -1,3 +1,21 @@
+/*
+ * (c) 2004 by Kalle Wallin (kaw@linux.se)
+ *
+ * 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
+ *
+ */
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -80,9 +98,9 @@ static command_definition_t cmds[] =
{ { DWN, '.', 0 }, CMD_LIST_NEXT, "down",
"Move cursor down" },
{ { HOME, 0x01, 0 }, CMD_LIST_FIRST, "home",
- "Home" },
+ "Home " },
{ { END, 0x05, 0 }, CMD_LIST_LAST, "end",
- "End" },
+ "End " },
{ { PGUP, 'A', 0 }, CMD_LIST_PREVIOUS_PAGE, "pgup",
"Page up" },
{ { PGDN, 'B', 0 }, CMD_LIST_NEXT_PAGE, "pgdn",
@@ -111,6 +129,10 @@ static command_definition_t cmds[] =
"Browse screen" },
{ {'u', 0, 0 }, CMD_SCREEN_UPDATE, "update",
"Update screen" },
+#ifdef ENABLE_KEYDEF_SCREEN
+ { {'K', 0, 0 }, CMD_SCREEN_KEYDEF, "screen-keyedit",
+ "Key edit screen" },
+#endif
{ { 'q', 0, 0 }, CMD_QUIT, "quit",
"Quit " PACKAGE },
@@ -118,10 +140,17 @@ static command_definition_t cmds[] =
{ { -1, -1, -1 }, CMD_NONE, NULL, NULL }
};
+command_definition_t *
+get_command_definitions(void)
+{
+ return cmds;
+}
+
char *
key2str(int key)
{
- static char buf[2];
+ static char buf[4];
+ int i;
buf[0] = 0;
switch(key)
@@ -158,20 +187,16 @@ key2str(int key)
return "Shift+Tab";
case ESC:
return "Esc";
- case F1:
- return "F1";
- case F2:
- return "F2";
- case F3:
- return "F3";
- case F4:
- return "F4";
- case F5:
- return "F5";
- case F6:
- return "F6";
+ case KEY_IC:
+ return "Insert";
default:
- snprintf(buf, 2, "%c", key);
+ for(i=0; i<=63; i++)
+ if( key==KEY_F(i) )
+ {
+ snprintf(buf, 4, "F%d", i );
+ return buf;
+ }
+ snprintf(buf, 4, "%c", key);
}
return buf;
}
@@ -265,13 +290,14 @@ get_key_command_from_name(char *name)
return CMD_NONE;
}
+
command_t
-get_key_command(int key)
+find_key_command(int key, command_definition_t *cmds)
{
int i;
i=0;
- while( cmds[i].name )
+ while( cmds && cmds[i].name )
{
if( cmds[i].keys[0] == key ||
cmds[i].keys[1] == key ||
@@ -282,6 +308,12 @@ get_key_command(int key)
return CMD_NONE;
}
+command_t
+get_key_command(int key)
+{
+ return find_key_command(key, cmds);
+}
+
command_t
get_keyboard_command(void)