ncmpc  0.29
command.h
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2017 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  */
19 
20 #ifndef COMMAND_H
21 #define COMMAND_H
22 
23 #include "config.h"
24 #include "Compiler.h"
25 
26 #include <stddef.h>
27 #include <stdbool.h>
28 
29 #ifndef NCMPC_MINI
30 #include <stdio.h>
31 #endif
32 
33 #define MAX_COMMAND_KEYS 3
34 
35 /* commands */
36 typedef enum {
37  CMD_NONE = 0,
107 } command_t;
108 
109 
110 #ifndef NCMPC_MINI
111 /* command definition flags */
112 #define COMMAND_KEY_MODIFIED 0x01
113 #define COMMAND_KEY_CONFLICT 0x02
114 #endif
115 
116 /* write key bindings flags */
117 #define KEYDEF_WRITE_HEADER 0x01
118 #define KEYDEF_WRITE_ALL 0x02
119 #define KEYDEF_COMMENT_ALL 0x04
120 
121 typedef struct {
122  int keys[MAX_COMMAND_KEYS];
123  char flags;
125  const char *name;
126  const char *description;
128 
129 #ifdef ENABLE_KEYDEF_SCREEN
130 command_definition_t *get_command_definitions(void);
131 size_t get_cmds_max_name_width(command_definition_t *cmds);
132 #endif
133 
134 gcc_pure
135 command_t
136 find_key_command(int key, const command_definition_t *cmds);
137 
138 void command_dump_keys(void);
139 
140 #ifndef NCMPC_MINI
141 
145 bool
146 check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
147 
151 bool
152 write_key_bindings(FILE *f, int all);
153 
154 #endif
155 
156 gcc_pure
157 const char *key2str(int key);
158 
159 gcc_pure
160 const char *get_key_description(command_t command);
161 
162 gcc_pure
163 const char *get_key_command_name(command_t command);
164 
165 gcc_pure
166 const char *get_key_names(command_t command, bool all);
167 
168 gcc_pure
169 command_t get_key_command(int key);
170 
171 gcc_pure
172 command_t
173 get_key_command_from_name(const char *name);
174 
178 bool
179 assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
180 
181 #endif
Definition: command.h:98
Definition: command.h:106
gcc_pure const char * key2str(int key)
Definition: command.h:76
Definition: command.h:39
const char * description
Definition: command.h:126
Definition: command.h:67
Definition: command.h:102
Definition: command.h:61
Definition: command.h:82
Definition: command.h:80
Definition: command.h:94
#define MAX_COMMAND_KEYS
Definition: command.h:33
Definition: command.h:70
Definition: command.h:101
Definition: command.h:86
Definition: command.h:48
Definition: command.h:79
Definition: command.h:74
Definition: command.h:99
Definition: command.h:47
Definition: command.h:69
Definition: command.h:65
Definition: command.h:87
Definition: command.h:68
Definition: command.h:52
Definition: command.h:77
Definition: command.h:63
Definition: command.h:66
Definition: command.h:59
Definition: command.h:90
gcc_pure command_t find_key_command(int key, const command_definition_t *cmds)
Definition: command.h:78
const char * name
Definition: command.h:125
Definition: command.h:56
Definition: command.h:89
Definition: command.h:83
bool write_key_bindings(FILE *f, int all)
Definition: command.h:46
bool check_key_bindings(command_definition_t *cmds, char *buf, size_t size)
void command_dump_keys(void)
Definition: command.h:97
Definition: command.h:57
Definition: command.h:42
char flags
Definition: command.h:123
Definition: command.h:93
command_t
Definition: command.h:36
Definition: command.h:85
Definition: command.h:50
Definition: command.h:96
Definition: command.h:103
Definition: command.h:58
Definition: command.h:73
Definition: command.h:121
Definition: command.h:81
gcc_pure command_t get_key_command(int key)
Definition: command.h:92
Definition: command.h:75
Definition: command.h:41
gcc_pure const char * get_key_names(command_t command, bool all)
Definition: command.h:100
Definition: command.h:45
Definition: command.h:38
Definition: command.h:72
Definition: command.h:40
Definition: command.h:44
Definition: command.h:105
Definition: command.h:95
Definition: command.h:64
Definition: command.h:88
gcc_pure const char * get_key_description(command_t command)
Definition: command.h:62
Definition: command.h:51
Definition: command.h:91
Definition: command.h:104
command_t command
Definition: command.h:124
#define gcc_pure
Definition: Compiler.h:100
Definition: command.h:71
Definition: command.h:55
gcc_pure const char * get_key_command_name(command_t command)
Definition: command.h:53
bool assign_keys(command_t command, int keys[MAX_COMMAND_KEYS])
gcc_pure command_t get_key_command_from_name(const char *name)
Definition: command.h:37
Definition: command.h:60
Definition: command.h:43
Definition: command.h:54
Definition: command.h:49
Definition: command.h:84