a1d5858d974d582332f4f0e658310b6f91de48ec
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_SINGLE,
52 CMD_CROSSFADE,
53 CMD_DB_UPDATE,
54 CMD_VOLUME_UP,
55 CMD_VOLUME_DOWN,
56 CMD_ADD,
57 CMD_SAVE_PLAYLIST,
58 CMD_TOGGLE_FIND_WRAP,
59 CMD_TOGGLE_AUTOCENTER,
60 CMD_SEARCH_MODE,
61 CMD_LIST_PREVIOUS,
62 CMD_LIST_NEXT,
63 CMD_LIST_TOP,
64 CMD_LIST_MIDDLE,
65 CMD_LIST_BOTTOM,
66 CMD_LIST_FIRST,
67 CMD_LIST_LAST,
68 CMD_LIST_NEXT_PAGE,
69 CMD_LIST_PREVIOUS_PAGE,
70 CMD_LIST_FIND,
71 CMD_LIST_FIND_NEXT,
72 CMD_LIST_RFIND,
73 CMD_LIST_RFIND_NEXT,
74 CMD_LIST_JUMP,
75 CMD_LIST_MOVE_UP,
76 CMD_LIST_MOVE_DOWN,
77 CMD_LIST_RANGE_SELECT,
78 CMD_LIST_SCROLL_UP_LINE,
79 CMD_LIST_SCROLL_DOWN_LINE,
80 CMD_LIST_SCROLL_UP_HALF,
81 CMD_LIST_SCROLL_DOWN_HALF,
82 CMD_MOUSE_EVENT,
83 CMD_SCREEN_UPDATE,
84 CMD_SCREEN_PREVIOUS,
85 CMD_SCREEN_NEXT,
86 CMD_SCREEN_SWAP,
87 CMD_SCREEN_PLAY,
88 CMD_SCREEN_FILE,
89 CMD_SCREEN_ARTIST,
90 CMD_SCREEN_SEARCH,
91 CMD_SCREEN_SONG,
92 CMD_SCREEN_KEYDEF,
93 CMD_SCREEN_HELP,
94 CMD_SCREEN_LYRICS,
95 CMD_SCREEN_OUTPUTS,
96 CMD_LYRICS_UPDATE,
97 CMD_INTERRUPT,
98 CMD_GO_ROOT_DIRECTORY,
99 CMD_GO_PARENT_DIRECTORY,
100 CMD_LOCATE,
101 CMD_QUIT
102 } command_t;
105 #ifndef NCMPC_MINI
106 /* command definition flags */
107 #define COMMAND_KEY_MODIFIED 0x01
108 #define COMMAND_KEY_CONFLICT 0x02
109 #endif
111 /* write key bindings flags */
112 #define KEYDEF_WRITE_HEADER 0x01
113 #define KEYDEF_WRITE_ALL 0x02
114 #define KEYDEF_COMMENT_ALL 0x04
116 typedef struct {
117 int keys[MAX_COMMAND_KEYS];
118 char flags;
119 command_t command;
120 const char *name;
121 const char *description;
122 } command_definition_t;
124 #ifdef ENABLE_KEYDEF_SCREEN
125 command_definition_t *get_command_definitions(void);
126 #endif
128 command_t find_key_command(int key, command_definition_t *cmds);
130 void command_dump_keys(void);
132 #ifndef NCMPC_MINI
134 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
135 int write_key_bindings(FILE *f, int all);
137 #endif
139 const char *key2str(int key);
140 const char *get_key_description(command_t command);
141 const char *get_key_command_name(command_t command);
142 const char *get_key_names(command_t command, int all);
143 command_t get_key_command(int key);
144 command_t get_key_command_from_name(char *name);
145 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
147 command_t get_keyboard_command(void);
149 #endif