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