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>
26 #include <stdbool.h>
28 #ifndef NCMPC_MINI
29 #include <stdio.h>
30 #endif
32 #define MAX_COMMAND_KEYS 3
34 /* commands */
35 typedef enum {
36 CMD_NONE = 0,
37 CMD_PLAY,
38 CMD_SELECT,
39 CMD_SELECT_ALL,
40 CMD_PAUSE,
41 CMD_STOP,
42 CMD_CROP,
43 CMD_TRACK_NEXT,
44 CMD_TRACK_PREVIOUS,
45 CMD_SEEK_FORWARD,
46 CMD_SEEK_BACKWARD,
47 CMD_SHUFFLE,
48 CMD_RANDOM,
49 CMD_CLEAR,
50 CMD_DELETE,
51 CMD_REPEAT,
52 CMD_SINGLE,
53 CMD_CONSUME,
54 CMD_CROSSFADE,
55 CMD_DB_UPDATE,
56 CMD_VOLUME_UP,
57 CMD_VOLUME_DOWN,
58 CMD_ADD,
59 CMD_SAVE_PLAYLIST,
60 CMD_TOGGLE_FIND_WRAP,
61 CMD_TOGGLE_AUTOCENTER,
62 CMD_SELECT_PLAYING,
63 CMD_SEARCH_MODE,
64 CMD_LIST_PREVIOUS,
65 CMD_LIST_NEXT,
66 CMD_LIST_TOP,
67 CMD_LIST_MIDDLE,
68 CMD_LIST_BOTTOM,
69 CMD_LIST_FIRST,
70 CMD_LIST_LAST,
71 CMD_LIST_NEXT_PAGE,
72 CMD_LIST_PREVIOUS_PAGE,
73 CMD_LIST_FIND,
74 CMD_LIST_FIND_NEXT,
75 CMD_LIST_RFIND,
76 CMD_LIST_RFIND_NEXT,
77 CMD_LIST_JUMP,
78 CMD_LIST_MOVE_UP,
79 CMD_LIST_MOVE_DOWN,
80 CMD_LIST_RANGE_SELECT,
81 CMD_LIST_SCROLL_UP_LINE,
82 CMD_LIST_SCROLL_DOWN_LINE,
83 CMD_LIST_SCROLL_UP_HALF,
84 CMD_LIST_SCROLL_DOWN_HALF,
85 CMD_MOUSE_EVENT,
86 CMD_SCREEN_UPDATE,
87 CMD_SCREEN_PREVIOUS,
88 CMD_SCREEN_NEXT,
89 CMD_SCREEN_SWAP,
90 CMD_SCREEN_PLAY,
91 CMD_SCREEN_FILE,
92 CMD_SCREEN_ARTIST,
93 CMD_SCREEN_SEARCH,
94 CMD_SCREEN_SONG,
95 CMD_SCREEN_KEYDEF,
96 CMD_SCREEN_HELP,
97 CMD_SCREEN_LYRICS,
98 CMD_SCREEN_OUTPUTS,
99 CMD_LYRICS_UPDATE,
100 CMD_EDIT,
101 CMD_INTERRUPT,
102 CMD_GO_ROOT_DIRECTORY,
103 CMD_GO_PARENT_DIRECTORY,
104 CMD_LOCATE,
105 CMD_QUIT
106 } command_t;
109 #ifndef NCMPC_MINI
110 /* command definition flags */
111 #define COMMAND_KEY_MODIFIED 0x01
112 #define COMMAND_KEY_CONFLICT 0x02
113 #endif
115 /* write key bindings flags */
116 #define KEYDEF_WRITE_HEADER 0x01
117 #define KEYDEF_WRITE_ALL 0x02
118 #define KEYDEF_COMMENT_ALL 0x04
120 typedef struct {
121 int keys[MAX_COMMAND_KEYS];
122 char flags;
123 command_t command;
124 const char *name;
125 const char *description;
126 } command_definition_t;
128 #ifdef ENABLE_KEYDEF_SCREEN
129 command_definition_t *get_command_definitions(void);
130 size_t get_cmds_max_name_width(command_definition_t *cmds);
131 #endif
133 command_t find_key_command(int key, command_definition_t *cmds);
135 void command_dump_keys(void);
137 #ifndef NCMPC_MINI
139 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
140 int write_key_bindings(FILE *f, int all);
142 #endif
144 const char *key2str(int key);
145 const char *get_key_description(command_t command);
146 const char *get_key_command_name(command_t command);
147 const char *get_key_names(command_t command, bool all);
148 command_t get_key_command(int key);
149 command_t get_key_command_from_name(char *name);
150 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
152 command_t get_keyboard_command(void);
154 #endif