1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2009 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
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.
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.
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_CROSSFADE,
52 CMD_DB_UPDATE,
53 CMD_VOLUME_UP,
54 CMD_VOLUME_DOWN,
55 CMD_ADD,
56 CMD_SAVE_PLAYLIST,
57 CMD_TOGGLE_FIND_WRAP,
58 CMD_TOGGLE_AUTOCENTER,
59 CMD_SEARCH_MODE,
60 CMD_LIST_PREVIOUS,
61 CMD_LIST_NEXT,
62 CMD_LIST_TOP,
63 CMD_LIST_MIDDLE,
64 CMD_LIST_BOTTOM,
65 CMD_LIST_FIRST,
66 CMD_LIST_LAST,
67 CMD_LIST_NEXT_PAGE,
68 CMD_LIST_PREVIOUS_PAGE,
69 CMD_LIST_FIND,
70 CMD_LIST_FIND_NEXT,
71 CMD_LIST_RFIND,
72 CMD_LIST_RFIND_NEXT,
73 CMD_LIST_JUMP,
74 CMD_LIST_MOVE_UP,
75 CMD_LIST_MOVE_DOWN,
76 CMD_LIST_VISUAL_SELECT,
77 CMD_LIST_SCROLL_UP_LINE,
78 CMD_LIST_SCROLL_DOWN_LINE,
79 CMD_LIST_SCROLL_UP_HALF,
80 CMD_LIST_SCROLL_DOWN_HALF,
81 CMD_MOUSE_EVENT,
82 CMD_SCREEN_UPDATE,
83 CMD_SCREEN_PREVIOUS,
84 CMD_SCREEN_NEXT,
85 CMD_SCREEN_SWAP,
86 CMD_SCREEN_PLAY,
87 CMD_SCREEN_FILE,
88 CMD_SCREEN_ARTIST,
89 CMD_SCREEN_SEARCH,
90 CMD_SCREEN_KEYDEF,
91 CMD_SCREEN_HELP,
92 CMD_SCREEN_LYRICS,
93 CMD_SCREEN_OUTPUTS,
94 CMD_LYRICS_UPDATE,
95 CMD_INTERRUPT,
96 CMD_GO_ROOT_DIRECTORY,
97 CMD_GO_PARENT_DIRECTORY,
98 CMD_VIEW,
99 CMD_LOCATE,
100 CMD_QUIT
101 } command_t;
104 #ifndef NCMPC_MINI
105 /* command definition flags */
106 #define COMMAND_KEY_MODIFIED 0x01
107 #define COMMAND_KEY_CONFLICT 0x02
108 #endif
110 /* write key bindings flags */
111 #define KEYDEF_WRITE_HEADER 0x01
112 #define KEYDEF_WRITE_ALL 0x02
113 #define KEYDEF_COMMENT_ALL 0x04
115 typedef struct {
116 int keys[MAX_COMMAND_KEYS];
117 char flags;
118 command_t command;
119 const char *name;
120 const char *description;
121 } command_definition_t;
123 #ifdef ENABLE_KEYDEF_SCREEN
124 command_definition_t *get_command_definitions(void);
125 #endif
127 command_t find_key_command(int key, command_definition_t *cmds);
129 void command_dump_keys(void);
131 #ifndef NCMPC_MINI
133 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
134 int write_key_bindings(FILE *f, int all);
136 #endif
138 const char *key2str(int key);
139 const char *get_key_description(command_t command);
140 const char *get_key_command_name(command_t command);
141 const char *get_key_names(command_t command, int all);
142 command_t get_key_command(int key);
143 command_t get_key_command_from_name(char *name);
144 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
146 command_t get_keyboard_command(void);
148 #endif