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_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_SEARCH_MODE,
62 CMD_LIST_PREVIOUS,
63 CMD_LIST_NEXT,
64 CMD_LIST_TOP,
65 CMD_LIST_MIDDLE,
66 CMD_LIST_BOTTOM,
67 CMD_LIST_FIRST,
68 CMD_LIST_LAST,
69 CMD_LIST_NEXT_PAGE,
70 CMD_LIST_PREVIOUS_PAGE,
71 CMD_LIST_FIND,
72 CMD_LIST_FIND_NEXT,
73 CMD_LIST_RFIND,
74 CMD_LIST_RFIND_NEXT,
75 CMD_LIST_JUMP,
76 CMD_LIST_MOVE_UP,
77 CMD_LIST_MOVE_DOWN,
78 CMD_LIST_RANGE_SELECT,
79 CMD_LIST_SCROLL_UP_LINE,
80 CMD_LIST_SCROLL_DOWN_LINE,
81 CMD_LIST_SCROLL_UP_HALF,
82 CMD_LIST_SCROLL_DOWN_HALF,
83 CMD_MOUSE_EVENT,
84 CMD_SCREEN_UPDATE,
85 CMD_SCREEN_PREVIOUS,
86 CMD_SCREEN_NEXT,
87 CMD_SCREEN_SWAP,
88 CMD_SCREEN_PLAY,
89 CMD_SCREEN_FILE,
90 CMD_SCREEN_ARTIST,
91 CMD_SCREEN_SEARCH,
92 CMD_SCREEN_SONG,
93 CMD_SCREEN_KEYDEF,
94 CMD_SCREEN_HELP,
95 CMD_SCREEN_LYRICS,
96 CMD_SCREEN_OUTPUTS,
97 CMD_LYRICS_UPDATE,
98 CMD_INTERRUPT,
99 CMD_GO_ROOT_DIRECTORY,
100 CMD_GO_PARENT_DIRECTORY,
101 CMD_LOCATE,
102 CMD_QUIT
103 } command_t;
106 #ifndef NCMPC_MINI
107 /* command definition flags */
108 #define COMMAND_KEY_MODIFIED 0x01
109 #define COMMAND_KEY_CONFLICT 0x02
110 #endif
112 /* write key bindings flags */
113 #define KEYDEF_WRITE_HEADER 0x01
114 #define KEYDEF_WRITE_ALL 0x02
115 #define KEYDEF_COMMENT_ALL 0x04
117 typedef struct {
118 int keys[MAX_COMMAND_KEYS];
119 char flags;
120 command_t command;
121 const char *name;
122 const char *description;
123 } command_definition_t;
125 #ifdef ENABLE_KEYDEF_SCREEN
126 command_definition_t *get_command_definitions(void);
127 #endif
129 command_t find_key_command(int key, command_definition_t *cmds);
131 void command_dump_keys(void);
133 #ifndef NCMPC_MINI
135 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
136 int write_key_bindings(FILE *f, int all);
138 #endif
140 const char *key2str(int key);
141 const char *get_key_description(command_t command);
142 const char *get_key_command_name(command_t command);
143 const char *get_key_names(command_t command, int all);
144 command_t get_key_command(int key);
145 command_t get_key_command_from_name(char *name);
146 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
148 command_t get_keyboard_command(void);
150 #endif