Code

9e8b1664d2475d585be84d71e392753fa26b9d8f
[ncmpc.git] / src / command.h
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2010 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  */
20 #ifndef COMMAND_H
21 #define COMMAND_H
23 #include "config.h"
25 #include <stddef.h>
26 #include <stdbool.h>
28 #ifndef NCMPC_MINI
29 #include <stdio.h>
30 #endif
32 #define MAX_COMMAND_KEYS 3
34 /* commands */
35 typedef enum {
36         CMD_NONE = 0,
37         CMD_PLAY,
38         CMD_SELECT,
39         CMD_SELECT_ALL,
40         CMD_PAUSE,
41         CMD_STOP,
42         CMD_CROP,
43         CMD_TRACK_NEXT,
44         CMD_TRACK_PREVIOUS,
45         CMD_SEEK_FORWARD,
46         CMD_SEEK_BACKWARD,
47         CMD_SHUFFLE,
48         CMD_RANDOM,
49         CMD_CLEAR,
50         CMD_DELETE,
51         CMD_REPEAT,
52         CMD_SINGLE,
53         CMD_CONSUME,
54         CMD_CROSSFADE,
55         CMD_DB_UPDATE,
56         CMD_VOLUME_UP,
57         CMD_VOLUME_DOWN,
58         CMD_ADD,
59         CMD_SAVE_PLAYLIST,
60         CMD_TOGGLE_FIND_WRAP,
61         CMD_TOGGLE_AUTOCENTER,
62         CMD_SELECT_PLAYING,
63         CMD_SEARCH_MODE,
64         CMD_LIST_PREVIOUS,
65         CMD_LIST_NEXT,
66         CMD_LIST_TOP,
67         CMD_LIST_MIDDLE,
68         CMD_LIST_BOTTOM,
69         CMD_LIST_FIRST,
70         CMD_LIST_LAST,
71         CMD_LIST_NEXT_PAGE,
72         CMD_LIST_PREVIOUS_PAGE,
73         CMD_LIST_FIND,
74         CMD_LIST_FIND_NEXT,
75         CMD_LIST_RFIND,
76         CMD_LIST_RFIND_NEXT,
77         CMD_LIST_JUMP,
78         CMD_LIST_MOVE_UP,
79         CMD_LIST_MOVE_DOWN,
80         CMD_LIST_RANGE_SELECT,
81         CMD_LIST_SCROLL_UP_LINE,
82         CMD_LIST_SCROLL_DOWN_LINE,
83         CMD_LIST_SCROLL_UP_HALF,
84         CMD_LIST_SCROLL_DOWN_HALF,
85         CMD_MOUSE_EVENT,
86         CMD_SCREEN_UPDATE,
87         CMD_SCREEN_PREVIOUS,
88         CMD_SCREEN_NEXT,
89         CMD_SCREEN_SWAP,
90         CMD_SCREEN_PLAY,
91         CMD_SCREEN_FILE,
92         CMD_SCREEN_ARTIST,
93         CMD_SCREEN_SEARCH,
94         CMD_SCREEN_SONG,
95         CMD_SCREEN_KEYDEF,
96         CMD_SCREEN_HELP,
97         CMD_SCREEN_LYRICS,
98         CMD_SCREEN_OUTPUTS,
99         CMD_SCREEN_CHAT,
100         CMD_LYRICS_UPDATE,
101         CMD_EDIT,
102         CMD_INTERRUPT,
103         CMD_GO_ROOT_DIRECTORY,
104         CMD_GO_PARENT_DIRECTORY,
105         CMD_LOCATE,
106         CMD_QUIT
107 } command_t;
110 #ifndef NCMPC_MINI
111 /* command definition flags */
112 #define COMMAND_KEY_MODIFIED  0x01
113 #define COMMAND_KEY_CONFLICT  0x02
114 #endif
116 /* write key bindings flags */
117 #define KEYDEF_WRITE_HEADER  0x01
118 #define KEYDEF_WRITE_ALL     0x02
119 #define KEYDEF_COMMENT_ALL   0x04
121 typedef struct  {
122         int keys[MAX_COMMAND_KEYS];
123         char flags;
124         command_t command;
125         const char *name;
126         const char *description;
127 } command_definition_t;
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
134 command_t find_key_command(int key, command_definition_t *cmds);
136 void command_dump_keys(void);
138 #ifndef NCMPC_MINI
140 int check_key_bindings(command_definition_t *cmds, char *buf, size_t size);
141 int write_key_bindings(FILE *f, int all);
143 #endif
145 const char *key2str(int key);
146 const char *get_key_description(command_t command);
147 const char *get_key_command_name(command_t command);
148 const char *get_key_names(command_t command, bool all);
149 command_t get_key_command(int key);
150 command_t get_key_command_from_name(char *name);
151 int assign_keys(command_t command, int keys[MAX_COMMAND_KEYS]);
153 command_t get_keyboard_command(void);
155 #endif