1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2010 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #ifndef COMMAND_H
21 #define COMMAND_H
23 #include "config.h"
25 #include <stddef.h>
27 #ifndef NCMPC_MINI
28 #include <stdio.h>
29 #endif
31 #define MAX_COMMAND_KEYS 3
33 /* commands */
34 typedef enum {
35 CMD_NONE = 0,
36 CMD_PLAY,
37 CMD_SELECT,
38 CMD_SELECT_ALL,
39 CMD_PAUSE,
40 CMD_STOP,
41 CMD_CROP,
42 CMD_TRACK_NEXT,
43 CMD_TRACK_PREVIOUS,
44 CMD_SEEK_FORWARD,
45 CMD_SEEK_BACKWARD,
46 CMD_SHUFFLE,
47 CMD_RANDOM,
48 CMD_CLEAR,
49 CMD_DELETE,
50 CMD_REPEAT,
51 CMD_SINGLE,
52 CMD_CONSUME,
53 CMD_CROSSFADE,
54 CMD_DB_UPDATE,
55 CMD_VOLUME_UP,
56 CMD_VOLUME_DOWN,
57 CMD_ADD,
58 CMD_SAVE_PLAYLIST,
59 CMD_TOGGLE_FIND_WRAP,
60 CMD_TOGGLE_AUTOCENTER,
61 CMD_SELECT_PLAYING,
62 CMD_SEARCH_MODE,
63 CMD_LIST_PREVIOUS,
64 CMD_LIST_NEXT,
65 CMD_LIST_TOP,
66 CMD_LIST_MIDDLE,
67 CMD_LIST_BOTTOM,
68 CMD_LIST_FIRST,
69 CMD_LIST_LAST,
70 CMD_LIST_NEXT_PAGE,
71 CMD_LIST_PREVIOUS_PAGE,
72 CMD_LIST_FIND,
73 CMD_LIST_FIND_NEXT,
74 CMD_LIST_RFIND,
75 CMD_LIST_RFIND_NEXT,
76 CMD_LIST_JUMP,
77 CMD_LIST_MOVE_UP,
78 CMD_LIST_MOVE_DOWN,
79 CMD_LIST_RANGE_SELECT,
80 CMD_LIST_SCROLL_UP_LINE,
81 CMD_LIST_SCROLL_DOWN_LINE,
82 CMD_LIST_SCROLL_UP_HALF,
83 CMD_LIST_SCROLL_DOWN_HALF,
84 CMD_MOUSE_EVENT,
85 CMD_SCREEN_UPDATE,
86 CMD_SCREEN_PREVIOUS,
87 CMD_SCREEN_NEXT,
88 CMD_SCREEN_SWAP,
89 CMD_SCREEN_PLAY,
90 CMD_SCREEN_FILE,
91 CMD_SCREEN_ARTIST,
92 CMD_SCREEN_SEARCH,
93 CMD_SCREEN_SONG,
94 CMD_SCREEN_KEYDEF,
95 CMD_SCREEN_HELP,
96 CMD_SCREEN_LYRICS,
97 CMD_SCREEN_OUTPUTS,
98 CMD_LYRICS_UPDATE,
99 CMD_INTERRUPT,
100 CMD_GO_ROOT_DIRECTORY,
101 CMD_GO_PARENT_DIRECTORY,
102 CMD_LOCATE,
103 CMD_QUIT
104 } command_t;
107 #ifndef NCMPC_MINI
108 /* command definition flags */
109 #define COMMAND_KEY_MODIFIED 0x01
110 #define COMMAND_KEY_CONFLICT 0x02
111 #endif
113 /* write key bindings flags */
114 #define KEYDEF_WRITE_HEADER 0x01
115 #define KEYDEF_WRITE_ALL 0x02
116 #define KEYDEF_COMMENT_ALL 0x04
118 typedef struct {
119 int keys[MAX_COMMAND_KEYS];
120 char flags;
121 command_t command;
122 const char *name;
123 const char *description;
124 } command_definition_t;
126 #ifdef ENABLE_KEYDEF_SCREEN
127 command_definition_t *get_command_definitions(void);
128 #endif
130 command_t find_key_command(int key, command_definition_t *cmds);
132 void command_dump_keys(void);
134 #ifndef NCMPC_MINI
136 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
137 int write_key_bindings(FILE *f, int all);
139 #endif
141 const char *key2str(int key);
142 const char *get_key_description(command_t command);
143 const char *get_key_command_name(command_t command);
144 const char *get_key_names(command_t command, int all);
145 command_t get_key_command(int key);
146 command_t get_key_command_from_name(char *name);
147 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
149 command_t get_keyboard_command(void);
151 #endif