File: command.h

package info (click to toggle)
ncmpc 0.25-0.1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,616 kB
  • sloc: ansic: 12,229; sh: 4,157; makefile: 282; ruby: 28
file content (185 lines) | stat: -rw-r--r-- 3,802 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/* ncmpc (Ncurses MPD Client)
 * (c) 2004-2010 The Music Player Daemon Project
 * Project homepage: http://musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef COMMAND_H
#define COMMAND_H

#include "config.h"
#include "Compiler.h"

#include <stddef.h>
#include <stdbool.h>

#ifndef NCMPC_MINI
#include <stdio.h>
#endif

#define MAX_COMMAND_KEYS 3

/* commands */
typedef enum {
	CMD_NONE = 0,
	CMD_PLAY,
	CMD_SELECT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
	CMD_LYRICS_UPDATE,
	CMD_EDIT,
	CMD_INTERRUPT,
	CMD_GO_ROOT_DIRECTORY,
	CMD_GO_PARENT_DIRECTORY,
	CMD_LOCATE,
	CMD_QUIT
} command_t;


#ifndef NCMPC_MINI
/* command definition flags */
#define COMMAND_KEY_MODIFIED  0x01
#define COMMAND_KEY_CONFLICT  0x02
#endif

/* write key bindings flags */
#define KEYDEF_WRITE_HEADER  0x01
#define KEYDEF_WRITE_ALL     0x02
#define KEYDEF_COMMENT_ALL   0x04

typedef struct  {
	int keys[MAX_COMMAND_KEYS];
	char flags;
	command_t command;
	const char *name;
	const char *description;
} command_definition_t;

#ifdef ENABLE_KEYDEF_SCREEN
command_definition_t *get_command_definitions(void);
size_t get_cmds_max_name_width(command_definition_t *cmds);
#endif

gcc_pure
command_t
find_key_command(int key, const command_definition_t *cmds);

void command_dump_keys(void);

#ifndef NCMPC_MINI

/**
 * @return true on success, false on error
 */
bool
check_key_bindings(command_definition_t *cmds, char *buf, size_t size);

/**
 * @return true on success, false on error
 */
bool
write_key_bindings(FILE *f, int all);

#endif

gcc_pure
const char *key2str(int key);

gcc_pure
const char *get_key_description(command_t command);

gcc_pure
const char *get_key_command_name(command_t command);

gcc_pure
const char *get_key_names(command_t command, bool all);

gcc_pure
command_t get_key_command(int key);

gcc_pure
command_t
get_key_command_from_name(const char *name);

/**
 * @return true on success, false on error
 */
bool
assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);

gcc_pure
command_t get_keyboard_command(void);

#endif